diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2024-05-10 09:55:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-10 09:55:20 -0400 |
| commit | a9708037c9e333104bfdfe0ccadbc40395809c39 (patch) | |
| tree | e3dd8e5fdb34deced4ccdee152adada90cb10494 /tests | |
| parent | 6066e069d141d7c0c19e088011fdf3c06782d12c (diff) | |
fix(node): better cjs re-export handling (#23760)
Closes #23458
Diffstat (limited to 'tests')
8 files changed, 46 insertions, 0 deletions
diff --git a/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/api.js b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/api.js new file mode 100644 index 000000000..831428ef7 --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/api.js @@ -0,0 +1 @@ +module.exports.main = 1; diff --git a/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/index.js b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/index.js new file mode 100644 index 000000000..9e9b27a0a --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/index.js @@ -0,0 +1,14 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +// specifier here is the same as in sub/index.js +__exportStar(require("./api"), exports); +__exportStar(require("./sub"), exports);
\ No newline at end of file diff --git a/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/package.json b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/package.json new file mode 100644 index 000000000..0264413a3 --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/package.json @@ -0,0 +1,4 @@ +{ + "name": "@denotest/cjs-reexport-same-specifier-in-sub-folder", + "version": "1.0.0" +}
\ No newline at end of file diff --git a/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/sub/api.js b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/sub/api.js new file mode 100644 index 000000000..bba5ee087 --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/sub/api.js @@ -0,0 +1 @@ +module.exports.sub = 2; diff --git a/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/sub/index.js b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/sub/index.js new file mode 100644 index 000000000..48f78249e --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0/sub/index.js @@ -0,0 +1,12 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +__exportStar(require("./api"), exports);
\ No newline at end of file diff --git a/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/__test__.jsonc b/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/__test__.jsonc new file mode 100644 index 000000000..5517e693d --- /dev/null +++ b/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run main.ts", + "output": "main.out" +} diff --git a/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/main.out b/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/main.out new file mode 100644 index 000000000..321d995b8 --- /dev/null +++ b/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/main.out @@ -0,0 +1,7 @@ +Download http://localhost:4260/@denotest/cjs-reexport-same-specifier-in-sub-folder +Download http://localhost:4260/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0.tgz +[Module: null prototype] { + default: { main: [Getter], sub: [Getter] }, + main: 1, + sub: 2 +} diff --git a/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/main.ts b/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/main.ts new file mode 100644 index 000000000..fd0bf7eba --- /dev/null +++ b/tests/specs/node/cjs_reexport_same_specifier_in_sub_folder/main.ts @@ -0,0 +1,3 @@ +import * as module from "npm:@denotest/cjs-reexport-same-specifier-in-sub-folder"; + +console.log(module); |
