Skip to content

Commit f725706

Browse files
authored
Merge pull request #1456 from matthewh/danger-js-1180-fix_compiler_option
fix(node): #1180 - Adjust tsconfig compiler options
2 parents c54a1fd + c175fef commit f725706

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
## Main
1616

1717
<!-- Your comment below this -->
18-
18+
- [#1180] Set module properly when tsconfig does not contain compilerOptions.module [@matthewh]
1919
<!-- Your comment above this -->
2020

2121
## 12.3.2

Diff for: source/runner/runners/utils/transpiler.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,14 @@ const sanitizeTSConfig = (config: any, esm: boolean = false) => {
149149
//
150150
// @see https://github.com/apollographql/react-apollo/pull/1402#issuecomment-351810274
151151
//
152-
if (!esm && safeConfig.compilerOptions.module) {
153-
safeConfig.compilerOptions.module = "commonjs"
154-
} else {
155-
safeConfig.compilerOptions.module = "es6"
152+
if (safeConfig.compilerOptions.module) {
153+
if (!esm) {
154+
// .ts files should fall back to commonjs
155+
safeConfig.compilerOptions.module = "commonjs"
156+
} else {
157+
// .mts files must use `import`/`export` syntax
158+
safeConfig.compilerOptions.module = "es6"
159+
}
156160
}
157161

158162
return safeConfig

0 commit comments

Comments
 (0)