Skip to content

Commit

Permalink
fix(node): danger#1180 - Adjust tsconfig compiler options
Browse files Browse the repository at this point in the history
Accidentally applied `es6` when compilerOptions.module was not defined.
  • Loading branch information
matthewh committed Jun 19, 2024
1 parent c54a1fd commit c175fef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
## Main

<!-- Your comment below this -->

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

## 12.3.2
Expand Down
12 changes: 8 additions & 4 deletions source/runner/runners/utils/transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ const sanitizeTSConfig = (config: any, esm: boolean = false) => {
//
// @see https://github.com/apollographql/react-apollo/pull/1402#issuecomment-351810274
//
if (!esm && safeConfig.compilerOptions.module) {
safeConfig.compilerOptions.module = "commonjs"
} else {
safeConfig.compilerOptions.module = "es6"
if (safeConfig.compilerOptions.module) {
if (!esm) {
// .ts files should fall back to commonjs
safeConfig.compilerOptions.module = "commonjs"
} else {
// .mts files must use `import`/`export` syntax
safeConfig.compilerOptions.module = "es6"
}
}

return safeConfig
Expand Down

0 comments on commit c175fef

Please sign in to comment.