diff options
author | 2023-07-31 17:31:16 -0700 | |
---|---|---|
committer | 2023-07-31 17:31:16 -0700 | |
commit | 47a0479bbf10a316c6e41c69f4ae14b978afa989 (patch) | |
tree | bf0b5253a0e97f1a9fe3a39f1c72fdf72f90994e /test | |
parent | 8589ba2f1712d68199fbef14f5a4ba9005df3065 (diff) | |
download | bun-dylan/fix-module-field-in-exports.tar.gz bun-dylan/fix-module-field-in-exports.tar.zst bun-dylan/fix-module-field-in-exports.zip |
prefer `module` in `exports`dylan/fix-module-field-in-exports
Diffstat (limited to 'test')
-rw-r--r-- | test/bundler/esbuild/default.test.ts | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/bundler/esbuild/default.test.ts b/test/bundler/esbuild/default.test.ts index ac820848a..0d17312ed 100644 --- a/test/bundler/esbuild/default.test.ts +++ b/test/bundler/esbuild/default.test.ts @@ -6836,4 +6836,77 @@ describe("bundler", () => { stdout: "5 9 2 7", }, }); + const fooNodeModule = { + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "exports": { + ".": { + "module": "./import.js", + "require": "./require.js", + "import": "./import.js" + } + } + } + `, + "/node_modules/foo/import.js": ` + export const foo = 'import'; + `, + "/node_modules/foo/require.js": ` + export const foo = 'require'; + `, + }; + itBundled("default/ExportFieldWithModuleRuntimeImport", { + files: { + "/entry.js": ` + import { foo } from 'foo'; + console.log(foo); + `, + ...fooNodeModule, + }, + bundling: false, + run: { + stdout: "import", + }, + }); + itBundled("default/ExportsFieldWithModuleBundleImport", { + files: { + "/entry.js": ` + import { foo } from 'foo'; + console.log(foo); + `, + ...fooNodeModule, + }, + bundling: true, + run: { + stdout: "import", + }, + }); + itBundled("default/ExportsFieldWithModuleRuntimeRequire", { + files: { + "/entry.js": ` + const { foo } = require('foo'); + console.log(foo); + `, + ...fooNodeModule, + }, + bundling: false, + run: { + stdout: "require", + }, + }); + itBundled("default/ExportsFieldWithModuleBundleRequire", { + files: { + "/entry.js": ` + const { foo } = require('foo'); + console.log(foo); + `, + ...fooNodeModule, + }, + bundling: true, + run: { + stdout: "import", + }, + }); }); |