-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(core): resolve webpack loaders with require.resolve()
#3341
Conversation
With strict package managers such as pnpm or Yarn PnP, transitive dependencies are *not* hoisted to the root node_modules folder. This means that a webpack config defined within a package like '@nrwl/cypress' cannot resolve loaders like 'ts-loader', unless 'ts-loader' is declared in the workspace's own package.json. This is a problem because the workspace might define a different version of 'ts-loader', incompatible with the version declared by '@nrwl/cypress/package.json'. The workspace should not need to declare a dependency on 'ts-loader' anyway. See also: * pnpm/pnpm#801 * webpack/webpack#5087
@elliottsj Going to have to revert this one since it is causing an issue with apps not being styled. I think you need to install https://github.com/arcanis/pnp-webpack-plugin You can test your changes locally by publishing to your local registry. https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#publishing-to-a-local-registry |
@elliottsj Basically styles were not applied, I'm guessing due to the loaders not being found but didn't debug too much. I'll check out your new PR. Thanks! |
With strict package managers such as pnpm or Yarn PnP, transitive dependencies are *not* hoisted to the root node_modules folder. This means that a webpack config defined within a package like '@nrwl/cypress' cannot resolve loaders like 'ts-loader', unless 'ts-loader' is declared in the workspace's own package.json. This is a problem because the workspace might define a different version of 'ts-loader', incompatible with the version declared by '@nrwl/cypress/package.json'. The workspace should not need to declare a dependency on 'ts-loader' anyway. See also: * pnpm/pnpm#801 * webpack/webpack#5087
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
With strict package managers such as pnpm or Yarn PnP, transitive dependencies are not hoisted to the root node_modules folder. This means that a webpack config defined within a package like '@nrwl/cypress' cannot resolve loaders like 'ts-loader', unless 'ts-loader' is declared in the workspace's own package.json.
This is a problem because the workspace might define a different version of 'ts-loader', incompatible with the version declared by '@nrwl/cypress/package.json'. The workspace should not need to declare a dependency on 'ts-loader' anyway.
By using
require.resolve()
, Node.js's module resolution is used instead of webpack's, so this issue is avoided.See also:
Current Behavior
Workspaces using pnpm must declare dependencies on loaders used by
@nrwl/*
packages, and manually keep the versions in sync. Or, apublic-hoist-pattern
must be defined to hoist webpack loaders.Expected Behavior
pnpm users should not have to declare transitive dependencies or customize package hoisting.