Skip to content

Commit f4349c5

Browse files
alan-agius4filipesilva
authored andcommitted
refactor(@ngtools/webpack): remove ESM workarounds
1 parent 556a3f5 commit f4349c5

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

packages/ngtools/webpack/src/ivy/plugin.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -734,24 +734,7 @@ export class AngularWebpackPlugin {
734734
// this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
735735
// Once TypeScript provides support for keeping the dynamic import this workaround can
736736
// be dropped.
737-
const compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();
738-
let compilerNgccModule;
739-
try {
740-
compilerNgccModule = await new Function(`return import('@angular/compiler-cli/ngcc');`)();
741-
} catch {
742-
// If the `exports` field entry is not present then try the file directly.
743-
// TODO_ESM: This try/catch can be removed once the `exports` field is present in `@angular/compiler-cli`
744-
compilerNgccModule = await new Function(
745-
`return import('@angular/compiler-cli/ngcc/index.js');`,
746-
)();
747-
}
748-
// If it is not ESM then the functions needed will be stored in the `default` property.
749-
// TODO_ESM: This conditional can be removed when `@angular/compiler-cli` is ESM only.
750-
this.compilerCliModule = compilerCliModule.readConfiguration
751-
? compilerCliModule
752-
: compilerCliModule.default;
753-
this.compilerNgccModule = compilerNgccModule.process
754-
? compilerNgccModule
755-
: compilerNgccModule.default;
737+
this.compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();
738+
this.compilerNgccModule = await new Function(`return import('@angular/compiler-cli/ngcc');`)();
756739
}
757740
}

packages/ngtools/webpack/src/ngcc_processor.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ export class NgccProcessor {
120120
const timeLabel = 'NgccProcessor.process';
121121
time(timeLabel);
122122

123-
// Temporary workaround during transition to ESM-only @angular/compiler-cli
124-
// TODO_ESM: This workaround should be removed prior to the final release of v13
125-
// and replaced with only `this.compilerNgcc.ngccMainFilePath`.
126-
const ngccExecutablePath =
127-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
128-
(this.compilerNgcc as any).ngccMainFilePath ??
129-
require.resolve('@angular/compiler-cli/ngcc/main-ngcc.js');
130-
131123
// We spawn instead of using the API because:
132124
// - NGCC Async uses clustering which is problematic when used via the API which means
133125
// that we cannot setup multiple cluster masters with different options.
@@ -136,7 +128,7 @@ export class NgccProcessor {
136128
const { status, error } = spawnSync(
137129
process.execPath,
138130
[
139-
ngccExecutablePath,
131+
this.compilerNgcc.ngccMainFilePath,
140132
'--source' /** basePath */,
141133
this._nodeModulesDirectory,
142134
'--properties' /** propertiesToConsider */,

0 commit comments

Comments
 (0)