Skip to content

Commit e4bd9c2

Browse files
committed
Transpile module syntax into CJS in dev
`src/index.ts` is designed to be run as an executable, and we want to be able to run this in tests via `ts-node`. However, `ts-node` does not run a TypeScript file when `tsconfig.json` specifies anything other than "CommonJS" for the `module` setting ([unless you configure `ts-node` and/or Node specially][1]). This commit instructs TypeScript to rewrite imports using the CommonJS syntax only in the default TypeScript config (ES6 is still used when `yarn build` is run). [1]: https://typestrong.org/ts-node/docs/imports/
1 parent de19413 commit e4bd9c2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tsconfig.build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"declaration": true,
55
"inlineSources": true,
6+
"module": "ES6",
67
"noEmit": false,
78
"outDir": "lib",
89
"rootDir": "src",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"esModuleInterop": true,
44
"lib": ["ES2020"],
5-
"module": "ES6",
5+
"module": "CommonJS",
66
"moduleResolution": "node",
77
"noEmit": true,
88
"strict": true,

0 commit comments

Comments
 (0)