Skip to content

Commit

Permalink
Merge pull request #1456 from matthewh/danger-js-1180-fix_compiler_op…
Browse files Browse the repository at this point in the history
…tion

fix(node): #1180 - Adjust tsconfig compiler options
  • Loading branch information
orta authored Jun 20, 2024
2 parents c54a1fd + c175fef commit f725706
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 f725706

Please sign in to comment.