@angular-devkit/build-angular 13.0.0-next.6 → 13.0.0-next.7

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 (68) hide show
  1. package/package.json +14 -14
  2. package/src/babel/plugins/adjust-static-class-members.js +2 -2
  3. package/src/babel/plugins/adjust-typescript-enums.js +8 -2
  4. package/src/babel/plugins/pure-toplevel-functions.js +2 -2
  5. package/src/babel/presets/application.d.ts +14 -0
  6. package/src/babel/presets/application.js +42 -36
  7. package/src/babel/webpack-loader.js +50 -5
  8. package/src/builders/app-shell/index.js +9 -9
  9. package/src/builders/browser/index.js +42 -52
  10. package/src/builders/dev-server/index.js +23 -23
  11. package/src/builders/extract-i18n/index.js +33 -21
  12. package/src/builders/extract-i18n/ivy-extract-loader.js +34 -8
  13. package/src/builders/karma/find-tests.js +5 -5
  14. package/src/builders/karma/index.js +14 -14
  15. package/src/builders/ng-packagr/index.js +4 -4
  16. package/src/builders/protractor/index.js +4 -4
  17. package/src/builders/server/index.js +16 -16
  18. package/src/sass/worker.js +2 -2
  19. package/src/utils/build-browser-features.js +2 -2
  20. package/src/utils/bundle-calculator.js +4 -4
  21. package/src/utils/cache-path.js +2 -2
  22. package/src/utils/check-port.js +1 -1
  23. package/src/utils/copy-assets.js +1 -1
  24. package/src/utils/delete-output-dir.js +1 -1
  25. package/src/utils/i18n-inlining.js +1 -1
  26. package/src/utils/i18n-options.js +26 -50
  27. package/src/utils/index-file/augment-index-html.js +2 -2
  28. package/src/utils/index-file/index-html-generator.js +3 -3
  29. package/src/utils/index-file/inline-fonts.js +4 -4
  30. package/src/utils/load-esm.d.ts +22 -0
  31. package/src/utils/load-esm.js +37 -0
  32. package/src/utils/load-translations.js +21 -8
  33. package/src/utils/normalize-asset-patterns.js +8 -8
  34. package/src/utils/normalize-builder-schema.js +4 -4
  35. package/src/utils/normalize-file-replacements.js +10 -10
  36. package/src/utils/output-paths.js +3 -3
  37. package/src/utils/package-chunk-sort.js +1 -1
  38. package/src/utils/process-bundle.d.ts +0 -1
  39. package/src/utils/process-bundle.js +44 -12
  40. package/src/utils/read-tsconfig.js +6 -8
  41. package/src/utils/run-module-as-observable-fork.js +2 -2
  42. package/src/utils/service-worker.js +16 -9
  43. package/src/utils/spinner.js +2 -2
  44. package/src/utils/version.js +1 -1
  45. package/src/utils/webpack-browser-config.js +11 -11
  46. package/src/webpack/configs/browser.js +1 -1
  47. package/src/webpack/configs/common.js +16 -17
  48. package/src/webpack/configs/dev-server.d.ts +1 -1
  49. package/src/webpack/configs/dev-server.js +22 -10
  50. package/src/webpack/configs/server.js +2 -2
  51. package/src/webpack/configs/styles.js +4 -4
  52. package/src/webpack/configs/test.js +2 -2
  53. package/src/webpack/configs/typescript.js +1 -1
  54. package/src/webpack/configs/worker.js +1 -1
  55. package/src/webpack/plugins/any-component-style-budget-checker.js +4 -4
  56. package/src/webpack/plugins/common-js-usage-warn-plugin.js +2 -2
  57. package/src/webpack/plugins/css-optimizer-plugin.js +1 -1
  58. package/src/webpack/plugins/dedupe-module-resolve-plugin.js +1 -1
  59. package/src/webpack/plugins/esbuild-executor.js +1 -1
  60. package/src/webpack/plugins/hmr/hmr-accept.js +3 -3
  61. package/src/webpack/plugins/hmr/hmr-loader.js +1 -1
  62. package/src/webpack/plugins/index-html-webpack-plugin.js +6 -6
  63. package/src/webpack/plugins/javascript-optimizer-worker.js +2 -2
  64. package/src/webpack/plugins/karma/karma.js +4 -4
  65. package/src/webpack/plugins/postcss-cli-resources.js +1 -1
  66. package/src/webpack/plugins/scripts-webpack-plugin.js +1 -1
  67. package/src/webpack/plugins/single-test-transform.js +1 -1
  68. package/src/webpack/utils/stats.js +6 -6
@@ -20,7 +20,7 @@ function getServerConfig(wco) {
20
20
  const extraPlugins = [];
21
21
  const { scripts, styles, hidden } = sourceMap;
22
22
  if (scripts || styles) {
23
- extraPlugins.push(helpers_1.getSourceMapDevTool(scripts, styles, hidden));
23
+ extraPlugins.push((0, helpers_1.getSourceMapDevTool)(scripts, styles, hidden));
24
24
  }
25
25
  const externals = [...externalDependencies];
26
26
  if (!bundleDependencies) {
@@ -58,7 +58,7 @@ function externalizePackages(context, request, callback) {
58
58
  return;
59
59
  }
60
60
  // Absolute & Relative paths are not externals
61
- if (request.startsWith('.') || path_1.isAbsolute(request)) {
61
+ if (request.startsWith('.') || (0, path_1.isAbsolute)(request)) {
62
62
  callback();
63
63
  return;
64
64
  }
@@ -41,7 +41,7 @@ function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
41
41
  if (styleEntrypoints.length === 0) {
42
42
  return { entryPoints, noInjectNames, paths };
43
43
  }
44
- for (const style of helpers_1.normalizeExtraEntryPoints(styleEntrypoints, 'styles')) {
44
+ for (const style of (0, helpers_1.normalizeExtraEntryPoints)(styleEntrypoints, 'styles')) {
45
45
  let resolvedPath = path.resolve(root, style.input);
46
46
  if (!fs.existsSync(resolvedPath)) {
47
47
  try {
@@ -79,7 +79,7 @@ function getStylesConfig(wco) {
79
79
  extraPlugins.push(new plugins_1.AnyComponentStyleBudgetChecker(buildOptions.budgets));
80
80
  const cssSourceMap = buildOptions.sourceMap.styles;
81
81
  // Determine hashing format.
82
- const hashFormat = helpers_1.getOutputHashFormat(buildOptions.outputHashing);
82
+ const hashFormat = (0, helpers_1.getOutputHashFormat)(buildOptions.outputHashing);
83
83
  // use includePaths from appConfig
84
84
  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 : [];
85
85
  // Process global styles.
@@ -100,7 +100,7 @@ function getStylesConfig(wco) {
100
100
  });
101
101
  },
102
102
  });
103
- const assetNameTemplate = helpers_1.assetNameTemplateFactory(hashFormat);
103
+ const assetNameTemplate = (0, helpers_1.assetNameTemplateFactory)(hashFormat);
104
104
  const extraPostcssPlugins = [];
105
105
  // Attempt to setup Tailwind CSS
106
106
  // A configuration file can exist in the project or workspace root
@@ -165,7 +165,7 @@ function getStylesConfig(wco) {
165
165
  });
166
166
  },
167
167
  }),
168
- plugins_1.PostcssCliResources({
168
+ (0, plugins_1.PostcssCliResources)({
169
169
  baseHref: buildOptions.baseHref,
170
170
  deployUrl: buildOptions.deployUrl,
171
171
  resourcesOutputPath: buildOptions.resourcesOutputPath,
@@ -54,7 +54,7 @@ function getTestConfig(wco) {
54
54
  });
55
55
  }
56
56
  if (sourceMap.scripts || sourceMap.styles) {
57
- extraPlugins.push(helpers_1.getSourceMapDevTool(sourceMap.scripts, sourceMap.styles, false, true));
57
+ extraPlugins.push((0, helpers_1.getSourceMapDevTool)(sourceMap.scripts, sourceMap.styles, false, true));
58
58
  }
59
59
  return {
60
60
  mode: 'development',
@@ -80,7 +80,7 @@ function getTestConfig(wco) {
80
80
  plugins: extraPlugins,
81
81
  optimization: {
82
82
  splitChunks: {
83
- chunks: (chunk) => !helpers_1.isPolyfillsEntry(chunk.name),
83
+ chunks: (chunk) => !(0, helpers_1.isPolyfillsEntry)(chunk.name),
84
84
  cacheGroups: {
85
85
  vendors: false,
86
86
  defaultVendors: {
@@ -41,7 +41,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
41
41
  const fileReplacements = {};
42
42
  if (buildOptions.fileReplacements) {
43
43
  for (const replacement of buildOptions.fileReplacements) {
44
- fileReplacements[core_1.getSystemPath(replacement.replace)] = core_1.getSystemPath(replacement.with);
44
+ fileReplacements[(0, core_1.getSystemPath)(replacement.replace)] = (0, core_1.getSystemPath)(replacement.with);
45
45
  }
46
46
  }
47
47
  let inlineStyleFileExtension;
@@ -16,7 +16,7 @@ function getWorkerConfig(wco) {
16
16
  return {};
17
17
  }
18
18
  return {
19
- plugins: [typescript_1.getTypescriptWorkerPlugin(wco, path_1.resolve(wco.root, webWorkerTsConfig))],
19
+ plugins: [(0, typescript_1.getTypescriptWorkerPlugin)(wco, (0, path_1.resolve)(wco.root, webWorkerTsConfig))],
20
20
  };
21
21
  }
22
22
  exports.getWorkerConfig = getWorkerConfig;
@@ -58,15 +58,15 @@ class AnyComponentStyleBudgetChecker {
58
58
  size: compilation.assets[name].size(),
59
59
  label: name,
60
60
  }));
61
- const thresholds = this.budgets.flatMap((budget) => [...bundle_calculator_1.calculateThresholds(budget)]);
61
+ const thresholds = this.budgets.flatMap((budget) => [...(0, bundle_calculator_1.calculateThresholds)(budget)]);
62
62
  for (const { size, label } of componentStyles) {
63
- for (const { severity, message } of bundle_calculator_1.checkThresholds(thresholds[Symbol.iterator](), size, label)) {
63
+ for (const { severity, message } of (0, bundle_calculator_1.checkThresholds)(thresholds[Symbol.iterator](), size, label)) {
64
64
  switch (severity) {
65
65
  case bundle_calculator_1.ThresholdSeverity.Warning:
66
- webpack_diagnostics_1.addWarning(compilation, message);
66
+ (0, webpack_diagnostics_1.addWarning)(compilation, message);
67
67
  break;
68
68
  case bundle_calculator_1.ThresholdSeverity.Error:
69
- webpack_diagnostics_1.addError(compilation, message);
69
+ (0, webpack_diagnostics_1.addError)(compilation, message);
70
70
  break;
71
71
  default:
72
72
  assertNever(severity);
@@ -32,7 +32,7 @@ class CommonJsUsageWarnPlugin {
32
32
  const { dependencies, rawRequest } = module;
33
33
  if (!rawRequest ||
34
34
  rawRequest.startsWith('.') ||
35
- path_1.isAbsolute(rawRequest) ||
35
+ (0, path_1.isAbsolute)(rawRequest) ||
36
36
  this.allowedDependencies.has(rawRequest) ||
37
37
  this.allowedDependencies.has(this.rawRequestToPackageName(rawRequest)) ||
38
38
  rawRequest.startsWith('@angular/common/locales/')) {
@@ -70,7 +70,7 @@ class CommonJsUsageWarnPlugin {
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.
72
72
  if (!this.shownWarnings.has(warning)) {
73
- webpack_diagnostics_1.addWarning(compilation, warning);
73
+ (0, webpack_diagnostics_1.addWarning)(compilation, warning);
74
74
  this.shownWarnings.add(warning);
75
75
  }
76
76
  }
@@ -102,7 +102,7 @@ class CssOptimizerPlugin {
102
102
  async addWarnings(compilation, warnings) {
103
103
  if (warnings.length > 0) {
104
104
  for (const warning of await this.esbuild.formatMessages(warnings, { kind: 'warning' })) {
105
- webpack_diagnostics_1.addWarning(compilation, warning);
105
+ (0, webpack_diagnostics_1.addWarning)(compilation, warning);
106
106
  }
107
107
  }
108
108
  }
@@ -62,7 +62,7 @@ class DedupeModuleResolvePlugin {
62
62
  return;
63
63
  }
64
64
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.verbose) {
65
- webpack_diagnostics_1.addWarning(compilation, `[DedupeModuleResolvePlugin]: ${resource} -> ${prevResource}`);
65
+ (0, webpack_diagnostics_1.addWarning)(compilation, `[DedupeModuleResolvePlugin]: ${resource} -> ${prevResource}`);
66
66
  }
67
67
  // Alter current request with previously resolved module.
68
68
  const createData = result.createData;
@@ -65,7 +65,7 @@ class EsbuildExecutor {
65
65
  // then the separate process spawn check can be removed in favor of a direct function
66
66
  // call check.
67
67
  try {
68
- const { status, error } = child_process_1.spawnSync(process.execPath, [
68
+ const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [
69
69
  path.join(__dirname, '../../../esbuild-check.js'),
70
70
  ]);
71
71
  return status === 0 && error === undefined;
@@ -14,7 +14,7 @@ function default_1(mod) {
14
14
  if (!mod['hot']) {
15
15
  return;
16
16
  }
17
- if (!core_1.isDevMode()) {
17
+ if (!(0, core_1.isDevMode)()) {
18
18
  console.error(`[NG HMR] Cannot use HMR when Angular is running in production mode. To prevent production mode, do not call 'enableProdMode()'.`);
19
19
  return;
20
20
  }
@@ -29,7 +29,7 @@ function default_1(mod) {
29
29
  return;
30
30
  }
31
31
  // Reset JIT compiled components cache
32
- core_1.ɵresetCompiledComponents();
32
+ (0, core_1.ɵresetCompiledComponents)();
33
33
  const appRoot = getAppRoot();
34
34
  if (!appRoot) {
35
35
  return;
@@ -72,7 +72,7 @@ function default_1(mod) {
72
72
  }
73
73
  // Wait until the application isStable to restore the form values
74
74
  newAppRef.isStable
75
- .pipe(operators_1.filter((isStable) => !!isStable), operators_1.take(1))
75
+ .pipe((0, operators_1.filter)((isStable) => !!isStable), (0, operators_1.take)(1))
76
76
  .subscribe(() => restoreFormValues(oldInputs, oldOptions));
77
77
  }).observe(bodyElement, {
78
78
  attributes: true,
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.HmrLoader = void 0;
11
11
  const path_1 = require("path");
12
12
  exports.HmrLoader = __filename;
13
- const hmrAcceptPath = path_1.join(__dirname, './hmr-accept.js').replace(/\\/g, '/');
13
+ const hmrAcceptPath = (0, path_1.join)(__dirname, './hmr-accept.js').replace(/\\/g, '/');
14
14
  function default_1(content,
15
15
  // Source map types are broken in the webpack type definitions
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -43,27 +43,27 @@ class IndexHtmlWebpackPlugin extends index_html_generator_1.IndexHtmlGenerator {
43
43
  files.push({
44
44
  name: chunk.name,
45
45
  file,
46
- extension: path_1.extname(file),
46
+ extension: (0, path_1.extname)(file),
47
47
  });
48
48
  }
49
49
  }
50
50
  const { content, warnings, errors } = await this.process({
51
51
  files,
52
- outputPath: path_1.dirname(this.options.outputPath),
52
+ outputPath: (0, path_1.dirname)(this.options.outputPath),
53
53
  baseHref: this.options.baseHref,
54
54
  lang: this.options.lang,
55
55
  });
56
56
  assets[this.options.outputPath] = new webpack_1.sources.RawSource(content);
57
- warnings.forEach((msg) => webpack_diagnostics_1.addWarning(this.compilation, msg));
58
- errors.forEach((msg) => webpack_diagnostics_1.addError(this.compilation, msg));
57
+ warnings.forEach((msg) => (0, webpack_diagnostics_1.addWarning)(this.compilation, msg));
58
+ errors.forEach((msg) => (0, webpack_diagnostics_1.addError)(this.compilation, msg));
59
59
  }
60
60
  catch (error) {
61
- webpack_diagnostics_1.addError(this.compilation, error.message);
61
+ (0, webpack_diagnostics_1.addError)(this.compilation, error.message);
62
62
  }
63
63
  };
64
64
  }
65
65
  async readAsset(path) {
66
- const data = this.compilation.assets[path_1.basename(path)].source();
66
+ const data = this.compilation.assets[(0, path_1.basename)(path)].source();
67
67
  return typeof data === 'string' ? data : data.toString();
68
68
  }
69
69
  async readIndex(path) {
@@ -40,7 +40,7 @@ async function default_1({ asset, options }) {
40
40
  if (asset.map) {
41
41
  partialSourcemaps.push(asset.map);
42
42
  }
43
- fullSourcemap = remapping_1.default(partialSourcemaps, () => null);
43
+ fullSourcemap = (0, remapping_1.default)(partialSourcemaps, () => null);
44
44
  }
45
45
  return { name: asset.name, code: terserResult.code, map: fullSourcemap };
46
46
  }
@@ -105,7 +105,7 @@ async function optimizeWithEsbuild(content, name, options) {
105
105
  * @returns A promise that resolves with the optimized code and source map.
106
106
  */
107
107
  async function optimizeWithTerser(name, code, sourcemaps, target, advanced) {
108
- const result = await terser_1.minify({ [name]: code }, {
108
+ const result = await (0, terser_1.minify)({ [name]: code }, {
109
109
  compress: {
110
110
  passes: advanced ? 2 : 1,
111
111
  pure_getters: advanced,
@@ -69,11 +69,11 @@ const init = (config, emitter) => {
69
69
  ` be used from within Angular CLI and will not work correctly outside of it.`);
70
70
  }
71
71
  const options = config.buildWebpack.options;
72
- const logger = config.buildWebpack.logger || node_1.createConsoleLogger();
72
+ const logger = config.buildWebpack.logger || (0, node_1.createConsoleLogger)();
73
73
  successCb = config.buildWebpack.successCb;
74
74
  failureCb = config.buildWebpack.failureCb;
75
75
  // Add a reporter that fixes sourcemap urls.
76
- if (index_1.normalizeSourceMaps(options.sourceMap).scripts) {
76
+ if ((0, index_1.normalizeSourceMaps)(options.sourceMap).scripts) {
77
77
  config.reporters.unshift('@angular-devkit/build-angular--sourcemap-reporter');
78
78
  // Code taken from https://github.com/tschaub/karma-source-map-support.
79
79
  // We can't use it directly because we need to add it conditionally in this file, and karma
@@ -124,7 +124,7 @@ const init = (config, emitter) => {
124
124
  // Files need to be served from a custom path for Karma.
125
125
  webpackConfig.output.path = `/${KARMA_APPLICATION_PATH}/`;
126
126
  webpackConfig.output.publicPath = `/${KARMA_APPLICATION_PATH}/`;
127
- const compiler = webpack_1.default(webpackConfig, (error, stats) => {
127
+ const compiler = (0, webpack_1.default)(webpackConfig, (error, stats) => {
128
128
  var _a;
129
129
  if (error) {
130
130
  throw error;
@@ -137,7 +137,7 @@ const init = (config, emitter) => {
137
137
  errors: true,
138
138
  warnings: true,
139
139
  });
140
- logger.error(stats_1.statsErrorsToString(statsJson, { colors: true }));
140
+ logger.error((0, stats_1.statsErrorsToString)(statsJson, { colors: true }));
141
141
  // Notify potential listeners of the compile error.
142
142
  emitter.emit('compile_error', {
143
143
  errors: (_a = statsJson.errors) === null || _a === void 0 ? void 0 : _a.map((e) => e.message),
@@ -93,7 +93,7 @@ function default_1(options) {
93
93
  reject(err);
94
94
  return;
95
95
  }
96
- let outputPath = loader_utils_1.interpolateName({ resourcePath: result }, filename(result), {
96
+ let outputPath = (0, loader_utils_1.interpolateName)({ resourcePath: result }, filename(result), {
97
97
  content,
98
98
  context: loader.context || loader.rootContext,
99
99
  }).replace(/\\|\//g, '-');
@@ -125,7 +125,7 @@ class ScriptsWebpackPlugin {
125
125
  concatSource.add('\n;');
126
126
  });
127
127
  const combinedSource = new webpack_1.sources.CachedSource(concatSource);
128
- const filename = loader_utils_1.interpolateName({ resourcePath: 'scripts.js' }, this.options.filename, {
128
+ const filename = (0, loader_utils_1.interpolateName)({ resourcePath: 'scripts.js' }, this.options.filename, {
129
129
  content: combinedSource.source(),
130
130
  });
131
131
  const output = { filename, source: combinedSource };
@@ -35,7 +35,7 @@ function loader(source) {
35
35
  return source;
36
36
  }
37
37
  const targettedImports = files
38
- .map((path) => `require('./${path.replace('.' + path_1.extname(path), '')}');`)
38
+ .map((path) => `require('./${path.replace('.' + (0, path_1.extname)(path), '')}');`)
39
39
  .join('\n');
40
40
  const mockedRequireContext = 'Object.assign(() => { }, { keys: () => [], resolve: () => undefined });\n';
41
41
  source = source.replace(/require\.context\(.*/, mockedRequireContext + targettedImports);
@@ -103,9 +103,9 @@ function generateBuildStatsTable(data, colors, showTotalSize) {
103
103
  if (changedLazyChunksStats.length) {
104
104
  bundleInfo.push(['Lazy Chunk Files', 'Names', 'Size'].map(bold), ...changedLazyChunksStats);
105
105
  }
106
- return text_table_1.default(bundleInfo, {
106
+ return (0, text_table_1.default)(bundleInfo, {
107
107
  hsep: dim(' | '),
108
- stringLength: (s) => color_1.removeColor(s).length,
108
+ stringLength: (s) => (0, color_1.removeColor)(s).length,
109
109
  align: ['l', 'l', 'r'],
110
110
  });
111
111
  }
@@ -259,17 +259,17 @@ exports.statsHasWarnings = statsHasWarnings;
259
259
  function createWebpackLoggingCallback(options, logger) {
260
260
  const { verbose = false, scripts = [], styles = [] } = options;
261
261
  const extraEntryPoints = [
262
- ...helpers_1.normalizeExtraEntryPoints(styles, 'styles'),
263
- ...helpers_1.normalizeExtraEntryPoints(scripts, 'scripts'),
262
+ ...(0, helpers_1.normalizeExtraEntryPoints)(styles, 'styles'),
263
+ ...(0, helpers_1.normalizeExtraEntryPoints)(scripts, 'scripts'),
264
264
  ];
265
265
  return (stats, config) => {
266
266
  if (verbose) {
267
267
  logger.info(stats.toString(config.stats));
268
268
  }
269
- const rawStats = stats.toJson(stats_1.getWebpackStatsConfig(false));
269
+ const rawStats = stats.toJson((0, stats_1.getWebpackStatsConfig)(false));
270
270
  const webpackStats = {
271
271
  ...rawStats,
272
- chunks: async_chunks_1.markAsyncChunksNonInitial(rawStats, extraEntryPoints),
272
+ chunks: (0, async_chunks_1.markAsyncChunksNonInitial)(rawStats, extraEntryPoints),
273
273
  };
274
274
  webpackStatsLogger(logger, webpackStats, config);
275
275
  };