Skip to content

Commit de1df2c

Browse files
committed
fixup! perf(@angular/build): optimize library dts bundling and enable dts tree-shaking
1 parent 22c75d9 commit de1df2c

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

‎packages/angular/build/src/builders/library/pipeline/bundler_spec.ts‎

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,31 @@ describe('bundleEntryPoints', () => {
100100
createOptions(entryPoints),
101101
);
102102

103-
const primaryDtsFile = output.filesToEmit.find((f) => f.path === 'types/my-lib.d.ts');
104-
expect(primaryDtsFile).toBeDefined();
105-
expect(String(primaryDtsFile?.contents)).toContain('PublicA');
106-
expect(String(primaryDtsFile?.contents)).not.toContain('UnexportedInternalA');
103+
expect(output.filesToEmit).toContain(
104+
jasmine.objectContaining({
105+
path: 'types/my-lib.d.ts',
106+
contents: jasmine.stringContaining('PublicA'),
107+
}),
108+
);
109+
expect(output.filesToEmit).not.toContain(
110+
jasmine.objectContaining({
111+
path: 'types/my-lib.d.ts',
112+
contents: jasmine.stringContaining('UnexportedInternalA'),
113+
}),
114+
);
107115

108-
const secondaryDtsFile = output.filesToEmit.find(
109-
(f) => f.path === 'types/my-lib-secondary.d.ts',
116+
expect(output.filesToEmit).toContain(
117+
jasmine.objectContaining({
118+
path: 'types/my-lib-secondary.d.ts',
119+
contents: jasmine.stringContaining('PublicB'),
120+
}),
121+
);
122+
expect(output.filesToEmit).not.toContain(
123+
jasmine.objectContaining({
124+
path: 'types/my-lib-secondary.d.ts',
125+
contents: jasmine.stringContaining('UnexportedInternalB'),
126+
}),
110127
);
111-
expect(secondaryDtsFile).toBeDefined();
112-
expect(String(secondaryDtsFile?.contents)).toContain('PublicB');
113-
expect(String(secondaryDtsFile?.contents)).not.toContain('UnexportedInternalB');
114128
});
115129

116130
it('should preserve legal comments in emitted FESM2022 .mjs bundles', async () => {
@@ -141,8 +155,11 @@ describe('bundleEntryPoints', () => {
141155
createOptions(entryPoints),
142156
);
143157

144-
const mjsFile = output.filesToEmit.find((f) => f.path === 'fesm2022/my-lib.mjs');
145-
expect(mjsFile).toBeDefined();
146-
expect(String(mjsFile?.contents)).toContain('/*! @license MIT Custom Header */');
158+
expect(output.filesToEmit).toContain(
159+
jasmine.objectContaining({
160+
path: 'fesm2022/my-lib.mjs',
161+
contents: jasmine.stringContaining('/*! @license MIT Custom Header */'),
162+
}),
163+
);
147164
});
148165
});

0 commit comments

Comments
 (0)