You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use yarn 2 to build an application with webpack and I get this error when building with both webpack 4 and pnp-webpack-plugin and webpack 5:
(node:415) UnhandledPromiseRejectionWarning: Error: Error on webpack build: ../lib/core/lib/nudash.js
Module not found: Error: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies
Required package: core-js (via "core-js/modules/web.dom-collections.iterator")
Required by: /usr/src/app/lib/core/lib/nudash.js
As @sokra rightly explained Babel injects core-js in your built files, but you still need to add it explicitly to your owns. Otherwise you would rely on hoisting, which is unsound (there's no telling which version of core-js you'd get depending on the packages that are part of the dependency tree).
Because hoisting made it accidentally work. Yarn 2 makes things stricter and let you know when you're using unsound pattern that will eventually cause problems in your deployment - instead of just letting you think that things are alright until the crash.
Sorry, I understand the difference between yarn 1 and 2 and what's going on there (I actually really like the explicit resolution that's happening with yarn 2).
The injection of core-js by babel into a "standard module" that's listed in package.json and pulled from npm appears to work just fine, so my question is why doesn't it behave the same way and work just like a "standard module" with my "workspace module" that is also listed in package.json?
Describe the bug
I'm trying to use yarn 2 to build an application with webpack and I get this error when building with both webpack 4 and pnp-webpack-plugin and webpack 5:
It appears that the use of
core-js
that's being done bybabel
isn't resolving in the workspace modules.To Reproduce
Use a module in a workspace that is processed by
babel
wherecore-js
is usedEnvironment if relevant (please complete the following information):
The text was updated successfully, but these errors were encountered: