Skip to content
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

fix(@angular-devkit/build-angular): handle promise rejection in IndexHtmlWebpackPlugin #19895

Merged
merged 1 commit into from Jan 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,41 +59,45 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator {
const noModuleFiles: FileInfo[] = [];
const moduleFiles: FileInfo[] = [];

for (const [entryName, entrypoint] of this.compilation.entrypoints) {
const entryFiles: FileInfo[] = entrypoint?.getFiles()?.map(
(f: string): FileInfo => ({
name: entryName,
file: f,
extension: extname(f),
}),
);

if (!entryFiles) {
continue;
try {
for (const [entryName, entrypoint] of this.compilation.entrypoints) {
const entryFiles: FileInfo[] = entrypoint?.getFiles()?.map(
(f: string): FileInfo => ({
name: entryName,
file: f,
extension: extname(f),
}),
);

if (!entryFiles) {
continue;
}

if (this.options.noModuleEntrypoints.includes(entryName)) {
noModuleFiles.push(...entryFiles);
} else if (this.options.moduleEntrypoints.includes(entryName)) {
moduleFiles.push(...entryFiles);
} else {
files.push(...entryFiles);
}
}

if (this.options.noModuleEntrypoints.includes(entryName)) {
noModuleFiles.push(...entryFiles);
} else if (this.options.moduleEntrypoints.includes(entryName)) {
moduleFiles.push(...entryFiles);
} else {
files.push(...entryFiles);
}
const { content, warnings, errors } = await this.process({
files,
noModuleFiles,
moduleFiles,
outputPath: dirname(this.options.outputPath),
baseHref: this.options.baseHref,
lang: this.options.lang,
});

assets[this.options.outputPath] = new RawSource(content);

warnings.forEach(msg => addWarning(this.compilation, msg));
errors.forEach(msg => addError(this.compilation, msg));
} catch (error) {
addError(this.compilation, error.message);
}

const { content, warnings, errors } = await this.process({
files,
noModuleFiles,
moduleFiles,
outputPath: dirname(this.options.outputPath),
baseHref: this.options.baseHref,
lang: this.options.lang,
});

assets[this.options.outputPath] = new RawSource(content);

warnings.forEach(msg => addWarning(this.compilation, msg));
errors.forEach(msg => addError(this.compilation, msg));
};
}

Expand Down