-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpackage-chunk-sort.js
31 lines (31 loc) · 1.16 KB
/
package-chunk-sort.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../models/webpack-configs/utils");
function generateEntryPoints(appConfig) {
// Add all styles/scripts, except lazy-loaded ones.
const extraEntryPoints = (extraEntryPoints, defaultBundleName) => {
const entryPoints = utils_1.normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName)
.filter(entry => entry.inject)
.map(entry => entry.bundleName);
// remove duplicates
return [...new Set(entryPoints)];
};
const entryPoints = [
'runtime',
'polyfills-es5',
'polyfills',
'sw-register',
...extraEntryPoints(appConfig.styles, 'styles'),
...extraEntryPoints(appConfig.scripts, 'scripts'),
'vendor',
'main',
];
const duplicates = [
...new Set(entryPoints.filter(x => entryPoints.indexOf(x) !== entryPoints.lastIndexOf(x))),
];
if (duplicates.length > 0) {
throw new Error(`Multiple bundles have been named the same: '${duplicates.join(`', '`)}'.`);
}
return entryPoints;
}
exports.generateEntryPoints = generateEntryPoints;