Skip to content

Commit 71e571b

Browse files
committed
Revert "fix(@angular-devkit/build-angular): preemptively remove AOT metadata in esbuild builder"
These changes are causing imported types to be incorrectly retained. This reverts commit c462d9c. (cherry picked from commit b4aa4ab)
1 parent 1419fff commit 71e571b

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/tests/behavior/stylesheet_autoprefixer_spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => {
106106

107107
harness
108108
.expectFile('dist/main.js')
109-
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
109+
.content.toMatch(
110+
/section\s*{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/,
111+
);
110112
harness
111113
.expectFile('dist/main.js')
112-
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
114+
.content.toMatch(/div\s*{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
113115
});
114116

115117
it(`should not add prefixes if not required by browsers in external component styles [${ext}]`, async () => {
@@ -135,8 +137,10 @@ describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => {
135137
const { result } = await harness.executeOnce();
136138
expect(result?.success).toBeTrue();
137139

138-
harness.expectFile('dist/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
139-
harness.expectFile('dist/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
140+
harness
141+
.expectFile('dist/main.js')
142+
.content.toMatch(/section\s*{\\n\s*hyphens:\s*none;\\n\s*}/);
143+
harness.expectFile('dist/main.js').content.toMatch(/div\s*{\\n\s*hyphens:\s*none;\\n\s*}/);
140144
});
141145
}
142146

@@ -165,8 +169,7 @@ describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => {
165169

166170
harness
167171
.expectFile('dist/main.js')
168-
// div[_ngcontent-%COMP%] {\n -webkit-hyphens: none;\n hyphens: none;\n}\n
169-
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
172+
.content.toMatch(/div\s*{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
170173
});
171174

172175
it('should not add prefixes if not required by browsers in inline component styles', async () => {
@@ -190,7 +193,7 @@ describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => {
190193
const { result } = await harness.executeOnce();
191194
expect(result?.success).toBeTrue();
192195

193-
harness.expectFile('dist/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
196+
harness.expectFile('dist/main.js').content.toMatch(/div\s*{\\n\s*hyphens:\s*none;\\n\s*}/);
194197
});
195198
});
196199
});

packages/angular_devkit/build_angular/src/tools/esbuild/angular/aot-compilation.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import {
1919

2020
// Temporary deep import for transformer support
2121
// TODO: Move these to a private exports location or move the implementation into this package.
22-
const {
23-
mergeTransformers,
24-
createAotTransformers,
25-
} = require('@ngtools/webpack/src/ivy/transformation');
22+
const { mergeTransformers, replaceBootstrap } = require('@ngtools/webpack/src/ivy/transformation');
2623

2724
class AngularCompilationState {
2825
constructor(
@@ -194,11 +191,9 @@ export class AotCompilation extends AngularCompilation {
194191
angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
195192
emittedFiles.set(sourceFile, { filename: sourceFile.fileName, contents });
196193
};
197-
const transformers = mergeTransformers(
198-
angularCompiler.prepareEmit().transformers,
199-
// The default behavior is to replace JIT bootstraping and remove AOT metadata calls
200-
createAotTransformers(typeScriptProgram, {}),
201-
);
194+
const transformers = mergeTransformers(angularCompiler.prepareEmit().transformers, {
195+
before: [replaceBootstrap(() => typeScriptProgram.getProgram().getTypeChecker())],
196+
});
202197

203198
// TypeScript will loop until there are no more affected files in the program
204199
while (

0 commit comments

Comments
 (0)