Skip to content

Commit

Permalink
Revert "fix(@angular-devkit/build-angular): preemptively remove AOT m…
Browse files Browse the repository at this point in the history
…etadata in esbuild builder"

These changes are causing imported types to be incorrectly retained.

This reverts commit c462d9c.

(cherry picked from commit b4aa4ab)
  • Loading branch information
clydin committed Jun 16, 2023
1 parent 1419fff commit 71e571b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => {

harness
.expectFile('dist/main.js')
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
.content.toMatch(
/section\s*{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/,
);
harness
.expectFile('dist/main.js')
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
.content.toMatch(/div\s*{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
});

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

harness.expectFile('dist/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
harness.expectFile('dist/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
harness
.expectFile('dist/main.js')
.content.toMatch(/section\s*{\\n\s*hyphens:\s*none;\\n\s*}/);
harness.expectFile('dist/main.js').content.toMatch(/div\s*{\\n\s*hyphens:\s*none;\\n\s*}/);
});
}

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

harness
.expectFile('dist/main.js')
// div[_ngcontent-%COMP%] {\n -webkit-hyphens: none;\n hyphens: none;\n}\n
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
.content.toMatch(/div\s*{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
});

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

harness.expectFile('dist/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
harness.expectFile('dist/main.js').content.toMatch(/div\s*{\\n\s*hyphens:\s*none;\\n\s*}/);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import {

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

class AngularCompilationState {
constructor(
Expand Down Expand Up @@ -194,11 +191,9 @@ export class AotCompilation extends AngularCompilation {
angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
emittedFiles.set(sourceFile, { filename: sourceFile.fileName, contents });
};
const transformers = mergeTransformers(
angularCompiler.prepareEmit().transformers,
// The default behavior is to replace JIT bootstraping and remove AOT metadata calls
createAotTransformers(typeScriptProgram, {}),
);
const transformers = mergeTransformers(angularCompiler.prepareEmit().transformers, {
before: [replaceBootstrap(() => typeScriptProgram.getProgram().getTypeChecker())],
});

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

0 comments on commit 71e571b

Please sign in to comment.