Skip to content

Commit

Permalink
fix(webpack-loader): override module if cjs/none
Browse files Browse the repository at this point in the history
so it doesn't break on projects with node16 mode on ts@5.2
  • Loading branch information
AviVahl committed Aug 24, 2023
1 parent 9e65e45 commit cbc62e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/webpack-loader/src/typescript-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ export const typescriptLoader: webpack.LoaderDefinition = function (source) {

// webpack supports, validates, and tree-shakes es modules.
// apply it before overrides, so user can customize it
compilerOptions.module = ts.ModuleKind.ESNext;
if (
compilerOptions.module === ts.ModuleKind.CommonJS ||
compilerOptions.module === ts.ModuleKind.None ||
compilerOptions.module === undefined
) {
compilerOptions.module = ts.ModuleKind.ESNext;
}

if (overrideOptions) {
const { options, errors } = ts.convertCompilerOptionsFromJson(overrideOptions, rootContext);
Expand Down

0 comments on commit cbc62e2

Please sign in to comment.