@angular-devkit/build-angular 14.0.0-next.1 → 14.0.0-next.12

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.
Files changed (95) hide show
  1. package/README.md +10 -10
  2. package/builders.json +5 -0
  3. package/package.json +33 -34
  4. package/src/babel/plugins/pure-toplevel-functions.js +5 -1
  5. package/src/babel/presets/application.js +5 -1
  6. package/src/babel/webpack-loader.d.ts +1 -0
  7. package/src/babel/webpack-loader.js +2 -0
  8. package/src/builders/app-shell/index.js +8 -4
  9. package/src/builders/app-shell/schema.d.ts +2 -2
  10. package/src/builders/app-shell/schema.json +2 -2
  11. package/src/builders/browser/index.d.ts +2 -3
  12. package/src/builders/browser/index.js +13 -10
  13. package/src/builders/browser/schema.d.ts +0 -1
  14. package/src/builders/browser/schema.json +2 -3
  15. package/src/builders/browser-esbuild/compiler-plugin.d.ts +14 -0
  16. package/src/builders/browser-esbuild/compiler-plugin.js +338 -0
  17. package/src/builders/browser-esbuild/esbuild.d.ts +34 -0
  18. package/src/builders/browser-esbuild/esbuild.js +59 -0
  19. package/src/builders/browser-esbuild/experimental-warnings.d.ts +10 -0
  20. package/src/builders/browser-esbuild/experimental-warnings.js +65 -0
  21. package/src/builders/browser-esbuild/index.d.ts +19 -0
  22. package/src/builders/browser-esbuild/index.js +258 -0
  23. package/src/builders/browser-esbuild/options.d.ts +34 -0
  24. package/src/builders/browser-esbuild/options.js +87 -0
  25. package/src/builders/browser-esbuild/stylesheets.d.ts +52 -0
  26. package/src/builders/browser-esbuild/stylesheets.js +118 -0
  27. package/src/builders/dev-server/index.d.ts +1 -1
  28. package/src/builders/dev-server/index.js +5 -1
  29. package/src/builders/dev-server/schema.d.ts +1 -1
  30. package/src/builders/dev-server/schema.json +1 -1
  31. package/src/builders/extract-i18n/index.d.ts +1 -1
  32. package/src/builders/extract-i18n/index.js +5 -1
  33. package/src/builders/extract-i18n/ivy-extract-loader.js +5 -1
  34. package/src/builders/karma/find-tests.js +5 -1
  35. package/src/builders/karma/index.d.ts +1 -1
  36. package/src/builders/karma/index.js +10 -6
  37. package/src/builders/ng-packagr/index.js +5 -1
  38. package/src/builders/protractor/index.d.ts +2 -1
  39. package/src/builders/protractor/index.js +5 -1
  40. package/src/builders/server/index.d.ts +2 -3
  41. package/src/builders/server/index.js +5 -1
  42. package/src/builders/server/schema.json +1 -2
  43. package/src/index.js +5 -1
  44. package/src/typings.d.ts +0 -4
  45. package/src/utils/check-port.js +8 -4
  46. package/src/utils/color.js +5 -1
  47. package/src/utils/copy-assets.js +5 -1
  48. package/src/utils/delete-output-dir.js +6 -9
  49. package/src/utils/environment-options.d.ts +0 -1
  50. package/src/utils/environment-options.js +1 -13
  51. package/src/utils/i18n-inlining.js +5 -1
  52. package/src/utils/i18n-options.js +1 -8
  53. package/src/utils/index-file/html-rewriting-stream.js +5 -1
  54. package/src/utils/index-file/index-html-generator.js +5 -1
  55. package/src/utils/index-file/inline-critical-css.js +5 -1
  56. package/src/utils/index-file/inline-fonts.js +5 -1
  57. package/src/utils/index.js +5 -1
  58. package/src/utils/load-translations.js +5 -1
  59. package/src/utils/normalize-asset-patterns.d.ts +2 -2
  60. package/src/utils/normalize-asset-patterns.js +34 -10
  61. package/src/utils/normalize-builder-schema.d.ts +2 -2
  62. package/src/utils/normalize-builder-schema.js +5 -6
  63. package/src/utils/normalize-cache.js +0 -4
  64. package/src/utils/normalize-file-replacements.d.ts +4 -4
  65. package/src/utils/normalize-file-replacements.js +38 -18
  66. package/src/utils/process-bundle.js +6 -2
  67. package/src/utils/purge-cache.js +3 -8
  68. package/src/utils/read-tsconfig.js +5 -1
  69. package/src/utils/service-worker.d.ts +1 -2
  70. package/src/utils/service-worker.js +14 -12
  71. package/src/utils/webpack-browser-config.js +14 -12
  72. package/src/webpack/configs/analytics.js +1 -4
  73. package/src/webpack/configs/common.js +10 -12
  74. package/src/webpack/configs/dev-server.js +6 -2
  75. package/src/webpack/configs/index.js +5 -1
  76. package/src/webpack/configs/styles.d.ts +6 -0
  77. package/src/webpack/configs/styles.js +16 -22
  78. package/src/webpack/plugins/analytics.d.ts +1 -2
  79. package/src/webpack/plugins/analytics.js +1 -3
  80. package/src/webpack/plugins/any-component-style-budget-checker.js +5 -1
  81. package/src/webpack/plugins/common-js-usage-warn-plugin.js +2 -2
  82. package/src/webpack/plugins/css-optimizer-plugin.js +7 -3
  83. package/src/webpack/plugins/esbuild-executor.d.ts +2 -2
  84. package/src/webpack/plugins/esbuild-executor.js +11 -17
  85. package/src/webpack/plugins/javascript-optimizer-plugin.js +8 -4
  86. package/src/webpack/plugins/json-stats-plugin.js +5 -1
  87. package/src/webpack/plugins/karma/karma.js +11 -27
  88. package/src/webpack/plugins/named-chunks-plugin.js +9 -0
  89. package/src/webpack/plugins/postcss-cli-resources.js +7 -3
  90. package/src/webpack/plugins/scripts-webpack-plugin.js +5 -1
  91. package/src/webpack/plugins/transfer-size-plugin.js +3 -2
  92. package/src/webpack/plugins/typescript.js +1 -2
  93. package/src/webpack/utils/helpers.js +5 -1
  94. package/src/webpack/utils/stats.js +5 -1
  95. package/esbuild-check.js +0 -16
@@ -6,27 +6,51 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
9
32
  Object.defineProperty(exports, "__esModule", { value: true });
10
33
  exports.normalizeFileReplacements = exports.MissingFileReplacementException = void 0;
11
34
  const core_1 = require("@angular-devkit/core");
12
35
  const fs_1 = require("fs");
36
+ const path = __importStar(require("path"));
13
37
  class MissingFileReplacementException extends core_1.BaseException {
14
38
  constructor(path) {
15
39
  super(`The ${path} path in file replacements does not exist.`);
16
40
  }
17
41
  }
18
42
  exports.MissingFileReplacementException = MissingFileReplacementException;
19
- function normalizeFileReplacements(fileReplacements, root) {
43
+ function normalizeFileReplacements(fileReplacements, workspaceRoot) {
20
44
  if (fileReplacements.length === 0) {
21
45
  return [];
22
46
  }
23
- const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement, root));
47
+ const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement, workspaceRoot));
24
48
  for (const { replace, with: replacementWith } of normalizedReplacement) {
25
- if (!(0, fs_1.existsSync)((0, core_1.getSystemPath)(replacementWith))) {
26
- throw new MissingFileReplacementException((0, core_1.getSystemPath)(replacementWith));
49
+ if (!(0, fs_1.existsSync)(replacementWith)) {
50
+ throw new MissingFileReplacementException(replacementWith);
27
51
  }
28
- if (!(0, fs_1.existsSync)((0, core_1.getSystemPath)(replace))) {
29
- throw new MissingFileReplacementException((0, core_1.getSystemPath)(replace));
52
+ if (!(0, fs_1.existsSync)(replace)) {
53
+ throw new MissingFileReplacementException(replace);
30
54
  }
31
55
  }
32
56
  return normalizedReplacement;
@@ -36,22 +60,18 @@ function normalizeFileReplacement(fileReplacement, root) {
36
60
  let replacePath;
37
61
  let withPath;
38
62
  if (fileReplacement.src && fileReplacement.replaceWith) {
39
- replacePath = (0, core_1.normalize)(fileReplacement.src);
40
- withPath = (0, core_1.normalize)(fileReplacement.replaceWith);
63
+ replacePath = fileReplacement.src;
64
+ withPath = fileReplacement.replaceWith;
41
65
  }
42
66
  else if (fileReplacement.replace && fileReplacement.with) {
43
- replacePath = (0, core_1.normalize)(fileReplacement.replace);
44
- withPath = (0, core_1.normalize)(fileReplacement.with);
67
+ replacePath = fileReplacement.replace;
68
+ withPath = fileReplacement.with;
45
69
  }
46
70
  else {
47
71
  throw new Error(`Invalid file replacement: ${JSON.stringify(fileReplacement)}`);
48
72
  }
49
- // TODO: For 7.x should this only happen if not absolute?
50
- if (root) {
51
- replacePath = (0, core_1.join)(root, replacePath);
52
- }
53
- if (root) {
54
- withPath = (0, core_1.join)(root, withPath);
55
- }
56
- return { replace: replacePath, with: withPath };
73
+ return {
74
+ replace: path.join(root, replacePath),
75
+ with: path.join(root, withPath),
76
+ };
57
77
  }
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -125,7 +129,7 @@ async function inlineLocales(options) {
125
129
  // Same errors will contain the full content of the file as the error message
126
130
  // Which makes it hard to find the actual error message.
127
131
  const index = error.message.indexOf(')\n');
128
- const msg = index !== -1 ? error.message.substr(0, index + 1) : error.message;
132
+ const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
129
133
  throw new Error(`${msg}\nAn error occurred inlining file "${options.filename}"`);
130
134
  }
131
135
  }
@@ -23,18 +23,13 @@ async function purgeStaleBuildCache(context) {
23
23
  if (!enabled || !(0, fs_1.existsSync)(basePath)) {
24
24
  return;
25
25
  }
26
- // The below should be removed and replaced with just `rm` when support for Node.Js 12 is removed.
27
- const { rm, rmdir } = fs_1.promises;
28
26
  const entriesToDelete = (await fs_1.promises.readdir(basePath, { withFileTypes: true }))
29
27
  .filter((d) => (0, path_1.join)(basePath, d.name) !== path && d.isDirectory())
30
28
  .map((d) => {
31
29
  const subPath = (0, path_1.join)(basePath, d.name);
32
- try {
33
- return rm
34
- ? rm(subPath, { force: true, recursive: true, maxRetries: 3 })
35
- : rmdir(subPath, { recursive: true, maxRetries: 3 });
36
- }
37
- catch { }
30
+ return fs_1.promises
31
+ .rm(subPath, { force: true, recursive: true, maxRetries: 3 })
32
+ .catch(() => void 0);
38
33
  });
39
34
  await Promise.all(entriesToDelete);
40
35
  }
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -5,5 +5,4 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Path } from '@angular-devkit/core';
9
- export declare function augmentAppWithServiceWorker(appRoot: Path, outputPath: Path, baseHref: string, ngswConfigPath?: string): Promise<void>;
8
+ export declare function augmentAppWithServiceWorker(appRoot: string, workspaceRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string): Promise<void>;
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -27,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
27
31
  };
28
32
  Object.defineProperty(exports, "__esModule", { value: true });
29
33
  exports.augmentAppWithServiceWorker = void 0;
30
- const core_1 = require("@angular-devkit/core");
31
34
  const crypto = __importStar(require("crypto"));
32
35
  const fs_1 = require("fs");
33
36
  const path = __importStar(require("path"));
@@ -72,12 +75,11 @@ class CliFilesystem {
72
75
  return items;
73
76
  }
74
77
  }
75
- async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswConfigPath) {
76
- const distPath = (0, core_1.getSystemPath)((0, core_1.normalize)(outputPath));
78
+ async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, baseHref, ngswConfigPath) {
77
79
  // Determine the configuration file path
78
80
  const configPath = ngswConfigPath
79
- ? (0, core_1.getSystemPath)((0, core_1.normalize)(ngswConfigPath))
80
- : path.join((0, core_1.getSystemPath)(appRoot), 'ngsw-config.json');
81
+ ? path.join(workspaceRoot, ngswConfigPath)
82
+ : path.join(appRoot, 'ngsw-config.json');
81
83
  // Read the configuration file
82
84
  let config;
83
85
  try {
@@ -87,7 +89,7 @@ async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswCo
87
89
  catch (error) {
88
90
  if (error.code === 'ENOENT') {
89
91
  throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
90
- ` in the ${(0, core_1.getSystemPath)(appRoot)} folder. Either provide one or` +
92
+ ` in the ${appRoot} folder. Either provide one or` +
91
93
  ' disable Service Worker in the angular.json configuration file.');
92
94
  }
93
95
  else {
@@ -99,20 +101,20 @@ async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswCo
99
101
  // changed to a direct dynamic import.
100
102
  const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)('@angular/service-worker/config')).Generator;
101
103
  // Generate the manifest
102
- const generator = new GeneratorConstructor(new CliFilesystem(distPath), baseHref);
104
+ const generator = new GeneratorConstructor(new CliFilesystem(outputPath), baseHref);
103
105
  const output = await generator.process(config);
104
106
  // Write the manifest
105
107
  const manifest = JSON.stringify(output, null, 2);
106
- await fs_1.promises.writeFile(path.join(distPath, 'ngsw.json'), manifest);
108
+ await fs_1.promises.writeFile(path.join(outputPath, 'ngsw.json'), manifest);
107
109
  // Find the service worker package
108
110
  const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js');
109
111
  // Write the worker code
110
- await fs_1.promises.copyFile(workerPath, path.join(distPath, 'ngsw-worker.js'), fs_1.constants.COPYFILE_FICLONE);
112
+ await fs_1.promises.copyFile(workerPath, path.join(outputPath, 'ngsw-worker.js'), fs_1.constants.COPYFILE_FICLONE);
111
113
  // If present, write the safety worker code
112
114
  const safetyPath = path.join(path.dirname(workerPath), 'safety-worker.js');
113
115
  try {
114
- await fs_1.promises.copyFile(safetyPath, path.join(distPath, 'worker-basic.min.js'), fs_1.constants.COPYFILE_FICLONE);
115
- await fs_1.promises.copyFile(safetyPath, path.join(distPath, 'safety-worker.js'), fs_1.constants.COPYFILE_FICLONE);
116
+ await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'worker-basic.min.js'), fs_1.constants.COPYFILE_FICLONE);
117
+ await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'safety-worker.js'), fs_1.constants.COPYFILE_FICLONE);
116
118
  }
117
119
  catch (error) {
118
120
  if (error.code !== 'ENOENT') {
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -27,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
27
31
  };
28
32
  Object.defineProperty(exports, "__esModule", { value: true });
29
33
  exports.getIndexInputFile = exports.getIndexOutputFile = exports.generateBrowserWebpackConfigFromContext = exports.generateI18nBrowserWebpackConfigFromContext = exports.generateWebpackConfig = void 0;
30
- const core_1 = require("@angular-devkit/core");
31
34
  const path = __importStar(require("path"));
32
35
  const typescript_1 = require("typescript");
33
36
  const webpack_1 = require("webpack");
@@ -108,19 +111,18 @@ async function generateI18nBrowserWebpackConfigFromContext(options, context, web
108
111
  }
109
112
  exports.generateI18nBrowserWebpackConfigFromContext = generateI18nBrowserWebpackConfigFromContext;
110
113
  async function generateBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, extraBuildOptions = {}) {
114
+ var _a;
111
115
  const projectName = context.target && context.target.project;
112
116
  if (!projectName) {
113
117
  throw new Error('The builder requires a target.');
114
118
  }
115
- const workspaceRoot = (0, core_1.normalize)(context.workspaceRoot);
119
+ const workspaceRoot = context.workspaceRoot;
116
120
  const projectMetadata = await context.getProjectMetadata(projectName);
117
- const projectRoot = (0, core_1.resolve)(workspaceRoot, (0, core_1.normalize)(projectMetadata.root || ''));
118
- const projectSourceRoot = projectMetadata.sourceRoot;
119
- const sourceRoot = projectSourceRoot
120
- ? (0, core_1.resolve)(workspaceRoot, (0, core_1.normalize)(projectSourceRoot))
121
- : undefined;
122
- const normalizedOptions = (0, utils_1.normalizeBrowserSchema)(workspaceRoot, projectRoot, sourceRoot, options, projectMetadata);
123
- const config = await generateWebpackConfig((0, core_1.getSystemPath)(workspaceRoot), (0, core_1.getSystemPath)(projectRoot), sourceRoot && (0, core_1.getSystemPath)(sourceRoot), projectName, normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
121
+ const projectRoot = path.join(workspaceRoot, (_a = projectMetadata.root) !== null && _a !== void 0 ? _a : '');
122
+ const sourceRoot = projectMetadata.sourceRoot;
123
+ const projectSourceRoot = sourceRoot ? path.join(workspaceRoot, sourceRoot) : undefined;
124
+ const normalizedOptions = (0, utils_1.normalizeBrowserSchema)(workspaceRoot, projectRoot, projectSourceRoot, options, projectMetadata);
125
+ const config = await generateWebpackConfig(workspaceRoot, projectRoot, projectSourceRoot, projectName, normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
124
126
  // If builder watch support is present in the context, add watch plugin
125
127
  // This is internal only and currently only used for testing
126
128
  const watcherFactory = context.watcherFactory;
@@ -132,8 +134,8 @@ async function generateBrowserWebpackConfigFromContext(options, context, webpack
132
134
  }
133
135
  return {
134
136
  config,
135
- projectRoot: (0, core_1.getSystemPath)(projectRoot),
136
- projectSourceRoot: sourceRoot && (0, core_1.getSystemPath)(sourceRoot),
137
+ projectRoot,
138
+ projectSourceRoot,
137
139
  };
138
140
  }
139
141
  exports.generateBrowserWebpackConfigFromContext = generateBrowserWebpackConfigFromContext;
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getAnalyticsConfig = void 0;
11
11
  const analytics_1 = require("../plugins/analytics");
12
12
  function getAnalyticsConfig(wco, context) {
13
- var _a;
14
13
  if (!context.analytics) {
15
14
  return {};
16
15
  }
@@ -22,9 +21,7 @@ function getAnalyticsConfig(wco, context) {
22
21
  }
23
22
  // The category is the builder name if it's an angular builder.
24
23
  return {
25
- plugins: [
26
- new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category, (_a = wco.buildOptions.aot) !== null && _a !== void 0 ? _a : false),
27
- ],
24
+ plugins: [new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category)],
28
25
  };
29
26
  }
30
27
  exports.getAnalyticsConfig = getAnalyticsConfig;
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -80,15 +84,6 @@ async function getCommonConfig(wco) {
80
84
  entryPoints['polyfills'] = [projectPolyfills];
81
85
  }
82
86
  }
83
- if (!buildOptions.aot) {
84
- const jitPolyfills = require.resolve('core-js/proposals/reflect-metadata');
85
- if (entryPoints['polyfills']) {
86
- entryPoints['polyfills'].push(jitPolyfills);
87
- }
88
- else {
89
- entryPoints['polyfills'] = [jitPolyfills];
90
- }
91
- }
92
87
  }
93
88
  if (allowedCommonJsDependencies) {
94
89
  // When this is not defined it means the builder doesn't support showing common js usages.
@@ -179,7 +174,9 @@ async function getCommonConfig(wco) {
179
174
  test: tsConfig.options.allowJs ? /\.[cm]?[tj]sx?$/ : /\.[cm]?tsx?$/,
180
175
  loader: webpack_1.AngularWebpackLoaderPath,
181
176
  // The below are known paths that are not part of the TypeScript compilation even when allowJs is enabled.
182
- exclude: [/[/\\](?:css-loader|mini-css-extract-plugin|webpack-dev-server|webpack)[/\\]/],
177
+ exclude: [
178
+ /[\\/]node_modules[/\\](?:css-loader|mini-css-extract-plugin|webpack-dev-server|webpack)[/\\]/,
179
+ ],
183
180
  });
184
181
  extraPlugins.push((0, typescript_2.createIvyPlugin)(wco, aot, tsConfigPath));
185
182
  }
@@ -293,7 +290,7 @@ async function getCommonConfig(wco) {
293
290
  // The below is needed due to a bug in `@babel/runtime`. See: https://github.com/babel/babel/issues/12824
294
291
  resolve: { fullySpecified: false },
295
292
  exclude: [
296
- /[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill|whatwg-url)[/\\]/,
293
+ /[\\/]node_modules[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill|whatwg-url)[/\\]/,
297
294
  ],
298
295
  use: [
299
296
  {
@@ -322,6 +319,7 @@ async function getCommonConfig(wco) {
322
319
  asyncWebAssembly: true,
323
320
  },
324
321
  infrastructureLogging: {
322
+ debug: verbose,
325
323
  level: verbose ? 'verbose' : 'error',
326
324
  },
327
325
  stats: (0, helpers_1.getStatsOptions)(verbose),
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -114,7 +118,7 @@ function buildServePath(options, logger) {
114
118
  servePath = defaultPath || '';
115
119
  }
116
120
  if (servePath.endsWith('/')) {
117
- servePath = servePath.substr(0, servePath.length - 1);
121
+ servePath = servePath.slice(0, -1);
118
122
  }
119
123
  if (!servePath.startsWith('/')) {
120
124
  servePath = `/${servePath}`;
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -6,5 +6,11 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Configuration } from 'webpack';
9
+ import { StyleElement } from '../../builders/browser/schema';
9
10
  import { WebpackConfigOptions } from '../../utils/build-options';
11
+ export declare function resolveGlobalStyles(styleEntrypoints: StyleElement[], root: string, preserveSymlinks: boolean): {
12
+ entryPoints: Record<string, string[]>;
13
+ noInjectNames: string[];
14
+ paths: string[];
15
+ };
10
16
  export declare function getStylesConfig(wco: WebpackConfigOptions): Configuration;
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -29,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
34
  };
31
35
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.getStylesConfig = void 0;
36
+ exports.getStylesConfig = exports.resolveGlobalStyles = void 0;
33
37
  const fs = __importStar(require("fs"));
34
38
  const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
35
39
  const path = __importStar(require("path"));
@@ -71,6 +75,7 @@ function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
71
75
  }
72
76
  return { entryPoints, noInjectNames, paths };
73
77
  }
78
+ exports.resolveGlobalStyles = resolveGlobalStyles;
74
79
  // eslint-disable-next-line max-lines-per-function
75
80
  function getStylesConfig(wco) {
76
81
  var _a, _b, _c;
@@ -94,16 +99,14 @@ function getStylesConfig(wco) {
94
99
  wco.logger.warn('Stylus usage is deprecated and will be removed in a future major version. ' +
95
100
  'To opt-out of the deprecated behaviour, please migrate to another stylesheet language.');
96
101
  }
97
- const sassImplementation = getSassImplementation();
98
- if (sassImplementation instanceof sass_service_1.SassWorkerImplementation) {
99
- extraPlugins.push({
100
- apply(compiler) {
101
- compiler.hooks.shutdown.tap('sass-worker', () => {
102
- sassImplementation === null || sassImplementation === void 0 ? void 0 : sassImplementation.close();
103
- });
104
- },
105
- });
106
- }
102
+ const sassImplementation = new sass_service_1.SassWorkerImplementation();
103
+ extraPlugins.push({
104
+ apply(compiler) {
105
+ compiler.hooks.shutdown.tap('sass-worker', () => {
106
+ sassImplementation.close();
107
+ });
108
+ },
109
+ });
107
110
  const assetNameTemplate = (0, helpers_1.assetNameTemplateFactory)(hashFormat);
108
111
  const extraPostcssPlugins = [];
109
112
  // Attempt to setup Tailwind CSS
@@ -151,7 +154,7 @@ function getStylesConfig(wco) {
151
154
  : undefined,
152
155
  plugins: [
153
156
  postcssImports({
154
- resolve: (url) => (url.startsWith('~') ? url.substr(1) : url),
157
+ resolve: (url) => (url.startsWith('~') ? url.slice(1) : url),
155
158
  load: (filename) => {
156
159
  return new Promise((resolve, reject) => {
157
160
  loader.fs.readFile(filename, (err, data) => {
@@ -371,12 +374,3 @@ function getStylesConfig(wco) {
371
374
  };
372
375
  }
373
376
  exports.getStylesConfig = getStylesConfig;
374
- function getSassImplementation() {
375
- const { webcontainer } = process.versions;
376
- // When `webcontainer` is a truthy it means that we are running in a StackBlitz webcontainer.
377
- // `SassWorkerImplementation` uses `receiveMessageOnPort` Node.js `worker_thread` API to ensure sync behavior which is ~2x faster.
378
- // However, it is non trivial to support this in a webcontainer and while slower we choose to use `dart-sass`
379
- // which in Webpack uses the slower async path.
380
- // We should periodically check with StackBlitz folks (Mark Whitfeld / Dominic Elm) to determine if this workaround is still needed.
381
- return webcontainer ? require('sass') : new sass_service_1.SassWorkerImplementation();
382
- }
@@ -40,10 +40,9 @@ export declare class NgBuildAnalyticsPlugin {
40
40
  protected _projectRoot: string;
41
41
  protected _analytics: analytics.Analytics;
42
42
  protected _category: string;
43
- private aotEnabled;
44
43
  protected _built: boolean;
45
44
  protected _stats: AnalyticsBuildStats;
46
- constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string, aotEnabled: boolean);
45
+ constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string);
47
46
  protected _reset(): void;
48
47
  protected _getMetrics(stats: Stats): (string | number)[];
49
48
  protected _getDimensions(): (string | number | boolean)[];
@@ -73,11 +73,10 @@ class AnalyticsBuildStats {
73
73
  * Analytics plugin that reports the analytics we want from the CLI.
74
74
  */
75
75
  class NgBuildAnalyticsPlugin {
76
- constructor(_projectRoot, _analytics, _category, aotEnabled) {
76
+ constructor(_projectRoot, _analytics, _category) {
77
77
  this._projectRoot = _projectRoot;
78
78
  this._analytics = _analytics;
79
79
  this._category = _category;
80
- this.aotEnabled = aotEnabled;
81
80
  this._built = false;
82
81
  this._stats = new AnalyticsBuildStats();
83
82
  }
@@ -108,7 +107,6 @@ class NgBuildAnalyticsPlugin {
108
107
  // Adding commas before and after so the regex are easier to define filters.
109
108
  dimensions[core_1.analytics.NgCliAnalyticsDimensions.BuildErrors] = `,${this._stats.errors.join()},`;
110
109
  }
111
- dimensions[core_1.analytics.NgCliAnalyticsDimensions.AotEnabled] = this.aotEnabled;
112
110
  return dimensions;
113
111
  }
114
112
  _reportBuildMetrics(stats) {
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -22,7 +22,7 @@ class CommonJsUsageWarnPlugin {
22
22
  apply(compiler) {
23
23
  compiler.hooks.compilation.tap('CommonJsUsageWarnPlugin', (compilation) => {
24
24
  compilation.hooks.finishModules.tap('CommonJsUsageWarnPlugin', (modules) => {
25
- var _a, _b;
25
+ var _a;
26
26
  const mainEntry = compilation.entries.get('main');
27
27
  if (!mainEntry) {
28
28
  return;
@@ -65,7 +65,7 @@ class CommonJsUsageWarnPlugin {
65
65
  // And if the issuer request is not from 'webpack-dev-server', as 'webpack-dev-server'
66
66
  // will require CommonJS libraries for live reloading such as 'sockjs-node'.
67
67
  if (mainIssuer && mainModules.has(mainIssuer)) {
68
- const warning = `${(_b = issuer) === null || _b === void 0 ? void 0 : _b.userRequest} depends on '${rawRequest}'. ` +
68
+ const warning = `${issuer === null || issuer === void 0 ? void 0 : issuer.userRequest} depends on '${rawRequest}'. ` +
69
69
  'CommonJS or AMD dependencies can cause optimization bailouts.\n' +
70
70
  'For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies';
71
71
  // Avoid showing the same warning multiple times when in 'watch' mode.
@@ -52,9 +52,10 @@ class CssOptimizerPlugin {
52
52
  const cachedOutput = await cacheItem.getPromise();
53
53
  if (cachedOutput) {
54
54
  await this.addWarnings(compilation, cachedOutput.warnings);
55
- compilation.updateAsset(name, cachedOutput.source, {
55
+ compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
56
+ ...assetInfo,
56
57
  minimized: true,
57
- });
58
+ }));
58
59
  continue;
59
60
  }
60
61
  }
@@ -65,7 +66,10 @@ class CssOptimizerPlugin {
65
66
  const optimizedAsset = map
66
67
  ? new SourceMapSource(code, name, map)
67
68
  : new OriginalSource(code, name);
68
- compilation.updateAsset(name, optimizedAsset, { minimized: true });
69
+ compilation.updateAsset(name, optimizedAsset, (assetInfo) => ({
70
+ ...assetInfo,
71
+ minimized: true,
72
+ }));
69
73
  await (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.storePromise({
70
74
  source: optimizedAsset,
71
75
  warnings,
@@ -28,9 +28,9 @@ export declare class EsbuildExecutor implements Pick<typeof import('esbuild'), '
28
28
  /**
29
29
  * Determines whether the native variant of esbuild can be used on the current platform.
30
30
  *
31
- * @returns True, if the native variant of esbuild is support; False, if the WASM variant is required.
31
+ * @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
32
32
  */
33
- static hasNativeSupport(): boolean;
33
+ static hasNativeSupport(): Promise<boolean>;
34
34
  /**
35
35
  * Initializes the esbuild transform and format messages functions.
36
36
  *