Running docusaurus build in a project with swizzled DocItem and DocPage components throws an when server code is being evaluated.
Yes
@docusaurus/init with classic templateblog directoryyarn docusaurus swizzle @docusaurus/theme-classic DocItemyarn docusaurus swizzle @docusaurus/theme-classic DocPageyarn builddocusaurus build to finish successfully
$ docusaurus build
Creating an optimized production build...
[info] [webpackbar] Compiling Client
[info] [webpackbar] Compiling Server
[success] [webpackbar] Client: Compiled successfully in 12.23s
[success] [webpackbar] Server: Compiled with some errors in 13.57s
(undefined) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
TypeError: Cannot convert undefined or null to object
at main:19364:12
at Array.reduce (<anonymous>)
at getBundles (main:19363:20)
at serverEntry_render (main:35231:113)
(undefined) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at main:19364:12
at Array.reduce (<anonymous>)
at getBundles (main:19363:20)
at serverEntry_render (main:35231:113)
(undefined) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at main:19364:12
at Array.reduce (<anonymous>)
at getBundles (main:19363:20)
at serverEntry_render (main:35231:113)
(undefined) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at main:19364:12
at Array.reduce (<anonymous>)
at getBundles (main:19363:20)
at serverEntry_render (main:35231:113)
(undefined) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at main:19364:12
at Array.reduce (<anonymous>)
at getBundles (main:19363:20)
at serverEntry_render (main:35231:113)
Error: Failed to compile with errors.
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/@docusaurus/core/lib/commands/build.js:38:24
at finalCallback (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/MultiCompiler.js:254:12)
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/MultiCompiler.js:277:6
at done (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/neo-async/async.js:2931:13)
at runCompilers (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/MultiCompiler.js:181:48)
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/MultiCompiler.js:188:7
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/MultiCompiler.js:270:7
at finalCallback (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/Compiler.js:257:39)
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/Compiler.js:273:13
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:42:1)
at AsyncSeriesHook.lazyCompileHook (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/Compiler.js:271:21)
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/tapable/lib/Hook.js:154:20)
at /home/runner/work/docusaurus-issue/docusaurus-issue/node_modules/webpack/lib/Compiler.js:678:31
at Function.keys (<anonymous>)
at Array.reduce (<anonymous>)TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Array.reduce (<anonymous>)TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Array.reduce (<anonymous>)TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Array.reduce (<anonymous>)TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Array.reduce (<anonymous>)
Hi @ark120202
I can reproduce your bug on your repo.
The blog folder removal does not seem to matter, removing the swizzled componets (both, not only one) seems to fix it.
I can't reproduce it by swizzling the same comps in D2 website, strange.
Will need more investigations, seems related to https://www.npmjs.com/package/react-loadable-ssr-addon
By chance can you explain to me how you used @docusaurus/init to create a 2.0.0-alpha.56 project?
Did you update the versions by hand?
Because it lead me to 2.0.0-alpha.39, and actually did not work so well either for other reasons:
~/Desktop/test-docu ๎ฐ yarn build ๎ฒ โ ๎ฒ 7699 ๎ฒ 12:21:26
yarn run v1.21.1
$ docusaurus build
Creating an optimized production build...
โ Client
Compiled with some errors in 14.99s
โ Server โโโโโโโโโโโโโโโโโโโโโโโโโ building (70%) 335/335 modules 0 active
./node_modules/@docusaurus/theme-classic/src/prism-include-languages.js
Module not found: Can't resolve '@docusaurus/ExecutionEnvironment' in '/Users/sebastienlorber/Desktop/test-docu/node_modules/@docusaurus/theme-classic/src'./node_modules/@docusaurus/theme-classic/src/theme/hooks/useScrollPosition.js
Module not found: Can't resolve '@docusaurus/ExecutionEnvironment' in '/Users/sebastienlorber/Desktop/test-docu/node_modules/@docusaurus/theme-classic/src/theme/hooks'./node_modules/@docusaurus/theme-classic/src/theme/DocItem/index.js
Module not found: Can't resolve '@docusaurus/isInternalUrl' in '/Users/sebastienlorber/Desktop/test-docu/node_modules/@docusaurus/theme-classic/src/theme/DocItem'./node_modules/@docusaurus/theme-classic/src/theme/DocSidebar/index.js
Module not found: Can't resolve '@docusaurus/isInternalUrl' in '/Users/sebastienlorber/Desktop/test-docu/node_modules/@docusaurus/theme-classic/src/theme/DocSidebar'./node_modules/@docusaurus/theme-classic/src/theme/Layout/index.js
Module not found: Can't resolve '@docusaurus/isInternalUrl' in '/Users/sebastienlorber/Desktop/test-docu/node_modules/@docusaurus/theme-classic/src/theme/Layout'./node_modules/@docusaurus/theme-classic/src/theme/hooks/useLogo.js
Module not found: Can't resolve '@docusaurus/isInternalUrl' in '/Users/sebastienlorber/Desktop/test-docu/node_modules/@docusaurus/theme-classic/src/theme/hooks'
The blog folder removal does not seem to matter, removing the swizzled componets (both, not only one) seems to fix it.
Restoring blog folder actually makes it build for me. One thing to note is that it's heavily affected by caching, so every time I have tried to test it I had to do
rm -rf .docusaurus node_modules/.cache && yarn build
I can't reproduce it by swizzling the same comps in D2 website, strange.
It's actually pretty inconsistent. I have found it in the https://github.com/ModDota/moddota.github.io repo, which builds fine now, but starts failing when I'm adding Algolia search (https://github.com/ModDota/moddota.github.io/commit/ddd4b3a2ff3a9ae14603240588ba6c4456f4fc25, CI).
By chance can you explain to me how you used @docusaurus/init to create a 2.0.0-alpha.56 project?
2.0.0-alpha.39 appears to be published under latest tag on npm. I have just used npx @docusaurus/init@next (as documented in installation instructions).
Hi @ark120202
I've opened a PR here with a potential fix here: https://github.com/themgoncalves/react-loadable-ssr-addon/pull/21
Not sure this is the solution to the problem, but at least doing this change locally did work for me. Maybe you could temporarily apply it with patch-package until we figure this out, and report us if it works fine?
Yes, this patch also makes it work for me
Great to know. Are you able to get your full site building without trouble or it just fixes the issue repo?
I have tried it on the repository where I have found that issue originally (https://github.com/ModDota/moddota.github.io/commit/ddd4b3a2ff3a9ae14603240588ba6c4456f4fc25)
fixed in next release (alpha 57 soon)