Skip to content
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

(v2) react-loadable-ssr-addon getBundles error #2898

Closed
ark120202 opened this issue Jun 6, 2020 · 7 comments
Closed

(v2) react-loadable-ssr-addon getBundles error #2898

ark120202 opened this issue Jun 6, 2020 · 7 comments
Assignees
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@ark120202
Copy link

🐛 Bug Report

Running docusaurus build in a project with swizzled DocItem and DocPage components throws an when server code is being evaluated.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Create a new project using @docusaurus/init with classic template
  2. Remove blog directory
  3. yarn docusaurus swizzle @docusaurus/theme-classic DocItem
  4. yarn docusaurus swizzle @docusaurus/theme-classic DocPage
  5. Run yarn build

Expected behavior

docusaurus build to finish successfully

Actual Behavior

Failed CI logs

$ 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>)

Your Environment

  • Docusaurus version used: 2.0.0-alpha.56
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node.js v14.3.0
  • Operating system and version (desktop or mobile): Linux

Reproducible Demo

https://github.com/ark120202/docusaurus-issue

@ark120202 ark120202 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jun 6, 2020
@slorber
Copy link
Collaborator

slorber commented Jun 8, 2020

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'

@slorber slorber self-assigned this Jun 8, 2020
@ark120202
Copy link
Author

ark120202 commented Jun 8, 2020

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 (ModDota/moddota.github.io@ddd4b3a, 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).

@slorber
Copy link
Collaborator

slorber commented Jun 8, 2020

Hi @ark120202

I've opened a PR here with a potential fix here: themgoncalves/react-loadable-ssr-addon#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?

@slorber slorber added v2 and removed status: needs triage This issue has not been triaged by maintainers labels Jun 8, 2020
@slorber slorber changed the title Server build error with swizzled DocItem and DocPage components (v2) react-loadable-ssr-addon getBundles error Jun 8, 2020
@ark120202
Copy link
Author

Yes, this patch also makes it work for me

@slorber
Copy link
Collaborator

slorber commented Jun 9, 2020

Great to know. Are you able to get your full site building without trouble or it just fixes the issue repo?

@ark120202
Copy link
Author

I have tried it on the repository where I have found that issue originally (ModDota/moddota.github.io@ddd4b3a)

slorber added a commit to slorber/docusaurus that referenced this issue Jun 11, 2020
yangshun added a commit that referenced this issue Jun 16, 2020
* docs(v2): fix typo in ExecutionEnvironment example

* upgrade react-loadable-ssr-addon for #2898

Co-authored-by: Yangshun Tay <tay.yang.shun@gmail.com>
@slorber
Copy link
Collaborator

slorber commented Jun 17, 2020

fixed in next release (alpha 57 soon)

@slorber slorber closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

2 participants