-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while running getDataFromTree
ReferenceError: document is not defined
#124
Comments
Hi @ianberdin,
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": [
+ "dom",
"esnext"
],
}
} |
Thanks for the quick response. {
"compilerOptions": {
"baseUrl": "./",
"allowSyntheticDefaultImports": true,
"module": "esnext",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext",
],
"downlevelIteration": true,
"sourceMap": false,
"allowJs": false,
"esModuleInterop": true,
"jsx": "preserve",
"moduleResolution": "node",
"noImplicitReturns": false,
"noImplicitThis": false,
"noImplicitAny": false,
"strictNullChecks": false,
"declaration": true,
"skipLibCheck": true,
"typeRoots": [
"./node_modules/@types",
"../frontend/node_modules/@types"
],
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"resolveJsonModule": true,
"isolatedModules": true,
} /* eslint-disable no-param-reassign */
const withBundleAnalyzer = require('@next/bundle-analyzer');
const withPlugins = require('next-compose-plugins');
const path = require('path');
const isDev = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'testing';
const packageJson = require('../../version.json');
const nextConfig = {
swcMinify: process.env.ENV === 'production',
webpack(webpackConfig, options) {
Object.assign(webpackConfig.resolve.alias, aliases);
webpackConfig.cache = {
type: 'filesystem',
compression: false,
}
webpackConfig.module.rules.push({
test: /\.(ts|tsx)$/,
include: Object.values(aliases),
use: {loader: 'swc-loader'},
exclude: /node_modules/,
});
return webpackConfig;
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
};
module.exports = async (phase) => withPlugins([
[withBundleAnalyzer({enabled: false})],
],
nextConfig
)(phase, { undefined }); |
It looks like Apollo SSR runs your code in the server. I think we need to use check if it is server. if (ssr && AppTree) {
try {
const { getDataFromTree } = await import('@apollo/client/react/ssr');
let props;
if (inAppContext) {
props = { ...pageProps, apolloClient };
} else {
props = { pageProps: { ...pageProps, apolloClient } };
}
await getDataFromTree(<AppTree {...props} />);
} catch (error) {
console.error('Error while running `getDataFromTree`', error);
}
} |
@garronej what do you think? |
Sorry, it's a runtime error, my bad. |
Hey @ianberdin, Thanks for reporting, I'm not fully sure it's okay to do that, though. What are you thought? Can you try the release candidate, make sure everything works as you expect? If you tell me everything is OK, I'll release for everyone. PS: You are using two caches, it means that you ran into issues using only one. Would you tell me with what MUI component in particular? |
Hi @garronej. Also we had to downgrade from react 18 to 17. Because Apollo SSR doesn't ready yet.
Thanks again. |
Versions
The text was updated successfully, but these errors were encountered: