Skip to content

Commit 32058cb

Browse files
filipesilvahansl
authored andcommitted
fix(@angular-devkit/build-angular): build with empty assets array
Fix #10438 (comment)
1 parent 84213f6 commit 32058cb

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/angular_devkit/build_angular/src/utils/normalize-asset-patterns.ts

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ export function normalizeAssetPatterns(
3838
const sourceRoot = maybeSourceRoot || join(projectRoot, 'src');
3939
const resolvedSourceRoot = resolve(root, sourceRoot);
4040

41+
if (assetPatterns.length === 0) {
42+
// If there are no asset patterns, return an empty array.
43+
// It's important to do this because forkJoin with an empty array will immediately complete
44+
// the observable.
45+
return of([]);
46+
}
47+
4148
const assetPatternObjectObservables: Observable<AssetPatternObject>[] = assetPatterns
4249
.map(assetPattern => {
4350
// Normalize string asset patterns to objects.

packages/angular_devkit/build_angular/test/browser/assets_spec_large.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { normalize, virtualFs } from '@angular-devkit/core';
10-
import { tap } from 'rxjs/operators';
10+
import { tap, toArray } from 'rxjs/operators';
1111
import { Timeout, browserTargetSpec, host, runTargetSpec } from '../utils';
1212

1313

@@ -91,4 +91,15 @@ describe('Browser Builder assets', () => {
9191
// node_modules folder will hit this one and can fail.
9292
host.scopedSync().delete(normalize('./node_modules'));
9393
}, Timeout.Basic);
94+
95+
it('still builds with empty asset array', (done) => {
96+
const overrides = {
97+
assets: [],
98+
};
99+
100+
runTargetSpec(host, browserTargetSpec, overrides).pipe(
101+
toArray(),
102+
tap((buildEvents) => expect(buildEvents.length).toBe(1)),
103+
).subscribe(undefined, done.fail, done);
104+
}, Timeout.Basic);
94105
});

0 commit comments

Comments
 (0)