-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): Include "node" condition during CJS re-export analysis (#2…
…5785) Fixes #25777. We were missing the "node" condition, so we were resolving to the wrong conditional export, causing our analysis to be incorrect.
- Loading branch information
1 parent
4b02210
commit 9be8dce
Showing
13 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/registry/npm/@denotest/conditional-exports-node/1.0.0/bad.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
hello: "bad" | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/registry/npm/@denotest/conditional-exports-node/1.0.0/good.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
hello: "from node" | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/registry/npm/@denotest/conditional-exports-node/1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
hello: "default export" | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/registry/npm/@denotest/conditional-exports-node/1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "@denotest/conditional-exports", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"node": "./good.cjs", | ||
"require": "./bad.js", | ||
"default": "./index.js" | ||
}, | ||
"./*": "./*" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/registry/npm/@denotest/mjs-reexport-cjs/1.0.0/dist/package.cjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
const pkg = require("@denotest/conditional-exports-node"); | ||
|
||
Object.keys(pkg).forEach(function (k) { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = pkg[k]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/package.cjs.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./index.js"; |
11 changes: 11 additions & 0 deletions
11
tests/registry/npm/@denotest/mjs-reexport-cjs/1.0.0/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@denotest/mjs-reexport-cjs", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"@denotest/conditional-exports-node": "*" | ||
}, | ||
"exports": { | ||
"node": "./index.mjs", | ||
"default": "./index.js" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/specs/node/cjs_reexport_node_condition/__test__.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"tempDir": true, | ||
"steps": [ | ||
{ | ||
"args": "install", | ||
"output": "[WILDCARD]" | ||
}, | ||
{ | ||
"args": "run -A ./main.ts", | ||
"output": "from node\n" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"nodeModulesDir": "manual" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { hello } from "@denotest/mjs-reexport-cjs"; | ||
|
||
console.log(hello); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"@denotest/mjs-reexport-cjs": "*" | ||
} | ||
} |