Skip to content

Commit d91527b

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

1 file changed

Lines changed: 1 addition & 57 deletions

File tree

  • packages/angular/build/src/builders/library/tests/behavior

‎packages/angular/build/src/builders/library/tests/behavior/build_spec.ts‎

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
8989
expect(logs.some((l) => l.level === 'warn')).toBeFalse();
9090
});
9191

92-
it('should preserve JSDoc comments in .d.ts and legal and annotation comments in .mjs bundles', async () => {
92+
it('should preserve JSDoc comments in .d.ts and annotation comments in .mjs bundles', async () => {
9393
await harness.writeFile(
9494
'projects/lib/src/public-api.ts',
9595
`
96-
/*! @license Custom license header */
9796
function identity<T>(x: T): T { return x; }
9897
/** Public API JSDoc comment */
9998
export const VALUE = /* @__PURE__ */ identity('test');
@@ -108,7 +107,6 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
108107
expect(result?.success).toBeTrue();
109108

110109
const fesmContent = harness.readFile('dist/lib/fesm2022/lib.mjs');
111-
expect(fesmContent).toContain('/*! @license Custom license header */');
112110
expect(fesmContent).toContain('@__PURE__');
113111
expect(fesmContent).not.toContain('Public API JSDoc comment');
114112

@@ -117,60 +115,6 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
117115
expect(dtsContent).not.toContain('@__PURE__');
118116
});
119117

120-
it('should tree-shake unexported internal types from .d.ts when using export *', async () => {
121-
await harness.writeFiles({
122-
'projects/lib/src/lib/internal.ts': `
123-
export interface PublicExportedType {
124-
id: string;
125-
}
126-
interface UnexportedInternalType {
127-
secret: number;
128-
}
129-
`,
130-
'projects/lib/src/public-api.ts': `
131-
export * from './lib/internal';
132-
export * from './lib/lib.service';
133-
export * from './lib/lib.component';
134-
`,
135-
'projects/lib/secondary/src/lib/sec-internal.ts': `
136-
export interface SecondaryPublicType {
137-
flag: boolean;
138-
}
139-
interface SecondaryInternalType {
140-
hidden: string;
141-
}
142-
`,
143-
'projects/lib/secondary/src/public-api.ts': `
144-
export * from './lib/sec-internal';
145-
`,
146-
});
147-
148-
await harness.modifyFile('projects/lib/package.json', (content) => {
149-
const pkg = JSON.parse(content);
150-
pkg.exports = {
151-
'.': './src/public-api.ts',
152-
'./secondary': './secondary/src/public-api.ts',
153-
};
154-
155-
return JSON.stringify(pkg, null, 2);
156-
});
157-
158-
harness.useTarget('build', {
159-
...BASE_OPTIONS,
160-
});
161-
162-
const { result } = await harness.executeOnce();
163-
expect(result?.success).toBeTrue();
164-
165-
const primaryDts = harness.readFile('dist/lib/types/lib.d.ts');
166-
expect(primaryDts).toContain('PublicExportedType');
167-
expect(primaryDts).not.toContain('UnexportedInternalType');
168-
169-
const secondaryDts = harness.readFile('dist/lib/types/lib-secondary.d.ts');
170-
expect(secondaryDts).toContain('SecondaryPublicType');
171-
expect(secondaryDts).not.toContain('SecondaryInternalType');
172-
});
173-
174118
it('should automatically add tslib to dependencies when output chunks import tslib', async () => {
175119
await harness.writeFile(
176120
'projects/lib/src/public-api.ts',

0 commit comments

Comments
 (0)