-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Open
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.
Description
- Version: v14.16.0
- Platform: Darwin DEV135MAC0211.fritz.box 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64
- Subsystem:
What steps will reproduce the bug?
When importing a package with conditional exports declared in the package.json, then node doesn't respect alternative path exports:
"exports": {
"./*": {
"require": [
"./dist/cjs/*/index.js",
"./dist/cjs/*.js"
]
}
}
Node only tries to resolve the first one and fails immediately if the first path to a module doesn't exist. I don't know if this is the intended behaviour, but in the Webpack guide it is explicitly mentioned as a feature (https://webpack.js.org/guides/package-exports/#alternatives).
What is the expected behavior?
Node tries to resolve an import against each entry in the conditional exports array and returns the first successful loaded module.
What do you see instead?
Node only resolves the first entry of the conditional exports alternatives.
radimbuchtela, privatenumber, SalvatorePreviti, chbdetta, acidoxee and 3 more
Metadata
Metadata
Assignees
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.