@angular-devkit/build-angular 12.0.0-rc.3 → 12.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +21 -21
- package/src/browser/schema.d.ts +1 -1
- package/src/browser/schema.json +1 -1
- package/src/dev-server/index.js +37 -36
- package/src/dev-server/schema.d.ts +2 -1
- package/src/dev-server/schema.json +1 -1
- package/src/extract-i18n/index.js +2 -0
- package/src/karma/schema.d.ts +1 -1
- package/src/karma/schema.json +1 -1
- package/src/sass/sass-service.d.ts +53 -0
- package/src/sass/sass-service.js +186 -0
- package/src/sass/worker.d.ts +8 -0
- package/src/sass/worker.js +49 -0
- package/src/server/schema.d.ts +1 -1
- package/src/server/schema.json +1 -1
- package/src/utils/action-executor.js +2 -2
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +12 -1
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/service-worker.js +1 -1
- package/src/webpack/configs/common.js +37 -42
- package/src/webpack/configs/server.js +8 -0
- package/src/webpack/configs/stats.d.ts +4 -14
- package/src/webpack/configs/stats.js +4 -8
- package/src/webpack/configs/styles.js +47 -7
- package/src/webpack/plugins/index-html-webpack-plugin.js +1 -1
- package/src/webpack/plugins/index.d.ts +0 -1
- package/src/webpack/plugins/index.js +1 -3
- package/src/webpack/plugins/postcss-cli-resources.js +1 -1
- package/src/webpack/utils/async-chunks.js +2 -6
- package/src/webpack/utils/stats.js +2 -7
- package/src/utils/workers.d.ts +0 -22
- package/src/utils/workers.js +0 -26
- package/src/webpack/plugins/optimize-css-webpack-plugin.d.ts +0 -17
- package/src/webpack/plugins/optimize-css-webpack-plugin.js +0 -106
package/src/utils/index.js
CHANGED
|
@@ -27,4 +27,3 @@ __exportStar(require("./normalize-source-maps"), exports);
|
|
|
27
27
|
__exportStar(require("./normalize-optimization"), exports);
|
|
28
28
|
__exportStar(require("./normalize-builder-schema"), exports);
|
|
29
29
|
__exportStar(require("./url"), exports);
|
|
30
|
-
__exportStar(require("./workers"), exports);
|
|
@@ -40,7 +40,7 @@ class CliFilesystem {
|
|
|
40
40
|
for await (const entry of await fs_1.promises.opendir(dir)) {
|
|
41
41
|
if (entry.isFile()) {
|
|
42
42
|
// Uses posix paths since the service worker expects URLs
|
|
43
|
-
items.push('/' + path.
|
|
43
|
+
items.push('/' + path.relative(this.base, path.join(dir, entry.name)).replace(/\\/g, '/'));
|
|
44
44
|
}
|
|
45
45
|
else if (entry.isDirectory()) {
|
|
46
46
|
subdirectories.push(path.join(dir, entry.name));
|
|
@@ -23,7 +23,6 @@ const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
|
23
23
|
const plugins_1 = require("../plugins");
|
|
24
24
|
const helpers_1 = require("../utils/helpers");
|
|
25
25
|
const stats_1 = require("../utils/stats");
|
|
26
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
27
26
|
// eslint-disable-next-line max-lines-per-function
|
|
28
27
|
function getCommonConfig(wco) {
|
|
29
28
|
var _a;
|
|
@@ -34,7 +33,33 @@ function getCommonConfig(wco) {
|
|
|
34
33
|
const entryPoints = {};
|
|
35
34
|
// determine hashing format
|
|
36
35
|
const hashFormat = helpers_1.getOutputHashFormat(buildOptions.outputHashing || 'none');
|
|
36
|
+
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
|
|
37
37
|
const targetInFileName = helpers_1.getEsVersionForFileName(tsConfig.options.target, buildOptions.differentialLoadingNeeded);
|
|
38
|
+
if (buildOptions.progress) {
|
|
39
|
+
const spinner = new spinner_1.Spinner();
|
|
40
|
+
spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
|
|
41
|
+
let previousPercentage;
|
|
42
|
+
extraPlugins.push(new webpack_1.ProgressPlugin({
|
|
43
|
+
handler: (percentage, message) => {
|
|
44
|
+
if (previousPercentage === 1 && percentage !== 0) {
|
|
45
|
+
// In some scenarios in Webpack 5 percentage goes from 1 back to 0.99.
|
|
46
|
+
// Ex: 0.99 -> 1 -> 0.99 -> 1
|
|
47
|
+
// This causes the "complete" message to be displayed multiple times.
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
switch (percentage) {
|
|
51
|
+
case 1:
|
|
52
|
+
spinner.succeed(`${platform.replace(/^\w/, (s) => s.toUpperCase())} application bundle generation complete.`);
|
|
53
|
+
break;
|
|
54
|
+
case 0:
|
|
55
|
+
default:
|
|
56
|
+
spinner.text = `Generating ${platform} application bundles (phase: ${message})...`;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
previousPercentage = percentage;
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
38
63
|
if (buildOptions.main) {
|
|
39
64
|
const mainPath = path.resolve(root, buildOptions.main);
|
|
40
65
|
entryPoints['main'] = [mainPath];
|
|
@@ -42,7 +67,6 @@ function getCommonConfig(wco) {
|
|
|
42
67
|
const differentialLoadingMode = buildOptions.differentialLoadingNeeded && !buildOptions.watch;
|
|
43
68
|
if (platform !== 'server') {
|
|
44
69
|
if (differentialLoadingMode || tsConfig.options.target === typescript_1.ScriptTarget.ES5) {
|
|
45
|
-
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
|
|
46
70
|
if (buildBrowserFeatures.isEs5SupportNeeded()) {
|
|
47
71
|
const polyfillsChunkName = 'polyfills-es5';
|
|
48
72
|
entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')];
|
|
@@ -162,32 +186,6 @@ function getCommonConfig(wco) {
|
|
|
162
186
|
patterns: copyWebpackPluginPatterns,
|
|
163
187
|
}));
|
|
164
188
|
}
|
|
165
|
-
if (buildOptions.progress) {
|
|
166
|
-
const spinner = new spinner_1.Spinner();
|
|
167
|
-
let previousPercentage;
|
|
168
|
-
extraPlugins.push(new webpack_1.ProgressPlugin({
|
|
169
|
-
handler: (percentage, message) => {
|
|
170
|
-
if (previousPercentage === 1 && percentage !== 0) {
|
|
171
|
-
// In some scenarios in Webpack 5 percentage goes from 1 back to 0.99.
|
|
172
|
-
// Ex: 0.99 -> 1 -> 0.99 -> 1
|
|
173
|
-
// This causes the "complete" message to be displayed multiple times.
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
switch (percentage) {
|
|
177
|
-
case 0:
|
|
178
|
-
spinner.start(`Generating ${platform} application bundles...`);
|
|
179
|
-
break;
|
|
180
|
-
case 1:
|
|
181
|
-
spinner.succeed(`${platform.replace(/^\w/, (s) => s.toUpperCase())} application bundle generation complete.`);
|
|
182
|
-
break;
|
|
183
|
-
default:
|
|
184
|
-
spinner.text = `Generating ${platform} application bundles (phase: ${message})...`;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
previousPercentage = percentage;
|
|
188
|
-
},
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
189
|
if (buildOptions.showCircularDependencies) {
|
|
192
190
|
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
193
191
|
extraPlugins.push(new CircularDependencyPlugin({
|
|
@@ -200,7 +198,7 @@ function getCommonConfig(wco) {
|
|
|
200
198
|
compiler.hooks.done.tapPromise('angular-cli-stats', async (stats) => {
|
|
201
199
|
const { stringifyStream } = await Promise.resolve().then(() => require('@discoveryjs/json-ext'));
|
|
202
200
|
const data = stats.toJson('verbose');
|
|
203
|
-
const statsOutputPath = path.
|
|
201
|
+
const statsOutputPath = path.resolve(root, buildOptions.outputPath, 'stats.json');
|
|
204
202
|
try {
|
|
205
203
|
await fs_1.promises.mkdir(path.dirname(statsOutputPath), { recursive: true });
|
|
206
204
|
await new Promise((resolve, reject) => stringifyStream(data)
|
|
@@ -234,14 +232,8 @@ function getCommonConfig(wco) {
|
|
|
234
232
|
];
|
|
235
233
|
}
|
|
236
234
|
const extraMinimizers = [];
|
|
237
|
-
if (stylesOptimization.minify) {
|
|
238
|
-
extraMinimizers.push(new plugins_1.OptimizeCssWebpackPlugin({
|
|
239
|
-
sourceMap: stylesSourceMap,
|
|
240
|
-
// component styles retain their original file name
|
|
241
|
-
test: (file) => /\.(?:css|scss|sass|less|styl)$/.test(file),
|
|
242
|
-
}));
|
|
243
|
-
}
|
|
244
235
|
if (scriptsOptimization) {
|
|
236
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
245
237
|
const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, } = require('@angular/compiler-cli');
|
|
246
238
|
const angularGlobalDefinitions = buildOptions.aot
|
|
247
239
|
? GLOBAL_DEFS_FOR_TERSER_WITH_AOT
|
|
@@ -285,9 +277,7 @@ function getCommonConfig(wco) {
|
|
|
285
277
|
};
|
|
286
278
|
const globalScriptsNames = globalScriptsByBundleName.map((s) => s.bundleName);
|
|
287
279
|
extraMinimizers.push(new TerserPlugin({
|
|
288
|
-
|
|
289
|
-
parallel: utils_1.maxWorkers,
|
|
290
|
-
cache: !environment_options_1.cachingDisabled && cache_path_1.findCachePath('terser-webpack'),
|
|
280
|
+
parallel: environment_options_1.maxWorkers,
|
|
291
281
|
extractComments: false,
|
|
292
282
|
exclude: globalScriptsNames,
|
|
293
283
|
terserOptions,
|
|
@@ -295,9 +285,7 @@ function getCommonConfig(wco) {
|
|
|
295
285
|
// Script bundles are fully optimized here in one step since they are never downleveled.
|
|
296
286
|
// They are shared between ES2015 & ES5 outputs so must support ES5.
|
|
297
287
|
new TerserPlugin({
|
|
298
|
-
|
|
299
|
-
parallel: utils_1.maxWorkers,
|
|
300
|
-
cache: !environment_options_1.cachingDisabled && cache_path_1.findCachePath('terser-webpack'),
|
|
288
|
+
parallel: environment_options_1.maxWorkers,
|
|
301
289
|
extractComments: false,
|
|
302
290
|
include: globalScriptsNames,
|
|
303
291
|
terserOptions: {
|
|
@@ -337,6 +325,7 @@ function getCommonConfig(wco) {
|
|
|
337
325
|
context: root,
|
|
338
326
|
entry: entryPoints,
|
|
339
327
|
output: {
|
|
328
|
+
clean: buildOptions.deleteOutputPath,
|
|
340
329
|
path: path.resolve(root, buildOptions.outputPath),
|
|
341
330
|
publicPath: (_a = buildOptions.deployUrl) !== null && _a !== void 0 ? _a : '',
|
|
342
331
|
filename: ({ chunk }) => {
|
|
@@ -374,6 +363,8 @@ function getCommonConfig(wco) {
|
|
|
374
363
|
},
|
|
375
364
|
{
|
|
376
365
|
test: /\.[cm]?js$|\.tsx?$/,
|
|
366
|
+
// The below is needed due to a bug in `@babel/runtime`. See: https://github.com/babel/babel/issues/12824
|
|
367
|
+
resolve: { fullySpecified: false },
|
|
377
368
|
exclude: [/[\/\\](?:core-js|\@babel|tslib|web-animations-js)[\/\\]/],
|
|
378
369
|
use: [
|
|
379
370
|
{
|
|
@@ -390,6 +381,10 @@ function getCommonConfig(wco) {
|
|
|
390
381
|
...extraRules,
|
|
391
382
|
],
|
|
392
383
|
},
|
|
384
|
+
experiments: {
|
|
385
|
+
syncWebAssembly: true,
|
|
386
|
+
asyncWebAssembly: true,
|
|
387
|
+
},
|
|
393
388
|
cache: !!buildOptions.watch &&
|
|
394
389
|
!environment_options_1.cachingDisabled && {
|
|
395
390
|
type: 'memory',
|
|
@@ -34,6 +34,14 @@ function getServerConfig(wco) {
|
|
|
34
34
|
output: {
|
|
35
35
|
libraryTarget: 'commonjs',
|
|
36
36
|
},
|
|
37
|
+
module: {
|
|
38
|
+
parser: {
|
|
39
|
+
javascript: {
|
|
40
|
+
worker: false,
|
|
41
|
+
url: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
37
45
|
plugins: [
|
|
38
46
|
// Fixes Critical dependency: the request of a dependency is an expression
|
|
39
47
|
new webpack_1.ContextReplacementPlugin(/@?hapi(\\|\/)/),
|
|
@@ -13,16 +13,11 @@ export declare function getWebpackStatsConfig(verbose?: boolean): {
|
|
|
13
13
|
timings: boolean;
|
|
14
14
|
chunks: boolean;
|
|
15
15
|
builtAt: boolean;
|
|
16
|
-
chunkModules: boolean;
|
|
17
|
-
children: boolean;
|
|
18
|
-
modules: boolean;
|
|
19
|
-
reasons: boolean;
|
|
20
16
|
warnings: boolean;
|
|
21
17
|
errors: boolean;
|
|
22
18
|
assets: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
moduleTrace: boolean;
|
|
19
|
+
ids: boolean;
|
|
20
|
+
entrypoints: boolean;
|
|
26
21
|
};
|
|
27
22
|
export declare function getStatsConfig(wco: WebpackConfigOptions): {
|
|
28
23
|
stats: {
|
|
@@ -32,15 +27,10 @@ export declare function getStatsConfig(wco: WebpackConfigOptions): {
|
|
|
32
27
|
timings: boolean;
|
|
33
28
|
chunks: boolean;
|
|
34
29
|
builtAt: boolean;
|
|
35
|
-
chunkModules: boolean;
|
|
36
|
-
children: boolean;
|
|
37
|
-
modules: boolean;
|
|
38
|
-
reasons: boolean;
|
|
39
30
|
warnings: boolean;
|
|
40
31
|
errors: boolean;
|
|
41
32
|
assets: boolean;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
moduleTrace: boolean;
|
|
33
|
+
ids: boolean;
|
|
34
|
+
entrypoints: boolean;
|
|
45
35
|
};
|
|
46
36
|
};
|
|
@@ -15,16 +15,12 @@ const webpackOutputOptions = {
|
|
|
15
15
|
timings: true,
|
|
16
16
|
chunks: true,
|
|
17
17
|
builtAt: true,
|
|
18
|
-
chunkModules: false,
|
|
19
|
-
children: false,
|
|
20
|
-
modules: false,
|
|
21
|
-
reasons: false,
|
|
22
18
|
warnings: true,
|
|
23
19
|
errors: true,
|
|
24
20
|
assets: true,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
// Needed for markAsyncChunksNonInitial.
|
|
22
|
+
ids: true,
|
|
23
|
+
entrypoints: true,
|
|
28
24
|
};
|
|
29
25
|
const verboseWebpackOutputOptions = {
|
|
30
26
|
// The verbose output will most likely be piped to a file, so colors just mess it up.
|
|
@@ -39,8 +35,8 @@ const verboseWebpackOutputOptions = {
|
|
|
39
35
|
errorDetails: true,
|
|
40
36
|
moduleTrace: true,
|
|
41
37
|
logging: 'verbose',
|
|
38
|
+
modulesSpace: Infinity,
|
|
42
39
|
};
|
|
43
|
-
verboseWebpackOutputOptions['modulesSpace'] = Infinity;
|
|
44
40
|
function getWebpackStatsConfig(verbose = false) {
|
|
45
41
|
return verbose
|
|
46
42
|
? { ...webpackOutputOptions, ...verboseWebpackOutputOptions }
|
|
@@ -10,7 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.getStylesConfig = void 0;
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
|
+
const sass_service_1 = require("../../sass/sass-service");
|
|
13
14
|
const build_browser_features_1 = require("../../utils/build-browser-features");
|
|
15
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
14
16
|
const plugins_1 = require("../plugins");
|
|
15
17
|
const helpers_1 = require("../utils/helpers");
|
|
16
18
|
function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
|
|
@@ -62,7 +64,7 @@ function getStylesConfig(wco) {
|
|
|
62
64
|
// use includePaths from appConfig
|
|
63
65
|
const includePaths = (_c = (_b = (_a = buildOptions.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths) === null || _b === void 0 ? void 0 : _b.map((p) => path.resolve(root, p))) !== null && _c !== void 0 ? _c : [];
|
|
64
66
|
// Process global styles.
|
|
65
|
-
const { entryPoints, noInjectNames, paths: globalStylePaths } = resolveGlobalStyles(buildOptions.styles, root, !!buildOptions.preserveSymlinks);
|
|
67
|
+
const { entryPoints, noInjectNames, paths: globalStylePaths, } = resolveGlobalStyles(buildOptions.styles, root, !!buildOptions.preserveSymlinks);
|
|
66
68
|
if (noInjectNames.length > 0) {
|
|
67
69
|
// Add plugin to remove hashes from lazy styles.
|
|
68
70
|
extraPlugins.push(new plugins_1.RemoveHashPlugin({ chunkNames: noInjectNames, hashFormat }));
|
|
@@ -78,7 +80,7 @@ function getStylesConfig(wco) {
|
|
|
78
80
|
`To opt-out of the deprecated behaviour and start using 'sass' uninstall 'node-sass'.`);
|
|
79
81
|
}
|
|
80
82
|
catch {
|
|
81
|
-
sassImplementation =
|
|
83
|
+
sassImplementation = new sass_service_1.SassWorkerImplementation();
|
|
82
84
|
}
|
|
83
85
|
const assetNameTemplate = helpers_1.assetNameTemplateFactory(hashFormat);
|
|
84
86
|
const extraPostcssPlugins = [];
|
|
@@ -115,6 +117,11 @@ function getStylesConfig(wco) {
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
const { supportedBrowsers } = new build_browser_features_1.BuildBrowserFeatures(wco.projectRoot);
|
|
120
|
+
const postcssPresetEnvPlugin = postcssPresetEnv({
|
|
121
|
+
browsers: supportedBrowsers,
|
|
122
|
+
autoprefixer: true,
|
|
123
|
+
stage: 3,
|
|
124
|
+
});
|
|
118
125
|
const postcssOptionsCreator = (inlineSourcemaps, extracted) => {
|
|
119
126
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
127
|
const optionGenerator = (loader) => ({
|
|
@@ -150,11 +157,7 @@ function getStylesConfig(wco) {
|
|
|
150
157
|
extracted,
|
|
151
158
|
}),
|
|
152
159
|
...extraPostcssPlugins,
|
|
153
|
-
|
|
154
|
-
browsers: supportedBrowsers,
|
|
155
|
-
autoprefixer: true,
|
|
156
|
-
stage: 3,
|
|
157
|
-
}),
|
|
160
|
+
postcssPresetEnvPlugin,
|
|
158
161
|
],
|
|
159
162
|
});
|
|
160
163
|
// postcss-loader fails when trying to determine configuration files for data URIs
|
|
@@ -232,6 +235,8 @@ function getStylesConfig(wco) {
|
|
|
232
235
|
implementation: sassImplementation,
|
|
233
236
|
sourceMap: true,
|
|
234
237
|
sassOptions: {
|
|
238
|
+
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
239
|
+
fiber: false,
|
|
235
240
|
// bootstrap-sass requires a minimum precision of 8
|
|
236
241
|
precision: 8,
|
|
237
242
|
includePaths,
|
|
@@ -340,11 +345,46 @@ function getStylesConfig(wco) {
|
|
|
340
345
|
],
|
|
341
346
|
});
|
|
342
347
|
}
|
|
348
|
+
const extraMinimizers = [];
|
|
349
|
+
if (buildOptions.optimization.styles.minify) {
|
|
350
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
351
|
+
const minimizerOptions = {
|
|
352
|
+
preset: [
|
|
353
|
+
'default',
|
|
354
|
+
{
|
|
355
|
+
// Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
|
|
356
|
+
svgo: false,
|
|
357
|
+
// Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
|
|
358
|
+
calc: false,
|
|
359
|
+
// Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
|
|
360
|
+
cssDeclarationSorter: false,
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
};
|
|
364
|
+
const globalBundlesRegExp = new RegExp(`^(${Object.keys(entryPoints).join('|')})(\.[0-9a-f]{20})?.css$`);
|
|
365
|
+
extraMinimizers.push(new CssMinimizerPlugin({
|
|
366
|
+
// Component styles retain their original file name
|
|
367
|
+
test: /\.(?:css|scss|sass|less|styl)$/,
|
|
368
|
+
parallel: false,
|
|
369
|
+
exclude: globalBundlesRegExp,
|
|
370
|
+
minify: [CssMinimizerPlugin.cssnanoMinify],
|
|
371
|
+
minimizerOptions,
|
|
372
|
+
}), new CssMinimizerPlugin({
|
|
373
|
+
test: /\.css$/,
|
|
374
|
+
include: globalBundlesRegExp,
|
|
375
|
+
parallel: environment_options_1.maxWorkers,
|
|
376
|
+
minify: [CssMinimizerPlugin.cssnanoMinify],
|
|
377
|
+
minimizerOptions,
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
343
380
|
return {
|
|
344
381
|
entry: entryPoints,
|
|
345
382
|
module: {
|
|
346
383
|
rules: [...fileLanguageRules, ...inlineLanguageRules],
|
|
347
384
|
},
|
|
385
|
+
optimization: {
|
|
386
|
+
minimizer: extraMinimizers,
|
|
387
|
+
},
|
|
348
388
|
plugins: extraPlugins,
|
|
349
389
|
};
|
|
350
390
|
}
|
|
@@ -40,7 +40,7 @@ class IndexHtmlWebpackPlugin extends index_html_generator_1.IndexHtmlGenerator {
|
|
|
40
40
|
const moduleFiles = [];
|
|
41
41
|
try {
|
|
42
42
|
for (const [entryName, entrypoint] of this.compilation.entrypoints) {
|
|
43
|
-
const entryFiles = (_a = entrypoint === null || entrypoint === void 0 ? void 0 : entrypoint.getFiles()) === null || _a === void 0 ? void 0 : _a.map((f) => ({
|
|
43
|
+
const entryFiles = (_a = entrypoint === null || entrypoint === void 0 ? void 0 : entrypoint.getFiles()) === null || _a === void 0 ? void 0 : _a.filter((f) => !f.endsWith('.hot-update.js')).map((f) => ({
|
|
44
44
|
name: entryName,
|
|
45
45
|
file: f,
|
|
46
46
|
extension: path_1.extname(f),
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export { AnyComponentStyleBudgetChecker } from './any-component-style-budget-checker';
|
|
9
|
-
export { OptimizeCssWebpackPlugin, OptimizeCssWebpackPluginOptions, } from './optimize-css-webpack-plugin';
|
|
10
9
|
export { ScriptsWebpackPlugin, ScriptsWebpackPluginOptions } from './scripts-webpack-plugin';
|
|
11
10
|
export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunks-webpack-plugin';
|
|
12
11
|
export { RemoveHashPlugin, RemoveHashPluginOptions } from './remove-hash-plugin';
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.
|
|
10
|
+
exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
|
|
11
11
|
// Exports the webpack plugins we use internally.
|
|
12
12
|
var any_component_style_budget_checker_1 = require("./any-component-style-budget-checker");
|
|
13
13
|
Object.defineProperty(exports, "AnyComponentStyleBudgetChecker", { enumerable: true, get: function () { return any_component_style_budget_checker_1.AnyComponentStyleBudgetChecker; } });
|
|
14
|
-
var optimize_css_webpack_plugin_1 = require("./optimize-css-webpack-plugin");
|
|
15
|
-
Object.defineProperty(exports, "OptimizeCssWebpackPlugin", { enumerable: true, get: function () { return optimize_css_webpack_plugin_1.OptimizeCssWebpackPlugin; } });
|
|
16
14
|
var scripts_webpack_plugin_1 = require("./scripts-webpack-plugin");
|
|
17
15
|
Object.defineProperty(exports, "ScriptsWebpackPlugin", { enumerable: true, get: function () { return scripts_webpack_plugin_1.ScriptsWebpackPlugin; } });
|
|
18
16
|
var suppress_entry_chunks_webpack_plugin_1 = require("./suppress-entry-chunks-webpack-plugin");
|
|
@@ -83,7 +83,7 @@ function default_1(options) {
|
|
|
83
83
|
}
|
|
84
84
|
loader.addDependency(result);
|
|
85
85
|
if (emitFile) {
|
|
86
|
-
loader.emitFile(outputPath, content, undefined);
|
|
86
|
+
loader.emitFile(outputPath, content, undefined, { sourceFilename: result });
|
|
87
87
|
}
|
|
88
88
|
let outputUrl = outputPath.replace(/\\/g, '/');
|
|
89
89
|
if (hash || search) {
|
|
@@ -24,17 +24,13 @@ function markAsyncChunksNonInitial(webpackStats, extraEntryPoints) {
|
|
|
24
24
|
.filter((entryPoint) => !entryPoint.inject)
|
|
25
25
|
.flatMap((entryPoint) => entryPoints[entryPoint.bundleName].chunks);
|
|
26
26
|
// Find chunks for each ID.
|
|
27
|
-
const asyncChunks = asyncChunkIds
|
|
28
|
-
.map((chunkId) => {
|
|
27
|
+
const asyncChunks = asyncChunkIds.map((chunkId) => {
|
|
29
28
|
const chunk = chunks.find((chunk) => chunk.id === chunkId);
|
|
30
29
|
if (!chunk) {
|
|
31
30
|
throw new Error(`Failed to find chunk (${chunkId}) in set:\n${JSON.stringify(chunks)}`);
|
|
32
31
|
}
|
|
33
32
|
return chunk;
|
|
34
|
-
})
|
|
35
|
-
// All Webpack chunks are dependent on `runtime`, which is never an async
|
|
36
|
-
// entry point, simply ignore this one.
|
|
37
|
-
.filter((chunk) => { var _a; return !!((_a = chunk.names) === null || _a === void 0 ? void 0 : _a.includes('runtime')); });
|
|
33
|
+
});
|
|
38
34
|
// A chunk is considered `initial` only if Webpack already belives it to be initial
|
|
39
35
|
// and the application developer did not mark it async via an extra entry point.
|
|
40
36
|
return chunks.map((chunk) => ({
|
|
@@ -12,6 +12,7 @@ const core_1 = require("@angular-devkit/core");
|
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const textTable = require("text-table");
|
|
14
14
|
const color_1 = require("../../utils/color");
|
|
15
|
+
const stats_1 = require("../configs/stats");
|
|
15
16
|
function formatSize(size) {
|
|
16
17
|
if (size <= 0) {
|
|
17
18
|
return '0 bytes';
|
|
@@ -259,13 +260,7 @@ function createWebpackLoggingCallback(verbose, logger) {
|
|
|
259
260
|
if (verbose) {
|
|
260
261
|
logger.info(stats.toString(config.stats));
|
|
261
262
|
}
|
|
262
|
-
webpackStatsLogger(logger, stats.toJson(
|
|
263
|
-
errors: true,
|
|
264
|
-
warnings: true,
|
|
265
|
-
builtAt: true,
|
|
266
|
-
assets: true,
|
|
267
|
-
chunks: true,
|
|
268
|
-
}), config);
|
|
263
|
+
webpackStatsLogger(logger, stats.toJson(stats_1.getWebpackStatsConfig(false)), config);
|
|
269
264
|
};
|
|
270
265
|
}
|
|
271
266
|
exports.createWebpackLoggingCallback = createWebpackLoggingCallback;
|
package/src/utils/workers.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Use CPU count -1 with limit to 7 for workers not to clog the system.
|
|
10
|
-
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
|
11
|
-
* This cause `Error: Call retries were exceeded` errors when trying to use them.
|
|
12
|
-
*
|
|
13
|
-
* See:
|
|
14
|
-
*
|
|
15
|
-
* https://github.com/nodejs/node/issues/28762
|
|
16
|
-
*
|
|
17
|
-
* https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
|
|
18
|
-
*
|
|
19
|
-
* https://github.com/angular/angular-cli/issues/16860#issuecomment-588828079
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export declare const maxWorkers: number;
|
package/src/utils/workers.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.maxWorkers = void 0;
|
|
11
|
-
const os_1 = require("os");
|
|
12
|
-
/**
|
|
13
|
-
* Use CPU count -1 with limit to 7 for workers not to clog the system.
|
|
14
|
-
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
|
15
|
-
* This cause `Error: Call retries were exceeded` errors when trying to use them.
|
|
16
|
-
*
|
|
17
|
-
* See:
|
|
18
|
-
*
|
|
19
|
-
* https://github.com/nodejs/node/issues/28762
|
|
20
|
-
*
|
|
21
|
-
* https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
|
|
22
|
-
*
|
|
23
|
-
* https://github.com/angular/angular-cli/issues/16860#issuecomment-588828079
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
exports.maxWorkers = Math.max(Math.min(os_1.cpus().length, 8) - 1, 1);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { Compiler } from 'webpack';
|
|
9
|
-
export interface OptimizeCssWebpackPluginOptions {
|
|
10
|
-
sourceMap: boolean;
|
|
11
|
-
test: (file: string) => boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare class OptimizeCssWebpackPlugin {
|
|
14
|
-
private readonly _options;
|
|
15
|
-
constructor(options: Partial<OptimizeCssWebpackPluginOptions>);
|
|
16
|
-
apply(compiler: Compiler): void;
|
|
17
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.OptimizeCssWebpackPlugin = void 0;
|
|
11
|
-
const cssNano = require("cssnano");
|
|
12
|
-
const webpack_1 = require("webpack");
|
|
13
|
-
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
14
|
-
const PLUGIN_NAME = 'optimize-css-webpack-plugin';
|
|
15
|
-
function hook(compiler, action) {
|
|
16
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
17
|
-
compilation.hooks.processAssets.tapPromise({
|
|
18
|
-
name: PLUGIN_NAME,
|
|
19
|
-
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
|
|
20
|
-
}, (assets) => action(compilation, Object.keys(assets)));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
class OptimizeCssWebpackPlugin {
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this._options = {
|
|
26
|
-
sourceMap: false,
|
|
27
|
-
test: (file) => file.endsWith('.css'),
|
|
28
|
-
...options,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
apply(compiler) {
|
|
32
|
-
hook(compiler, (compilation, assetsURI) => {
|
|
33
|
-
const files = [...compilation.additionalChunkAssets, ...assetsURI];
|
|
34
|
-
const actions = files
|
|
35
|
-
.filter((file) => this._options.test(file))
|
|
36
|
-
.map(async (file) => {
|
|
37
|
-
const asset = compilation.assets[file];
|
|
38
|
-
if (!asset) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
let content;
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
let map;
|
|
44
|
-
if (this._options.sourceMap && asset.sourceAndMap) {
|
|
45
|
-
const sourceAndMap = asset.sourceAndMap({});
|
|
46
|
-
content = sourceAndMap.source;
|
|
47
|
-
map = sourceAndMap.map;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
content = asset.source();
|
|
51
|
-
}
|
|
52
|
-
if (typeof content !== 'string') {
|
|
53
|
-
content = content.toString();
|
|
54
|
-
}
|
|
55
|
-
if (content.length === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const cssNanoOptions = {
|
|
59
|
-
preset: [
|
|
60
|
-
'default',
|
|
61
|
-
{
|
|
62
|
-
// Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
|
|
63
|
-
svgo: false,
|
|
64
|
-
// Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
|
|
65
|
-
calc: false,
|
|
66
|
-
// Disable CSS rules sorted due to several issues #20693, https://github.com/ionic-team/ionic-framework/issues/23266 and https://github.com/cssnano/cssnano/issues/1054
|
|
67
|
-
cssDeclarationSorter: false,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
const postCssOptions = {
|
|
72
|
-
from: file,
|
|
73
|
-
map: map && { annotation: false, prev: map },
|
|
74
|
-
};
|
|
75
|
-
try {
|
|
76
|
-
const output = await new Promise((resolve, reject) => {
|
|
77
|
-
// @types/cssnano are not up to date with version 5.
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
cssNano(cssNanoOptions)
|
|
80
|
-
.process(content, postCssOptions)
|
|
81
|
-
.then(resolve)
|
|
82
|
-
.catch((err) => reject(err));
|
|
83
|
-
});
|
|
84
|
-
for (const { text } of output.warnings()) {
|
|
85
|
-
webpack_diagnostics_1.addWarning(compilation, text);
|
|
86
|
-
}
|
|
87
|
-
let newSource;
|
|
88
|
-
if (output.map) {
|
|
89
|
-
newSource = new webpack_1.sources.SourceMapSource(output.css, file, output.map.toString(), content, map);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
newSource = new webpack_1.sources.RawSource(output.css);
|
|
93
|
-
}
|
|
94
|
-
compilation.assets[file] = newSource;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
webpack_diagnostics_1.addError(compilation, error.message);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
102
|
-
return Promise.all(actions).then(() => { });
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.OptimizeCssWebpackPlugin = OptimizeCssWebpackPlugin;
|