Skip to content

Commit 78c5a6a

Browse files
committed
fixup! fix(@angular/build): support incremental asset updates and output cleanup in library watch mode
1 parent 6d590c8 commit 78c5a6a

2 files changed

Lines changed: 25 additions & 32 deletions

File tree

‎packages/angular/build/src/builders/library/pipeline/build-action.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ export async function buildAction(actionContext: BuildActionContext): Promise<Bu
276276

277277
if (filesToDelete.size > 0) {
278278
await Promise.allSettled(
279-
[...filesToDelete].map((file) =>
280-
rm(path.join(options.outputPath, file), { force: true, maxRetries: 3 }),
281-
),
279+
[...filesToDelete].map((file) => rm(path.join(options.outputPath, file), { force: true })),
282280
);
283281
}
284282

‎packages/angular/build/src/builders/library/pipeline/entry-points_spec.ts‎

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { posix, resolve } from 'node:path';
10-
import { toPosixPath } from '../../../utils/path';
9+
import { join, resolve } from 'node:path';
1110
import type {
1211
BundleResult,
1312
NormalizedEntryPoint,
@@ -23,8 +22,8 @@ import {
2322
} from './entry-points';
2423

2524
describe('entry-points pipeline', () => {
26-
const projectRoot = toPosixPath(resolve('/workspace/projects/my-lib'));
27-
const packageJsonPath = posix.join(projectRoot, 'package.json');
25+
const projectRoot = resolve('/workspace/projects/my-lib');
26+
const packageJsonPath = join(projectRoot, 'package.json');
2827
const packageName = '@my-scope/my-lib';
2928

3029
describe('getEntryPointBundleName', () => {
@@ -77,7 +76,7 @@ describe('entry-points pipeline', () => {
7776
name: '.',
7877
displayName: packageName,
7978
bundleName: 'my-scope-my-lib',
80-
entryFilePath: posix.join(projectRoot, 'src/public-api.ts'),
79+
entryFilePath: join(projectRoot, 'src/public-api.ts'),
8180
isPrimary: true,
8281
});
8382
});
@@ -97,7 +96,7 @@ describe('entry-points pipeline', () => {
9796
name: '.',
9897
displayName: packageName,
9998
bundleName: 'my-scope-my-lib',
100-
entryFilePath: posix.join(projectRoot, 'src/public-api.ts'),
99+
entryFilePath: join(projectRoot, 'src/public-api.ts'),
101100
isPrimary: true,
102101
});
103102
});
@@ -117,7 +116,7 @@ describe('entry-points pipeline', () => {
117116
name: '.',
118117
displayName: packageName,
119118
bundleName: 'my-scope-my-lib',
120-
entryFilePath: posix.join(projectRoot, 'src/public-api.ts'),
119+
entryFilePath: join(projectRoot, 'src/public-api.ts'),
121120
isPrimary: true,
122121
});
123122
});
@@ -137,7 +136,7 @@ describe('entry-points pipeline', () => {
137136
name: '.',
138137
displayName: packageName,
139138
bundleName: 'my-scope-my-lib',
140-
entryFilePath: posix.join(projectRoot, 'src/public-api.ts'),
139+
entryFilePath: join(projectRoot, 'src/public-api.ts'),
141140
isPrimary: true,
142141
});
143142
});
@@ -156,11 +155,9 @@ describe('entry-points pipeline', () => {
156155
);
157156

158157
expect(entryPoints).toHaveSize(2);
159-
expect(entryPoints.get('.')?.entryFilePath).toBe(
160-
posix.join(projectRoot, 'src/public-api.ts'),
161-
);
158+
expect(entryPoints.get('.')?.entryFilePath).toBe(join(projectRoot, 'src/public-api.ts'));
162159
expect(entryPoints.get('testing')?.entryFilePath).toBe(
163-
posix.join(projectRoot, 'testing/src/public-api.ts'),
160+
join(projectRoot, 'testing/src/public-api.ts'),
164161
);
165162
});
166163

@@ -186,7 +183,7 @@ describe('entry-points pipeline', () => {
186183
name: '.',
187184
displayName: packageName,
188185
bundleName: 'my-scope-my-lib',
189-
entryFilePath: posix.join(projectRoot, 'src/public-api.ts'),
186+
entryFilePath: join(projectRoot, 'src/public-api.ts'),
190187
isPrimary: true,
191188
});
192189

@@ -196,7 +193,7 @@ describe('entry-points pipeline', () => {
196193
name: 'testing',
197194
displayName: `${packageName}/testing`,
198195
bundleName: 'my-scope-my-lib-testing',
199-
entryFilePath: posix.join(projectRoot, 'testing/src/public-api.ts'),
196+
entryFilePath: join(projectRoot, 'testing/src/public-api.ts'),
200197
isPrimary: false,
201198
});
202199

@@ -206,7 +203,7 @@ describe('entry-points pipeline', () => {
206203
name: 'testing/sub',
207204
displayName: `${packageName}/testing/sub`,
208205
bundleName: 'my-scope-my-lib-testing-sub',
209-
entryFilePath: posix.join(projectRoot, 'testing/sub/src/public-api.mts'),
206+
entryFilePath: join(projectRoot, 'testing/sub/src/public-api.mts'),
210207
isPrimary: false,
211208
});
212209
});
@@ -225,11 +222,9 @@ describe('entry-points pipeline', () => {
225222
);
226223

227224
expect(entryPoints).toHaveSize(2);
228-
expect(entryPoints.get('.')?.entryFilePath).toBe(
229-
posix.join(projectRoot, 'src/public-api.ts'),
230-
);
225+
expect(entryPoints.get('.')?.entryFilePath).toBe(join(projectRoot, 'src/public-api.ts'));
231226
expect(entryPoints.get('testing')?.entryFilePath).toBe(
232-
posix.join(projectRoot, 'testing/src/public-api.ts'),
227+
join(projectRoot, 'testing/src/public-api.ts'),
233228
);
234229
});
235230

@@ -419,7 +414,7 @@ describe('entry-points pipeline', () => {
419414
name: '.',
420415
displayName: 'my-lib',
421416
bundleName: 'my-lib',
422-
entryFilePath: posix.join(projectRoot, 'src/public-api.ts'),
417+
entryFilePath: join(projectRoot, 'src/public-api.ts'),
423418
isPrimary: true,
424419
};
425420

@@ -428,7 +423,7 @@ describe('entry-points pipeline', () => {
428423
name: 'testing',
429424
displayName: 'my-lib/testing',
430425
bundleName: 'my-lib-testing',
431-
entryFilePath: posix.join(projectRoot, 'testing/src/public-api.ts'),
426+
entryFilePath: join(projectRoot, 'testing/src/public-api.ts'),
432427
isPrimary: false,
433428
};
434429

@@ -452,7 +447,7 @@ describe('entry-points pipeline', () => {
452447
const mapB = createMap([
453448
{
454449
...primaryEp,
455-
entryFilePath: posix.join(projectRoot, 'src/other.ts'),
450+
entryFilePath: join(projectRoot, 'src/other.ts'),
456451
},
457452
]);
458453

@@ -535,8 +530,8 @@ describe('entry-points pipeline', () => {
535530
} as unknown as SingleBuildState;
536531

537532
const watchedCompilationFiles = new Set<string>([
538-
posix.join(projectRoot, 'src/public-api.ts'),
539-
posix.join(projectRoot, 'old-feature/src/public-api.ts'),
533+
join(projectRoot, 'src/public-api.ts'),
534+
join(projectRoot, 'old-feature/src/public-api.ts'),
540535
]);
541536

542537
const newPackageJson: PackageJsonData = {
@@ -560,12 +555,12 @@ describe('entry-points pipeline', () => {
560555
expect(options.entryPoints.has('old-feature')).toBeFalse();
561556
expect(buildState.previousBundleResults.has('old-feature')).toBeFalse();
562557
expect(buildState.previousBundleResults.has('.')).toBeTrue();
563-
expect(watchedCompilationFiles.has(posix.join(projectRoot, 'src/public-api.ts'))).toBeTrue();
558+
expect(watchedCompilationFiles.has(join(projectRoot, 'src/public-api.ts'))).toBeTrue();
564559
expect(
565-
watchedCompilationFiles.has(posix.join(projectRoot, 'old-feature/src/public-api.ts')),
560+
watchedCompilationFiles.has(join(projectRoot, 'old-feature/src/public-api.ts')),
566561
).toBeFalse();
567562
expect(
568-
watchedCompilationFiles.has(posix.join(projectRoot, 'new-feature/src/public-api.ts')),
563+
watchedCompilationFiles.has(join(projectRoot, 'new-feature/src/public-api.ts')),
569564
).toBeTrue();
570565
});
571566

@@ -661,9 +656,9 @@ describe('entry-points pipeline', () => {
661656
expect(buildState.hasEntryPointsChanges).toBeTrue();
662657
expect(buildState.previousBundleResults.has('.')).toBeFalse();
663658
expect(options.entryPoints.get('.')?.entryFilePath).toBe(
664-
posix.join(projectRoot, 'src/other-api.ts'),
659+
join(projectRoot, 'src/other-api.ts'),
665660
);
666-
expect(watchedCompilationFiles.has(posix.join(projectRoot, 'src/other-api.ts'))).toBeTrue();
661+
expect(watchedCompilationFiles.has(join(projectRoot, 'src/other-api.ts'))).toBeTrue();
667662
});
668663

669664
it('should prune previousBundleResults when an entry point bundleName changes', () => {

0 commit comments

Comments
 (0)