@angular-devkit/build-angular 13.0.0-next.3 → 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 (78) hide show
  1. package/esbuild-check.js +16 -0
  2. package/package.json +32 -29
  3. package/src/babel/plugins/adjust-static-class-members.js +2 -2
  4. package/src/babel/plugins/adjust-typescript-enums.js +8 -2
  5. package/src/babel/plugins/pure-toplevel-functions.js +2 -2
  6. package/src/babel/presets/application.d.ts +14 -0
  7. package/src/babel/presets/application.js +42 -36
  8. package/src/babel/webpack-loader.js +50 -5
  9. package/src/builders/app-shell/index.js +9 -9
  10. package/src/builders/browser/index.js +42 -52
  11. package/src/builders/dev-server/index.js +23 -23
  12. package/src/builders/extract-i18n/index.js +33 -21
  13. package/src/builders/extract-i18n/ivy-extract-loader.js +34 -8
  14. package/src/builders/karma/find-tests.js +5 -5
  15. package/src/builders/karma/index.js +14 -14
  16. package/src/builders/ng-packagr/index.js +4 -4
  17. package/src/builders/protractor/index.js +4 -4
  18. package/src/builders/server/index.js +16 -16
  19. package/src/sass/worker.js +2 -2
  20. package/src/utils/build-browser-features.js +2 -2
  21. package/src/utils/build-options.d.ts +1 -1
  22. package/src/utils/bundle-calculator.js +4 -4
  23. package/src/utils/cache-path.js +2 -2
  24. package/src/utils/check-port.js +1 -1
  25. package/src/utils/color.js +25 -2
  26. package/src/utils/copy-assets.js +1 -1
  27. package/src/utils/delete-output-dir.js +1 -1
  28. package/src/utils/i18n-inlining.js +1 -1
  29. package/src/utils/i18n-options.js +26 -50
  30. package/src/utils/index-file/augment-index-html.js +2 -2
  31. package/src/utils/index-file/index-html-generator.js +3 -3
  32. package/src/utils/index-file/inline-fonts.js +4 -4
  33. package/src/utils/load-esm.d.ts +22 -0
  34. package/src/utils/load-esm.js +37 -0
  35. package/src/utils/load-translations.js +21 -8
  36. package/src/utils/normalize-asset-patterns.js +8 -8
  37. package/src/utils/normalize-builder-schema.js +4 -4
  38. package/src/utils/normalize-file-replacements.js +10 -10
  39. package/src/utils/output-paths.js +3 -3
  40. package/src/utils/package-chunk-sort.js +1 -1
  41. package/src/utils/process-bundle.d.ts +0 -1
  42. package/src/utils/process-bundle.js +44 -12
  43. package/src/utils/read-tsconfig.d.ts +2 -2
  44. package/src/utils/read-tsconfig.js +11 -6
  45. package/src/utils/run-module-as-observable-fork.js +2 -2
  46. package/src/utils/service-worker.js +16 -9
  47. package/src/utils/spinner.js +2 -2
  48. package/src/utils/version.js +1 -1
  49. package/src/utils/webpack-browser-config.d.ts +4 -3
  50. package/src/utils/webpack-browser-config.js +12 -11
  51. package/src/webpack/configs/browser.js +1 -1
  52. package/src/webpack/configs/common.d.ts +1 -1
  53. package/src/webpack/configs/common.js +24 -16
  54. package/src/webpack/configs/dev-server.d.ts +1 -1
  55. package/src/webpack/configs/dev-server.js +22 -10
  56. package/src/webpack/configs/server.js +2 -2
  57. package/src/webpack/configs/styles.js +4 -4
  58. package/src/webpack/configs/test.js +2 -2
  59. package/src/webpack/configs/typescript.js +1 -1
  60. package/src/webpack/configs/worker.js +1 -1
  61. package/src/webpack/plugins/any-component-style-budget-checker.js +4 -4
  62. package/src/webpack/plugins/common-js-usage-warn-plugin.js +2 -2
  63. package/src/webpack/plugins/css-optimizer-plugin.d.ts +12 -0
  64. package/src/webpack/plugins/css-optimizer-plugin.js +43 -17
  65. package/src/webpack/plugins/dedupe-module-resolve-plugin.js +1 -1
  66. package/src/webpack/plugins/esbuild-executor.d.ts +46 -0
  67. package/src/webpack/plugins/esbuild-executor.js +126 -0
  68. package/src/webpack/plugins/hmr/hmr-accept.js +3 -3
  69. package/src/webpack/plugins/hmr/hmr-loader.js +1 -1
  70. package/src/webpack/plugins/index-html-webpack-plugin.js +6 -6
  71. package/src/webpack/plugins/javascript-optimizer-plugin.js +5 -0
  72. package/src/webpack/plugins/javascript-optimizer-worker.d.ts +42 -0
  73. package/src/webpack/plugins/javascript-optimizer-worker.js +63 -27
  74. package/src/webpack/plugins/karma/karma.js +4 -4
  75. package/src/webpack/plugins/postcss-cli-resources.js +1 -1
  76. package/src/webpack/plugins/scripts-webpack-plugin.js +1 -1
  77. package/src/webpack/plugins/single-test-transform.js +1 -1
  78. package/src/webpack/utils/stats.js +6 -6
@@ -0,0 +1,16 @@
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
+ // If the platform does not support the native variant of esbuild, this will crash.
10
+ // This script can then be spawned by the CLI to determine if native usage is supported.
11
+ require('esbuild')
12
+ .formatMessages([], { kind: 'error ' })
13
+ .then(
14
+ () => {},
15
+ () => {},
16
+ );
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "13.0.0-next.3",
3
+ "version": "13.0.0-next.7",
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
9
  "@ampproject/remapping": "1.0.1",
10
- "@angular-devkit/architect": "0.1300.0-next.3",
11
- "@angular-devkit/build-webpack": "0.1300.0-next.3",
12
- "@angular-devkit/core": "13.0.0-next.3",
13
- "@babel/core": "7.15.0",
14
- "@babel/generator": "7.15.0",
15
- "@babel/helper-annotate-as-pure": "7.14.5",
16
- "@babel/plugin-proposal-async-generator-functions": "7.14.9",
10
+ "@angular-devkit/architect": "0.1300.0-next.7",
11
+ "@angular-devkit/build-webpack": "0.1300.0-next.7",
12
+ "@angular-devkit/core": "13.0.0-next.7",
13
+ "@babel/core": "7.15.5",
14
+ "@babel/generator": "7.15.4",
15
+ "@babel/helper-annotate-as-pure": "7.15.4",
16
+ "@babel/plugin-proposal-async-generator-functions": "7.15.4",
17
17
  "@babel/plugin-transform-async-to-generator": "7.14.5",
18
18
  "@babel/plugin-transform-runtime": "7.15.0",
19
- "@babel/preset-env": "7.15.0",
20
- "@babel/runtime": "7.15.3",
21
- "@babel/template": "7.14.5",
22
- "@discoveryjs/json-ext": "0.5.3",
19
+ "@babel/preset-env": "7.15.6",
20
+ "@babel/runtime": "7.15.4",
21
+ "@babel/template": "7.15.4",
22
+ "@discoveryjs/json-ext": "0.5.5",
23
23
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
24
- "@ngtools/webpack": "13.0.0-next.3",
24
+ "@ngtools/webpack": "13.0.0-next.7",
25
25
  "ansi-colors": "4.1.1",
26
26
  "babel-loader": "8.2.2",
27
27
  "browserslist": "^4.9.1",
@@ -29,58 +29,61 @@
29
29
  "caniuse-lite": "^1.0.30001032",
30
30
  "circular-dependency-plugin": "5.2.2",
31
31
  "copy-webpack-plugin": "9.0.1",
32
- "core-js": "3.16.4",
32
+ "core-js": "3.18.1",
33
33
  "critters": "0.0.10",
34
- "css-loader": "6.2.0",
35
- "esbuild": "0.12.24",
34
+ "css-loader": "6.3.0",
35
+ "esbuild-wasm": "0.13.3",
36
36
  "find-cache-dir": "3.3.2",
37
- "glob": "7.1.7",
37
+ "glob": "7.2.0",
38
38
  "https-proxy-agent": "5.0.0",
39
- "inquirer": "8.1.2",
39
+ "inquirer": "8.1.5",
40
40
  "karma-source-map-support": "1.4.0",
41
41
  "less": "4.1.1",
42
42
  "less-loader": "10.0.1",
43
43
  "license-webpack-plugin": "2.3.21",
44
44
  "loader-utils": "2.0.0",
45
- "mini-css-extract-plugin": "2.2.1",
45
+ "mini-css-extract-plugin": "2.3.0",
46
46
  "minimatch": "3.0.4",
47
47
  "open": "8.2.1",
48
48
  "ora": "5.4.1",
49
49
  "parse5-html-rewriting-stream": "6.0.1",
50
50
  "piscina": "3.1.0",
51
- "postcss": "8.3.6",
51
+ "postcss": "8.3.8",
52
52
  "postcss-import": "14.0.2",
53
53
  "postcss-loader": "6.1.1",
54
54
  "postcss-preset-env": "6.7.0",
55
55
  "regenerator-runtime": "0.13.9",
56
56
  "resolve-url-loader": "4.0.0",
57
57
  "rxjs": "6.6.7",
58
- "sass": "1.38.2",
58
+ "sass": "1.42.1",
59
59
  "sass-loader": "12.1.0",
60
60
  "semver": "7.3.5",
61
61
  "source-map-loader": "3.0.0",
62
- "source-map-support": "0.5.19",
63
- "stylus": "0.54.8",
62
+ "source-map-support": "0.5.20",
63
+ "stylus": "0.55.0",
64
64
  "stylus-loader": "6.1.0",
65
- "terser": "5.7.2",
65
+ "terser": "5.9.0",
66
66
  "text-table": "0.2.0",
67
67
  "tree-kill": "1.2.2",
68
68
  "tslib": "2.3.1",
69
- "webpack": "5.51.1",
70
- "webpack-dev-middleware": "5.0.0",
71
- "webpack-dev-server": "4.1.0",
69
+ "webpack": "5.55.1",
70
+ "webpack-dev-middleware": "5.2.1",
71
+ "webpack-dev-server": "4.3.0",
72
72
  "webpack-merge": "5.8.0",
73
73
  "webpack-subresource-integrity": "5.0.0"
74
74
  },
75
+ "optionalDependencies": {
76
+ "esbuild": "0.13.3"
77
+ },
75
78
  "peerDependencies": {
76
79
  "@angular/compiler-cli": "^13.0.0 || ^13.0.0-next",
77
80
  "@angular/localize": "^13.0.0 || ^13.0.0-next",
78
81
  "@angular/service-worker": "^13.0.0 || ^13.0.0-next",
79
82
  "karma": "^6.3.0",
80
- "ng-packagr": "^12.0.0",
83
+ "ng-packagr": "^13.0.0 || ^13.0.0-next",
81
84
  "protractor": "^7.0.0",
82
85
  "tailwindcss": "^2.0.0",
83
- "typescript": "~4.2.3 || ~4.3.2"
86
+ "typescript": "~4.4.3"
84
87
  },
85
88
  "peerDependenciesMeta": {
86
89
  "@angular/localize": {
@@ -208,7 +208,7 @@ function default_1() {
208
208
  core_1.types.returnStatement(core_1.types.cloneNode(classNode.id)),
209
209
  ]));
210
210
  const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
211
- helper_annotate_as_pure_1.default(replacementInitializer);
211
+ (0, helper_annotate_as_pure_1.default)(replacementInitializer);
212
212
  // Replace class with IIFE wrapped class
213
213
  const declaration = core_1.types.variableDeclaration('let', [
214
214
  core_1.types.variableDeclarator(core_1.types.cloneNode(classNode.id), replacementInitializer),
@@ -264,7 +264,7 @@ function default_1() {
264
264
  core_1.types.returnStatement(core_1.types.cloneNode(classNode.id)),
265
265
  ]));
266
266
  const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
267
- helper_annotate_as_pure_1.default(replacementInitializer);
267
+ (0, helper_annotate_as_pure_1.default)(replacementInitializer);
268
268
  // Add the wrapped class directly to the variable declaration
269
269
  parentPath.get('init').replaceWith(replacementInitializer);
270
270
  },
@@ -68,9 +68,15 @@ function default_1() {
68
68
  if (!enumCallee.isFunctionExpression() || enumCallee.node.params.length !== 1) {
69
69
  return;
70
70
  }
71
+ const enumCalleeParam = enumCallee.node.params[0];
72
+ const isEnumCalleeMatching = core_1.types.isIdentifier(enumCalleeParam) && enumCalleeParam.name === declarationId.name;
71
73
  // Loose mode rewrites the enum to a shorter but less TypeScript-like form
74
+ // Note: We only can apply the `loose` mode transformation if the callee parameter matches
75
+ // with the declaration identifier name. This is necessary in case the the declaration id has
76
+ // been renamed to avoid collisions, as the loose transform would then break the enum assignments
77
+ // which rely on the differently-named callee identifier name.
72
78
  let enumAssignments;
73
- if (loose) {
79
+ if (loose && isEnumCalleeMatching) {
74
80
  enumAssignments = [];
75
81
  }
76
82
  // Check if all enum member values are pure.
@@ -113,7 +119,7 @@ function default_1() {
113
119
  core_1.types.returnStatement(core_1.types.cloneNode(declarationId)),
114
120
  ]));
115
121
  const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
116
- helper_annotate_as_pure_1.default(replacementInitializer);
122
+ (0, helper_annotate_as_pure_1.default)(replacementInitializer);
117
123
  // Add the wrapped enum initializer directly to the variable declaration
118
124
  declaration.get('init').replaceWith(replacementInitializer);
119
125
  },
@@ -72,12 +72,12 @@ function default_1() {
72
72
  if (core_1.types.isIdentifier(callee) && isTslibHelperName(callee.name)) {
73
73
  return;
74
74
  }
75
- helper_annotate_as_pure_1.default(path);
75
+ (0, helper_annotate_as_pure_1.default)(path);
76
76
  },
77
77
  NewExpression(path) {
78
78
  // If the expression has a function parent, it is not top-level
79
79
  if (!path.getFunctionParent()) {
80
- helper_annotate_as_pure_1.default(path);
80
+ (0, helper_annotate_as_pure_1.default)(path);
81
81
  }
82
82
  },
83
83
  },
@@ -6,15 +6,29 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  export declare type DiagnosticReporter = (type: 'error' | 'warning' | 'info', message: string) => void;
9
+ /**
10
+ * An interface representing the factory functions for the `@angular/localize` translation Babel plugins.
11
+ * This must be provided for the ESM imports since dynamic imports are required to be asynchronous and
12
+ * Babel presets currently can only be synchronous.
13
+ *
14
+ * TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
15
+ */
16
+ export interface I18nPluginCreators {
17
+ makeEs2015TranslatePlugin: typeof import('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin').makeEs2015TranslatePlugin;
18
+ makeEs5TranslatePlugin: typeof import('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin').makeEs5TranslatePlugin;
19
+ makeLocalePlugin: typeof import('@angular/localize/src/tools/src/translate/source_files/locale_plugin').makeLocalePlugin;
20
+ }
9
21
  export interface ApplicationPresetOptions {
10
22
  i18n?: {
11
23
  locale: string;
12
24
  missingTranslationBehavior?: 'error' | 'warning' | 'ignore';
13
25
  translation?: unknown;
26
+ pluginCreators?: I18nPluginCreators;
14
27
  };
15
28
  angularLinker?: {
16
29
  shouldLink: boolean;
17
30
  jitMode: boolean;
31
+ linkerPluginCreator: typeof import('@angular/compiler-cli/linker/babel').createEs2015LinkerPlugin;
18
32
  };
19
33
  forceES5?: boolean;
20
34
  forceAsyncTransformation?: boolean;
@@ -26,54 +26,62 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ const assert_1 = require("assert");
29
30
  const fs = __importStar(require("fs"));
30
31
  const path = __importStar(require("path"));
31
32
  function createI18nDiagnostics(reporter) {
32
- // Babel currently is synchronous so import cannot be used
33
- const diagnostics = new (require('@angular/localize/src/tools/src/diagnostics').Diagnostics)();
34
- if (!reporter) {
35
- return diagnostics;
36
- }
37
- const baseAdd = diagnostics.add;
38
- diagnostics.add = function (type, message, ...args) {
39
- if (type !== 'ignore') {
40
- baseAdd.call(diagnostics, type, message, ...args);
41
- reporter(type, message);
33
+ const diagnostics = new (class {
34
+ constructor() {
35
+ this.messages = [];
36
+ this.hasErrors = false;
42
37
  }
43
- };
44
- const baseError = diagnostics.error;
45
- diagnostics.error = function (message, ...args) {
46
- baseError.call(diagnostics, message, ...args);
47
- reporter('error', message);
48
- };
49
- const baseWarn = diagnostics.warn;
50
- diagnostics.warn = function (message, ...args) {
51
- baseWarn.call(diagnostics, message, ...args);
52
- reporter('warning', message);
53
- };
54
- const baseMerge = diagnostics.merge;
55
- diagnostics.merge = function (other, ...args) {
56
- baseMerge.call(diagnostics, other, ...args);
57
- for (const diagnostic of other.messages) {
58
- reporter(diagnostic.type, diagnostic.message);
38
+ add(type, message) {
39
+ if (type === 'ignore') {
40
+ return;
41
+ }
42
+ this.messages.push({ type, message });
43
+ this.hasErrors || (this.hasErrors = type === 'error');
44
+ reporter === null || reporter === void 0 ? void 0 : reporter(type, message);
59
45
  }
60
- };
46
+ error(message) {
47
+ this.add('error', message);
48
+ }
49
+ warn(message) {
50
+ this.add('warning', message);
51
+ }
52
+ merge(other) {
53
+ for (const diagnostic of other.messages) {
54
+ this.add(diagnostic.type, diagnostic.message);
55
+ }
56
+ }
57
+ formatDiagnostics() {
58
+ assert_1.strict.fail('@angular/localize Diagnostics formatDiagnostics should not be called from within babel.');
59
+ }
60
+ })();
61
61
  return diagnostics;
62
62
  }
63
- function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter) {
63
+ function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter,
64
+ // TODO_ESM: Make `pluginCreators` required once `@angular/localize` is published with the `tools` entry point
65
+ pluginCreators) {
64
66
  const diagnostics = createI18nDiagnostics(diagnosticReporter);
65
67
  const plugins = [];
66
68
  if (translation) {
67
- const { makeEs2015TranslatePlugin, } = require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin');
69
+ const { makeEs2015TranslatePlugin,
70
+ // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
71
+ } = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin');
68
72
  plugins.push(makeEs2015TranslatePlugin(diagnostics, translation, {
69
73
  missingTranslation: missingTranslationBehavior,
70
74
  }));
71
- const { makeEs5TranslatePlugin, } = require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin');
75
+ const { makeEs5TranslatePlugin,
76
+ // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
77
+ } = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin');
72
78
  plugins.push(makeEs5TranslatePlugin(diagnostics, translation, {
73
79
  missingTranslation: missingTranslationBehavior,
74
80
  }));
75
81
  }
76
- const { makeLocalePlugin, } = require('@angular/localize/src/tools/src/translate/source_files/locale_plugin');
82
+ const { makeLocalePlugin,
83
+ // TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
84
+ } = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/locale_plugin');
77
85
  plugins.push(makeLocalePlugin(locale));
78
86
  return plugins;
79
87
  }
@@ -98,9 +106,7 @@ function default_1(api, options) {
98
106
  const plugins = [];
99
107
  let needRuntimeTransform = false;
100
108
  if ((_a = options.angularLinker) === null || _a === void 0 ? void 0 : _a.shouldLink) {
101
- // Babel currently is synchronous so import cannot be used
102
- const { createEs2015LinkerPlugin } = require('@angular/compiler-cli/linker/babel');
103
- plugins.push(createEs2015LinkerPlugin({
109
+ plugins.push(options.angularLinker.linkerPluginCreator({
104
110
  linkerJitMode: options.angularLinker.jitMode,
105
111
  // This is a workaround until https://github.com/angular/angular/issues/42769 is fixed.
106
112
  sourceMapping: false,
@@ -130,8 +136,8 @@ function default_1(api, options) {
130
136
  needRuntimeTransform = true;
131
137
  }
132
138
  if (options.i18n) {
133
- const { locale, missingTranslationBehavior, translation } = options.i18n;
134
- const i18nPlugins = createI18nPlugins(locale, translation, missingTranslationBehavior || 'ignore', options.diagnosticReporter);
139
+ const { locale, missingTranslationBehavior, pluginCreators, translation } = options.i18n;
140
+ const i18nPlugins = createI18nPlugins(locale, translation, missingTranslationBehavior || 'ignore', options.diagnosticReporter, pluginCreators);
135
141
  plugins.push(...i18nPlugins);
136
142
  }
137
143
  if (options.forceAsyncTransformation) {
@@ -7,18 +7,37 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const linker_1 = require("@angular/compiler-cli/linker");
11
10
  const babel_loader_1 = require("babel-loader");
12
11
  const typescript_1 = require("typescript");
13
- function requiresLinking(path, source) {
12
+ const load_esm_1 = require("../utils/load-esm");
13
+ /**
14
+ * Cached instance of the compiler-cli linker's needsLinking function.
15
+ */
16
+ let needsLinking;
17
+ /**
18
+ * Cached instance of the compiler-cli linker's Babel plugin factory function.
19
+ */
20
+ let linkerPluginCreator;
21
+ /**
22
+ * Cached instance of the localize Babel plugins factory functions.
23
+ */
24
+ let i18nPluginCreators;
25
+ async function requiresLinking(path, source) {
14
26
  // @angular/core and @angular/compiler will cause false positives
15
27
  // Also, TypeScript files do not require linking
16
28
  if (/[\\/]@angular[\\/](?:compiler|core)|\.tsx?$/.test(path)) {
17
29
  return false;
18
30
  }
19
- return linker_1.needsLinking(path, source);
31
+ if (!needsLinking) {
32
+ // Load ESM `@angular/compiler-cli/linker` using the TypeScript dynamic import workaround.
33
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
34
+ // changed to a direct dynamic import.
35
+ const linkerModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker');
36
+ needsLinking = linkerModule.needsLinking;
37
+ }
38
+ return needsLinking(path, source);
20
39
  }
21
- exports.default = babel_loader_1.custom(() => {
40
+ exports.default = (0, babel_loader_1.custom)(() => {
22
41
  const baseOptions = Object.freeze({
23
42
  babelrc: false,
24
43
  configFile: false,
@@ -40,9 +59,17 @@ exports.default = babel_loader_1.custom(() => {
40
59
  };
41
60
  // Analyze file for linking
42
61
  if (await requiresLinking(this.resourcePath, source)) {
62
+ if (!linkerPluginCreator) {
63
+ // Load ESM `@angular/compiler-cli/linker/babel` using the TypeScript dynamic import workaround.
64
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
65
+ // changed to a direct dynamic import.
66
+ const linkerBabelModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel');
67
+ linkerPluginCreator = linkerBabelModule.createEs2015LinkerPlugin;
68
+ }
43
69
  customOptions.angularLinker = {
44
70
  shouldLink: true,
45
71
  jitMode: aot !== true,
72
+ linkerPluginCreator,
46
73
  };
47
74
  shouldProcess = true;
48
75
  }
@@ -66,7 +93,25 @@ exports.default = babel_loader_1.custom(() => {
66
93
  if (i18n &&
67
94
  !/[\\/]@angular[\\/](?:compiler|localize)/.test(this.resourcePath) &&
68
95
  source.includes('$localize')) {
69
- customOptions.i18n = i18n;
96
+ // Load the i18n plugin creators from the new `@angular/localize/tools` entry point.
97
+ // This may fail during the transition to ESM due to the entry point not yet existing.
98
+ // During the transition, this will always attempt to load the entry point for each file.
99
+ // This will only occur during prerelease and will be automatically corrected once the new
100
+ // entry point exists.
101
+ // TODO_ESM: Make import failure an error once the `tools` entry point exists.
102
+ if (i18nPluginCreators === undefined) {
103
+ // Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
104
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
105
+ // changed to a direct dynamic import.
106
+ try {
107
+ i18nPluginCreators = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
108
+ }
109
+ catch { }
110
+ }
111
+ customOptions.i18n = {
112
+ ...i18n,
113
+ pluginCreators: i18nPluginCreators,
114
+ };
70
115
  shouldProcess = true;
71
116
  }
72
117
  if (optimize) {
@@ -36,7 +36,7 @@ const service_worker_1 = require("../../utils/service-worker");
36
36
  const spinner_1 = require("../../utils/spinner");
37
37
  async function _renderUniversal(options, context, browserResult, serverResult, spinner) {
38
38
  // Get browser target options.
39
- const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
39
+ const browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
40
40
  const rawBrowserOptions = (await context.getTargetOptions(browserTarget));
41
41
  const browserBuilderName = await context.getBuilderNameForTarget(browserTarget);
42
42
  const browserOptions = await context.validateOptions(rawBrowserOptions, browserBuilderName);
@@ -49,8 +49,8 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
49
49
  throw new Error('The builder requires a target.');
50
50
  }
51
51
  const projectMetadata = await context.getProjectMetadata(projectName);
52
- const projectRoot = core_1.resolve(core_1.normalize(root), core_1.normalize(projectMetadata.root || ''));
53
- const { styles } = utils_1.normalizeOptimization(browserOptions.optimization);
52
+ const projectRoot = (0, core_1.resolve)((0, core_1.normalize)(root), (0, core_1.normalize)(projectMetadata.root || ''));
53
+ const { styles } = (0, utils_1.normalizeOptimization)(browserOptions.optimization);
54
54
  const inlineCriticalCssProcessor = styles.inlineCritical
55
55
  ? new inline_critical_css_1.InlineCriticalCssProcessor({
56
56
  minify: styles.minify,
@@ -91,7 +91,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
91
91
  }
92
92
  await fs.promises.writeFile(outputIndexPath, html);
93
93
  if (browserOptions.serviceWorker) {
94
- await service_worker_1.augmentAppWithServiceWorker(core_1.normalize(root), projectRoot, core_1.normalize(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
94
+ await (0, service_worker_1.augmentAppWithServiceWorker)((0, core_1.normalize)(root), projectRoot, (0, core_1.normalize)(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
95
95
  }
96
96
  }
97
97
  return browserResult;
@@ -105,7 +105,7 @@ async function _getServerModuleBundlePath(options, context, serverResult, browse
105
105
  if (!fs.existsSync(outputPath)) {
106
106
  throw new Error(`Could not find server output directory: ${outputPath}.`);
107
107
  }
108
- const re = /^main\.(?:[a-zA-Z0-9]{20}\.)?js$/;
108
+ const re = /^main\.(?:[a-zA-Z0-9]{16}\.)?js$/;
109
109
  const maybeMain = fs.readdirSync(outputPath).find((x) => re.test(x));
110
110
  if (!maybeMain) {
111
111
  throw new Error('Could not find the main bundle.');
@@ -113,12 +113,12 @@ async function _getServerModuleBundlePath(options, context, serverResult, browse
113
113
  return path.join(outputPath, maybeMain);
114
114
  }
115
115
  async function _appShellBuilder(options, context) {
116
- const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
117
- const serverTarget = architect_1.targetFromTargetString(options.serverTarget);
116
+ const browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
117
+ const serverTarget = (0, architect_1.targetFromTargetString)(options.serverTarget);
118
118
  // Never run the browser target in watch mode.
119
119
  // If service worker is needed, it will be added in _renderUniversal();
120
120
  const browserOptions = (await context.getTargetOptions(browserTarget));
121
- const optimization = utils_1.normalizeOptimization(browserOptions.optimization);
121
+ const optimization = (0, utils_1.normalizeOptimization)(browserOptions.optimization);
122
122
  optimization.styles.inlineCritical = false;
123
123
  const browserTargetRun = await context.scheduleTarget(browserTarget, {
124
124
  watch: false,
@@ -154,4 +154,4 @@ async function _appShellBuilder(options, context) {
154
154
  await Promise.all([browserTargetRun.stop(), serverTargetRun.stop()]);
155
155
  }
156
156
  }
157
- exports.default = architect_1.createBuilder(_appShellBuilder);
157
+ exports.default = (0, architect_1.createBuilder)(_appShellBuilder);