Skip to content

Commit e68a190

Browse files
committed
fix(@schematics/angular): do not set esModuleInterop and moduleResolution when module is preserve
1 parent 61a027d commit e68a190

File tree

1 file changed

+8
-2
lines changed
  • packages/schematics/angular/migrations/use-application-builder

1 file changed

+8
-2
lines changed

packages/schematics/angular/migrations/use-application-builder/migration.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,16 @@ export default function (): Rule {
362362
),
363363
// Update main tsconfig
364364
updateJsonFile('tsconfig.json', (rootJson) => {
365-
rootJson.modify(['compilerOptions', 'esModuleInterop'], true);
365+
const module = rootJson.get(['compilerOptions', 'module']);
366+
const hasPreserveModule = typeof module === 'string' && module.toLowerCase() === 'preserve';
367+
368+
if (!hasPreserveModule) {
369+
rootJson.modify(['compilerOptions', 'esModuleInterop'], true);
370+
rootJson.modify(['compilerOptions', 'moduleResolution'], 'bundler');
371+
}
372+
366373
rootJson.modify(['compilerOptions', 'downlevelIteration'], undefined);
367374
rootJson.modify(['compilerOptions', 'allowSyntheticDefaultImports'], undefined);
368-
rootJson.modify(['compilerOptions', 'moduleResolution'], 'bundler');
369375
}),
370376
]);
371377
}

0 commit comments

Comments
 (0)