Skip to content

Commit c8b46cf

Browse files
Fix TS failing if module is set to CommonJS (#638)
1 parent a71918b commit c8b46cf

6 files changed

Lines changed: 79 additions & 0 deletions

File tree

β€Žsrc/index.jsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ function createConfig(options, entry, format, writeMeta) {
583583
tsconfig: options.tsconfig,
584584
tsconfigOverride: {
585585
compilerOptions: {
586+
module: 'ESNext',
586587
target: 'esnext',
587588
},
588589
},

β€Žtest/__snapshots__/index.test.js.snapβ€Ž

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,3 +2514,65 @@ exports[`fixtures build ts-mixed-exports with microbundle 7`] = `
25142514
//# sourceMappingURL=ts-mixed-exports.umd.js.map
25152515
"
25162516
`;
2517+
2518+
exports[`fixtures build ts-module with microbundle 1`] = `
2519+
"Used script: microbundle
2520+
2521+
Directory tree:
2522+
2523+
ts-module
2524+
dist
2525+
foo.d.ts
2526+
index.d.ts
2527+
ts-module.esm.js
2528+
ts-module.esm.js.map
2529+
ts-module.js
2530+
ts-module.js.map
2531+
ts-module.umd.js
2532+
ts-module.umd.js.map
2533+
node_modules
2534+
package.json
2535+
src
2536+
foo.ts
2537+
index.ts
2538+
tsconfig.json
2539+
2540+
2541+
Build \\"tsModule\\" to dist:
2542+
59 B: ts-module.js.gz
2543+
42 B: ts-module.js.br
2544+
65 B: ts-module.esm.js.gz
2545+
49 B: ts-module.esm.js.br
2546+
168 B: ts-module.umd.js.gz
2547+
128 B: ts-module.umd.js.br"
2548+
`;
2549+
2550+
exports[`fixtures build ts-module with microbundle 2`] = `8`;
2551+
2552+
exports[`fixtures build ts-module with microbundle 3`] = `
2553+
"export declare function foo(): string;
2554+
"
2555+
`;
2556+
2557+
exports[`fixtures build ts-module with microbundle 4`] = `
2558+
"export declare function foobar(): string;
2559+
"
2560+
`;
2561+
2562+
exports[`fixtures build ts-module with microbundle 5`] = `
2563+
"function o(){return\\"foobar\\"}export{o as foobar};
2564+
//# sourceMappingURL=ts-module.esm.js.map
2565+
"
2566+
`;
2567+
2568+
exports[`fixtures build ts-module with microbundle 6`] = `
2569+
"exports.foobar=function(){return\\"foobar\\"};
2570+
//# sourceMappingURL=ts-module.js.map
2571+
"
2572+
`;
2573+
2574+
exports[`fixtures build ts-module with microbundle 7`] = `
2575+
"!function(e,o){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?o(exports):\\"function\\"==typeof define&&define.amd?define([\\"exports\\"],o):o((e=e||self).tsModule={})}(this,function(e){e.foobar=function(){return\\"foobar\\"}});
2576+
//# sourceMappingURL=ts-module.umd.js.map
2577+
"
2578+
`;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "ts-module"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function foo() {
2+
return 'foo';
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { foo } from './foo';
2+
3+
export function foobar() {
4+
return foo() + 'bar';
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"module": "CommonJS"
4+
}
5+
}

0 commit comments

Comments
Β (0)