This demonstrates an issue the DllPlugin/DllReferencePlugin when running Yarn 2 when it uses virtual paths.
yarn@~1.22.0 installed globally
cd dll-lib
yarn set version berry # set yarn to v2
yarn # install
yarn webpack
cd lib-user
yarn set version berry # set yarn to v2
yarn # install
yarn webpack
The bundle in lib-user
makes a reference to react-dom
in it's bundle by using library-manifest.json
in dll-lib
.
react-dom
is bundled into lib-user/dist/index.js
.
In library-manifest.json
in dll-lib
the reference is a yarn 2 virtual package.
{
"name": "library_1109ed9bec109636950b",
"content": {
"./.yarn/$$virtual/react-dom-virtual-4970a0b490/0/cache/react-dom-npm-16.12.0-4ea576dd1a-2.zip/node_modules/react-dom/index.js": {
"id": 601,
"buildMeta": {}
}
}
}
When the webpack build in dll-user
runs, it looks for react-dom
but the path it has in .pnp.js
is:
"packageLocation": "./.yarn/$$virtual/react-dom-virtual-76a393ef8c/0/cache/react-dom-npm-16.12.0-4ea576dd1a-2.zip/node_modules/react-dom/",
From reading the yarn docs here and here it looks like these virtual paths are unique to disambiguate packages that list peerDependencies. So while they both point to the same package the virtual path will not be the same. This will prevent the reference being be pulled in as the paths won't match.