Skip to content

fix(@ngtools/webpack): allow generated assets of Angular component resources #21296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/ngtools/webpack/src/resource_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,15 @@ export class WebpackResourceLoader {

parent.warnings.push(...childCompilation.warnings);
parent.errors.push(...childCompilation.errors);
for (const { info, name, source } of childCompilation.getAssets()) {
if (info.sourceFilename === undefined) {
throw new Error(`'${name}' asset info 'sourceFilename' is 'undefined'.`);
}

this.assetCache?.set(info.sourceFilename, { info, name, source });
if (this.assetCache) {
for (const { info, name, source } of childCompilation.getAssets()) {
// Use the originating file as the cache key if present
// Otherwise, generate a cache key based on the generated name
const cacheKey = info.sourceFilename ?? `!![GENERATED]:${name}`;

this.assetCache.set(cacheKey, { info, name, source });
}
}
}

Expand Down