Skip to content

fix(@angular-devkit/build-angular): throw error when multiple bundles… #13571

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 1 commit into from
Feb 13, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,36 @@ import { normalizeExtraEntryPoints } from '../models/webpack-configs/utils';
export function generateEntryPoints(
appConfig: { styles: ExtraEntryPoint[], scripts: ExtraEntryPoint[] },
) {
const entryPoints = ['es2015-polyfills', 'polyfills', 'sw-register'];

// Add all styles/scripts, except lazy-loaded ones.
[
...normalizeExtraEntryPoints(appConfig.styles, 'styles')
const extraEntryPoints = (
extraEntryPoints: ExtraEntryPoint[],
defaultBundleName: string,
): string[] => {
const entryPoints = normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName)
.filter(entry => !entry.lazy)
.map(entry => entry.bundleName),
...normalizeExtraEntryPoints(appConfig.scripts, 'scripts')
.filter(entry => !entry.lazy)
.map(entry => entry.bundleName),
].forEach(bundleName => {
if (entryPoints.indexOf(bundleName) === -1) {
entryPoints.push(bundleName);
}
});
.map(entry => entry.bundleName);

// remove duplicates
return [...new Set(entryPoints)];
};

const entryPoints = [
'es2015-polyfills',
'polyfills',
'sw-register',
...extraEntryPoints(appConfig.styles, 'styles'),
...extraEntryPoints(appConfig.scripts, 'scripts'),
'main',
];

const duplicates = [...new Set(
entryPoints.filter(x => entryPoints.indexOf(x) !== entryPoints.lastIndexOf(x)),
)];

entryPoints.push('main');
if (duplicates.length > 0) {
throw new Error(`Multiple bundles have been named the same: '${duplicates.join(`', '`)}'.`);
}

return entryPoints;
}