nx-plus: Docusaurus build crashes during minification
Current Behavior
Build process crashes at the end
Expected Behavior
Build process to pass
Steps to Reproduce
- Create nx workspace
- create a docusaurus app
- Build the docusaurus app
This issue may not be prioritized if details are not provided to help us reproduce the issue.
Failure Logs
> nx run dummy-doc:build 
Creating an optimized production build...
2019-05-28-hola.md - 'id' header option is deprecated. Please use 'slug' option instead.
2019-05-29-hello-world.md - 'id' header option is deprecated. Please use 'slug' option instead.
2019-05-30-welcome.md - 'id' header option is deprecated. Please use 'slug' option instead.
✔ Client
  Compiled successfully in 8.06s
✖ Server
  Compiled with some errors in 9.59s
TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:17359:28)
    at Object.chars (main:17847:24)
    at main:46819:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:46811:19)
    at minify (main:17633:3)
    at module.exports.exports.minify (main:17994:16)
    at serverEntry_render (main:84584:38)
Environment
Plugin name and version: @nx-plus/docusaurus#8b21c9f
NX Report complete
  nx : 10.2.1
  @nrwl/angular : Not Found
  @nrwl/cli : 10.2.1
  @nrwl/cypress : 10.2.1
  @nrwl/eslint-plugin-nx : 10.2.1
  @nrwl/express : Not Found
  @nrwl/jest : 10.2.1
  @nrwl/linter : 10.2.1
  @nrwl/nest : Not Found
  @nrwl/next : 10.2.1
  @nrwl/node : Not Found
  @nrwl/react : 10.2.1
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.2.1
  @nrwl/web : 10.2.1
  @nrwl/workspace : 10.2.1
  typescript : 4.0.3```
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24
@BuckyMaler I can confirm you that with
terser-webpack-plugininstalled manually, the build is completed with no issue.@taylorreece thanks for the additional details, but
nohoistwon’t work with Nx because it doesn’t use yarn workspaces.@dbrrt the issue is that Docusaurus resolves a different version of
terser-webpack-pluginwhen@nrwl/webis installed. There are a couple of workarounds that may work for you as we sort out this issue. The first workaround is to install the version ofterser-webpack-pluginexpected by Docusaurus, i.e.yarn add terser-webpack-plugin@^4.1.0 -D. The second workaround is to switch from yarn to npm. I cannot reproduce the error when using npm.I hope one of those workarounds help.
I’m closing this because it’s not a
@nx-plus/docusaurusbug. There’s a documented workaround here thanks to @devinshoemaker, and a couple more workarounds here.I’m going to leave this issue open for now. Though I think the fix will be a PR in Nx and/or Docusaurus. Here are a couple of workarounds in the meantime.
@dbrrt I wanted to notify you that we’ve added contributing docs so that may be helpful as you work on this. Let me know if there’s anything I can do to help.
I can reproduce the error when
@nrwl/webis installed. I can also reproduce the error when@nrwl/reactor@nrwl/nextare installed, but that’s because@nrwl/webis a dependency of those. I think the issue may be due to a shared build dependency and Docusaurus resolving the wrong version of that dependency. @dbrrt would you like to look into this?