-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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()
#3436
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
@jaysoo I've published these changes to my local registry following https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md?rgh-link-date=2020-07-20T18%3A06%3A53Z#publishing-to-a-local-registry, and created an app using |
Thanks, I'm going to take a look this this week. |
@elliottsj looks like the same issue of apps not being styled is happening. I'm not sure why, but if you can investigate that'd be super helpful. Otherwise I may have time next week to take a look. Once you have it published to your local registry, run this:
Let it finish, and then run |
When replacing the 'raw-loader' rule in the `getStylesPartial` function, check for the absolute path of 'raw-loader' rather than just the name.
Awesome. Just waiting for the CI to finish. |
* fix(core): resolve webpack loaders with `require.resolve()` 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 * fix(core): resolve absolute 'raw-loader' path When replacing the 'raw-loader' rule in the `getStylesPartial` function, check for the absolute path of 'raw-loader' rather than just the name.
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. |
Same as #3341
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.