Skip to content
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

Bug: linked package incorrectly uses node_modules instead of pnpapi #288

Closed
noahnu opened this issue Mar 31, 2021 · 0 comments · Fixed by #289
Closed

Bug: linked package incorrectly uses node_modules instead of pnpapi #288

noahnu opened this issue Mar 31, 2021 · 0 comments · Fixed by #289

Comments

@noahnu
Copy link
Contributor

noahnu commented Mar 31, 2021

enhanced-resolve is incorrectly escaping from the pnpapi context.

Context

Encountered this via webpack initially using Yarn 2's pnpapi.

With Webpack:

Repro project: https://github.com/noahnu/yarn-repro-linking-non-pnp, after cloning the project, cd yarn2-pnp-project && yarn build then search for yarn1-nm-project/node_modules/react-dom/index.js in the dist/bundle.js file. It's from node_modules.

And without webpack, purely using enhanced-resolve:

Repro:

Clone: https://github.com/noahnu/yarn-repro-linking-non-pnp/tree/pure_enhance

and run the bash script: ./run-repro.sh.

const assert = require('assert')
const resolve = require('enhanced-resolve')

assert.equal(
  resolve.sync(require.resolve('my-linked-package'), 'react-dom'),
  require.resolve('react-dom', {
    paths: [require.resolve('my-linked-package')],
  })
)

Expectation

I expect the assertion to pass, as both should be going through pnp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant