Skip to content

Commit

Permalink
fix: set allowSyntheticDefaultImports properly
Browse files Browse the repository at this point in the history
Fixes #4156
  • Loading branch information
ahnpnl committed Jul 10, 2024
1 parent 083cd89 commit ff4b302
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`TsCompiler getCompiledOutput isolatedModules false should compile codes

exports[`TsCompiler getCompiledOutput isolatedModules false should compile codes with useESM {"babelConfig": false, "supportsStaticESM": true, "useESM": true} 1`] = `
{
"allowSyntheticDefaultImports": true,
"allowSyntheticDefaultImports": undefined,
"esModuleInterop": true,
"module": 1,
}
Expand Down Expand Up @@ -50,7 +50,7 @@ exports[`TsCompiler getCompiledOutput isolatedModules true should transpile code

exports[`TsCompiler getCompiledOutput isolatedModules true should transpile code with config {"babelConfig": false, "supportsStaticESM": true, "useESM": true} 1`] = `
{
"allowSyntheticDefaultImports": true,
"allowSyntheticDefaultImports": undefined,
"esModuleInterop": true,
"module": 1,
}
Expand Down
1 change: 0 additions & 1 deletion src/legacy/compiler/ts-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export class TsCompiler implements TsCompilerInstance {
...compilerOptions,
module: moduleKind,
esModuleInterop: esModuleInterop ?? false,
allowSyntheticDefaultImports: esModuleInterop ?? compilerOptions.allowSyntheticDefaultImports,
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/legacy/config/config-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ describe('parsedTsConfig', () => {

expect(cs.parsedTsConfig.options).toMatchObject({
module: ts.ModuleKind.AMD,
allowSyntheticDefaultImports: true,
esModuleInterop: false,
})
expect(target.lines.warn.join()).toEqual(expect.stringContaining(Errors.ConfigNoModuleInterop))
Expand Down Expand Up @@ -839,7 +838,6 @@ describe('_resolveTsConfig', () => {
expect(readConfig.mock.calls[0][0]).toBe(tscfgPathStub)
expect(parseConfig.mock.calls[0][2]).toBe('/root')
expect(parseConfig.mock.calls[0][4]).toBe(tscfgPathStub)
expect(conf.options.allowSyntheticDefaultImports).toEqual(true)
expect(conf.errors).toMatchSnapshot()
})

Expand Down
5 changes: 0 additions & 5 deletions src/legacy/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,6 @@ export class ConfigSet {
start: undefined,
length: undefined,
})
// at least enable synthetic default imports (except if it's set in the input config)
/* istanbul ignore next (already covered in unit test) */
if (!('allowSyntheticDefaultImports' in finalOptions)) {
finalOptions.allowSyntheticDefaultImports = true
}
}
// Make sure when allowJs is enabled, outDir is required to have when using allowJs: true
if (finalOptions.allowJs && !finalOptions.outDir) {
Expand Down

0 comments on commit ff4b302

Please sign in to comment.