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?]: Dynamic ES module import in .cjs file not working with PnP #4034

Closed
1 task
tavoyne opened this issue Jan 29, 2022 · 2 comments
Closed
1 task

[Bug?]: Dynamic ES module import in .cjs file not working with PnP #4034

tavoyne opened this issue Jan 29, 2022 · 2 comments
Labels
bug Something isn't working waiting for feedback Will autoclose in a while unless more data are provided

Comments

@tavoyne
Copy link
Contributor

tavoyne commented Jan 29, 2022

Self-service

  • I'd be willing to implement a fix

Describe the bug

Note: this looks similar to #3671 and #3687 but wasn't fixed by #3667.

I'm getting the following error when using the @mdx-js/loader@2.0.0-rc.2 Webpack loader:

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/blackjelly/code/mdx-pb/.yarn/__virtual__/@mdx-js-loader-virtual-079d9df3b5/0/cache/@mdx-js-loader-npm-2.0.0-rc.2-eb4487e27d-5637b8d92c.zip/node_modules/@mdx-js/loader/lib/index.js' imported from /Users/blackjelly/code/mdx-pb/.yarn/__virtual__/@mdx-js-loader-virtual-079d9df3b5/0/cache/@mdx-js-loader-npm-2.0.0-rc.2-eb4487e27d-5637b8d92c.zip/node_modules/@mdx-js/loader/index.cjs

But the module does exist.

If I switch to a node-modules linker, then it compiles successfully.

I believe it has to do with the dynamic import of an ES module in the package's entry point.

To reproduce

Clone this repository (it's a minimal example).

Run yarn webpack.

Environment

System:
  OS: macOS 12.1
  CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
  Node: 16.13.2 - /private/var/folders/_m/hj6rftx17hl0zb66kk7y978m0000gp/T/xfs-2ff2f68f/node
  Yarn: 3.2.0-rc.12 - /private/var/folders/_m/hj6rftx17hl0zb66kk7y978m0000gp/T/xfs-550fed4e/yarn
  npm: 8.3.2 - ~/.nvm/versions/node/v16.13.2/bin/npm

Additional context

No response

@tavoyne tavoyne added the bug Something isn't working label Jan 29, 2022
@merceyz merceyz added the waiting for feedback Will autoclose in a while unless more data are provided label Jan 29, 2022
@merceyz
Copy link
Member

merceyz commented Jan 29, 2022

Your reproduction works after running yarn in it

@tavoyne
Copy link
Contributor Author

tavoyne commented Jan 29, 2022

Woow, that's true. I apologise for the trouble. #3667 indeed fixed the thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for feedback Will autoclose in a while unless more data are provided
Projects
None yet
Development

No branches or pull requests

2 participants