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?]: PnP fails to resolve dynamic require from CJS #3687
Comments
This is fixed by #3667, you can verify by running yarn set version from sources --branch 3667 |
Having done |
Did you run |
Ah nope, that fixed it, thanks! So I'm guessing the newer Yarn modifies the PnP map to make it work correctly? |
Ahahaha, that’s why I ended up filing #4045! Any reason |
import 에러로 인해 변경함 - 링크 참고 yarnpkg/berry#3687
Self-service
Describe the bug
Attempting to use
import()
from a CJS file fails under PnP despite Node being loaded with--experimental-loader=.../.pnp.loader.mjs
. This appears to be a gap in the recent support added for the experimental ESM loader as the issue is not present when the script is loaded as ESM.To reproduce
https://github.com/kherock/pnp-exports-map-import-bug
You can reproduce the error by running the following after checking out:
The failure disappears when loading the script as .mjs:
The error is not present with
nodeLinker: node-modules
set in.yarnrc.yml
.Environment
System: OS: macOS 11.5.2 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Binaries: Node: 16.9.1 - /private/var/folders/9f/kl_c86q5651fqmhmzf63jb0x5t_d9j/T/xfs-7d04f2cf/node Yarn: 3.1.0 - /private/var/folders/9f/kl_c86q5651fqmhmzf63jb0x5t_d9j/T/xfs-7d04f2cf/yarn npm: 7.21.1 - ~/.volta/tools/image/node/16.9.1/bin/npm
Additional context
I'm running Next.js 12 which generates server-side code with imports in the form of dynamic
import()
calls. The package I'm trying to import is@react-hook/passive-layout-effect
which has a package.json in a format similar to the reproduction linked above. NextJS doesn't support running under a project with{ "type": "module" }
yet, so the workaround of loading the script as ESM isn't an option.The text was updated successfully, but these errors were encountered: