@angular-devkit/build-angular 12.0.1 → 12.0.2

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "12.0.1",
3
+ "version": "12.0.2",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "main": "src/index.js",
6
6
  "typings": "src/index.d.ts",
7
7
  "builders": "builders.json",
8
8
  "dependencies": {
9
- "@angular-devkit/architect": "0.1200.1",
10
- "@angular-devkit/build-optimizer": "0.1200.1",
11
- "@angular-devkit/build-webpack": "0.1200.1",
12
- "@angular-devkit/core": "12.0.1",
9
+ "@angular-devkit/architect": "0.1200.2",
10
+ "@angular-devkit/build-optimizer": "0.1200.2",
11
+ "@angular-devkit/build-webpack": "0.1200.2",
12
+ "@angular-devkit/core": "12.0.2",
13
13
  "@babel/core": "7.14.3",
14
14
  "@babel/generator": "7.14.3",
15
15
  "@babel/plugin-transform-async-to-generator": "7.13.0",
@@ -19,7 +19,7 @@
19
19
  "@babel/template": "7.12.13",
20
20
  "@discoveryjs/json-ext": "0.5.2",
21
21
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
22
- "@ngtools/webpack": "12.0.1",
22
+ "@ngtools/webpack": "12.0.2",
23
23
  "ansi-colors": "4.1.1",
24
24
  "babel-loader": "8.2.2",
25
25
  "browserslist": "^4.9.1",
@@ -46,7 +46,7 @@
46
46
  "open": "8.0.2",
47
47
  "ora": "5.4.0",
48
48
  "parse5-html-rewriting-stream": "6.0.1",
49
- "postcss": "8.2.14",
49
+ "postcss": "8.3.0",
50
50
  "postcss-import": "14.0.1",
51
51
  "postcss-loader": "5.2.0",
52
52
  "postcss-preset-env": "6.7.0",
@@ -133,7 +133,8 @@ function serveWebpackBrowser(options, context, transforms = {}) {
133
133
  logger.warn(core_1.tags.stripIndents `NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
134
134
  See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`);
135
135
  }
136
- if (options.host &&
136
+ if (!options.disableHostCheck &&
137
+ options.host &&
137
138
  !/^127\.\d+\.\d+\.\d+/g.test(options.host) &&
138
139
  options.host !== 'localhost') {
139
140
  logger.warn(core_1.tags.stripIndent `
@@ -150,6 +150,7 @@ async function execute(options, context, transforms) {
150
150
  configs_1.getCommonConfig(wco),
151
151
  configs_1.getBrowserConfig(wco),
152
152
  configs_1.getTypeScriptConfig(wco),
153
+ configs_1.getWorkerConfig(wco),
153
154
  configs_1.getStatsConfig(wco),
154
155
  ];
155
156
  // Add Ivy application file extractor support
@@ -14,6 +14,14 @@ const environment_options_1 = require("../utils/environment-options");
14
14
  * The maximum number of Workers that will be created to execute render requests.
15
15
  */
16
16
  const MAX_RENDER_WORKERS = environment_options_1.maxWorkers;
17
+ /**
18
+ * Workaround required for lack of new Worker transfer list support in Node.js prior to 12.17
19
+ */
20
+ let transferListWorkaround = false;
21
+ const version = process.versions.node.split('.').map((part) => Number(part));
22
+ if (version[0] === 12 && version[1] < 17) {
23
+ transferListWorkaround = true;
24
+ }
17
25
  /**
18
26
  * A Sass renderer implementation that provides an interface that can be used by Webpack's
19
27
  * `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
@@ -94,9 +102,12 @@ class SassWorkerImplementation {
94
102
  const importerSignal = new Int32Array(new SharedArrayBuffer(4));
95
103
  const workerPath = require.resolve('./worker');
96
104
  const worker = new worker_threads_1.Worker(workerPath, {
97
- workerData: { workerImporterPort, importerSignal },
98
- transferList: [workerImporterPort],
105
+ workerData: transferListWorkaround ? undefined : { workerImporterPort, importerSignal },
106
+ transferList: transferListWorkaround ? undefined : [workerImporterPort],
99
107
  });
108
+ if (transferListWorkaround) {
109
+ worker.postMessage({ init: true, workerImporterPort, importerSignal }, [workerImporterPort]);
110
+ }
100
111
  worker.on('message', (response) => {
101
112
  const request = this.requests.get(response.id);
102
113
  if (!request) {
@@ -9,12 +9,19 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  const sass_1 = require("sass");
11
11
  const worker_threads_1 = require("worker_threads");
12
- if (!worker_threads_1.parentPort || !worker_threads_1.workerData) {
12
+ if (!worker_threads_1.parentPort) {
13
13
  throw new Error('Sass worker must be executed as a Worker.');
14
14
  }
15
15
  // The importer variables are used to proxy import requests to the main thread
16
- const { workerImporterPort, importerSignal } = worker_threads_1.workerData;
17
- worker_threads_1.parentPort.on('message', ({ id, hasImporter, options }) => {
16
+ let { workerImporterPort, importerSignal } = (worker_threads_1.workerData || {});
17
+ worker_threads_1.parentPort.on('message', (message) => {
18
+ // The init message is only needed to support Node.js < 12.17 and can be removed once support is dropped
19
+ if (message.init) {
20
+ workerImporterPort = message.workerImporterPort;
21
+ importerSignal = message.importerSignal;
22
+ return;
23
+ }
24
+ const { id, hasImporter, options } = message;
18
25
  try {
19
26
  if (hasImporter) {
20
27
  // When a custom importer function is present, the importer request must be proxied
@@ -35,6 +42,8 @@ worker_threads_1.parentPort.on('message', ({ id, hasImporter, options }) => {
35
42
  worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({ id, result });
36
43
  }
37
44
  catch (error) {
38
- worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({ id, error });
45
+ // Needed because V8 will only serialize the message and stack properties of an Error instance.
46
+ const { formatted, file, line, column, message, stack } = error;
47
+ worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({ id, error: { formatted, file, line, column, message, stack } });
39
48
  }
40
49
  });
@@ -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.posix.relative(this.base, path.posix.join(dir, entry.name)));
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));
@@ -199,7 +199,7 @@ function getCommonConfig(wco) {
199
199
  compiler.hooks.done.tapPromise('angular-cli-stats', async (stats) => {
200
200
  const { stringifyStream } = await Promise.resolve().then(() => require('@discoveryjs/json-ext'));
201
201
  const data = stats.toJson('verbose');
202
- const statsOutputPath = path.join(root, buildOptions.outputPath, 'stats.json');
202
+ const statsOutputPath = path.resolve(root, buildOptions.outputPath, 'stats.json');
203
203
  try {
204
204
  await fs_1.promises.mkdir(path.dirname(statsOutputPath), { recursive: true });
205
205
  await new Promise((resolve, reject) => stringifyStream(data)
@@ -233,28 +233,6 @@ function getCommonConfig(wco) {
233
233
  ];
234
234
  }
235
235
  const extraMinimizers = [];
236
- if (stylesOptimization.minify) {
237
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
238
- extraMinimizers.push(new CssMinimizerPlugin({
239
- // component styles retain their original file name
240
- test: /\.(?:css|scss|sass|less|styl)$/,
241
- parallel: environment_options_1.maxWorkers,
242
- minify: [CssMinimizerPlugin.cssnanoMinify],
243
- minimizerOptions: {
244
- preset: [
245
- 'default',
246
- {
247
- // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.
248
- svgo: false,
249
- // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890
250
- calc: false,
251
- // 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
252
- cssDeclarationSorter: false,
253
- },
254
- ],
255
- },
256
- }));
257
- }
258
236
  if (scriptsOptimization) {
259
237
  const TerserPlugin = require('terser-webpack-plugin');
260
238
  const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, } = require('@angular/compiler-cli');
@@ -12,6 +12,7 @@ const fs = require("fs");
12
12
  const path = require("path");
13
13
  const sass_service_1 = require("../../sass/sass-service");
14
14
  const build_browser_features_1 = require("../../utils/build-browser-features");
15
+ const environment_options_1 = require("../../utils/environment-options");
15
16
  const plugins_1 = require("../plugins");
16
17
  const helpers_1 = require("../utils/helpers");
17
18
  function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
@@ -116,6 +117,11 @@ function getStylesConfig(wco) {
116
117
  }
117
118
  }
118
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
+ });
119
125
  const postcssOptionsCreator = (inlineSourcemaps, extracted) => {
120
126
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
121
127
  const optionGenerator = (loader) => ({
@@ -151,11 +157,7 @@ function getStylesConfig(wco) {
151
157
  extracted,
152
158
  }),
153
159
  ...extraPostcssPlugins,
154
- postcssPresetEnv({
155
- browsers: supportedBrowsers,
156
- autoprefixer: true,
157
- stage: 3,
158
- }),
160
+ postcssPresetEnvPlugin,
159
161
  ],
160
162
  });
161
163
  // postcss-loader fails when trying to determine configuration files for data URIs
@@ -343,11 +345,46 @@ function getStylesConfig(wco) {
343
345
  ],
344
346
  });
345
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
+ }
346
380
  return {
347
381
  entry: entryPoints,
348
382
  module: {
349
383
  rules: [...fileLanguageRules, ...inlineLanguageRules],
350
384
  },
385
+ optimization: {
386
+ minimizer: extraMinimizers,
387
+ },
351
388
  plugins: extraPlugins,
352
389
  };
353
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),
@@ -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) {