Minify failure when building docusaurus site in a yarn workspaces with another project #3515
Description
Edit from @slorber: TL.DR, try using this nohoist config
🐛 Bug Report
I have a Docusaurus-built site that shares a yarn.lock file with several other projects. Since bumping to Docusaurus to 2.0.0-alpha.64
from 2.0.0-alpha.63
, I have been unable to docusaurus build
. I get this error:
(undefined) TypeError: Cannot read property 'replace' of undefined
at Object.options.minifyJS (main:18614:28)
at Object.chars (main:19102:24)
at main:48074:19
at String.replace (<anonymous>)
at new HTMLParser (main:48066:19)
at minify (main:18888:3)
at module.exports.exports.minify (main:19249:16)
at serverEntry_render (main:87861:38)
Error: Failed to compile with errors.
at /Users/treece/src/docusaurus-minify-troubles/node_modules/@docusaurus/core/lib/webpack/utils.js:164:24
at finalCallback (/Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/MultiCompiler.js:254:12)
at /Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/MultiCompiler.js:277:6
at done (/Users/treece/src/docusaurus-minify-troubles/node_modules/neo-async/async.js:2931:13)
at runCompilers (/Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/MultiCompiler.js:181:48)
at /Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/MultiCompiler.js:188:7
at /Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/MultiCompiler.js:270:7
at finalCallback (/Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/Compiler.js:257:39)
at /Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/Compiler.js:273:13
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/treece/src/docusaurus-minify-troubles/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)
at AsyncSeriesHook.lazyCompileHook (/Users/treece/src/docusaurus-minify-troubles/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/Compiler.js:271:21)
at /Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/treece/src/docusaurus-minify-troubles/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/Users/treece/src/docusaurus-minify-troubles/node_modules/tapable/lib/Hook.js:154:20)
at /Users/treece/src/docusaurus-minify-troubles/node_modules/webpack/lib/Compiler.js:678:31
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
I've created a minimal repro repo, https://github.com/taylorreece/docusaurus-minify-troubles, with a new Docusaurus project created with npx @docusaurus/init@next init docs classic
. I did not touch the docusaurus project otherwise.
The other project in this repo, aptly named "other-project" has a package.json file with a series of dependencies.
These two projects share a yarn.lock
.
git clone git@github.com:taylorreece/docusaurus-minify-troubles.git
cd docusaurus-minify-troubles
yarn install
cd docs/
yarn build
If you remove other-project
and then yarn install
and yarn build
, the Docusaurus site builds fine.
Expected behavior
I'd expect it to build.
Actual Behavior
I get the stack trace listed above
Your Environment
MacOS
Node v12.16.2
Yarn v1.22.4