@angular-devkit/build-angular 14.1.0-next.0 → 14.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/builders.json +1 -1
  2. package/package.json +24 -24
  3. package/src/babel/webpack-loader.js +3 -3
  4. package/src/builders/app-shell/index.js +4 -2
  5. package/src/builders/browser/index.d.ts +9 -1
  6. package/src/builders/browser/index.js +19 -3
  7. package/src/builders/browser-esbuild/experimental-warnings.js +0 -3
  8. package/src/builders/browser-esbuild/index.d.ts +2 -2
  9. package/src/builders/browser-esbuild/index.js +21 -7
  10. package/src/builders/browser-esbuild/schema.d.ts +428 -0
  11. package/src/builders/browser-esbuild/schema.js +58 -0
  12. package/src/builders/browser-esbuild/schema.json +542 -0
  13. package/src/builders/extract-i18n/index.js +3 -1
  14. package/src/builders/karma/index.js +2 -2
  15. package/src/builders/protractor/index.js +2 -0
  16. package/src/builders/server/index.d.ts +8 -1
  17. package/src/builders/server/index.js +7 -0
  18. package/src/sass/worker.js +1 -0
  19. package/src/utils/color.js +0 -1
  20. package/src/utils/error.d.ts +10 -0
  21. package/src/utils/error.js +18 -0
  22. package/src/utils/i18n-inlining.js +3 -0
  23. package/src/utils/i18n-options.js +11 -19
  24. package/src/utils/process-bundle.js +8 -8
  25. package/src/utils/service-worker.js +3 -0
  26. package/src/webpack/configs/dev-server.js +6 -0
  27. package/src/webpack/plugins/index-html-webpack-plugin.js +2 -0
  28. package/src/webpack/plugins/json-stats-plugin.js +2 -0
  29. package/src/webpack/plugins/postcss-cli-resources.js +2 -0
  30. package/src/webpack/plugins/typescript.js +1 -5
  31. package/src/webpack/utils/helpers.d.ts +1 -2
  32. package/src/webpack/utils/helpers.js +3 -2
  33. package/src/webpack/utils/stats.d.ts +3 -2
  34. package/src/webpack/utils/stats.js +22 -5
package/builders.json CHANGED
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "browser-esbuild": {
15
15
  "implementation": "./src/builders/browser-esbuild",
16
- "schema": "./src/builders/browser/schema.json",
16
+ "schema": "./src/builders/browser-esbuild/schema.json",
17
17
  "description": "Build a browser application."
18
18
  },
19
19
  "dev-server": {
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "14.1.0-next.0",
3
+ "version": "14.1.0-next.3",
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": "2.2.0",
10
- "@angular-devkit/architect": "0.1401.0-next.0",
11
- "@angular-devkit/build-webpack": "0.1401.0-next.0",
12
- "@angular-devkit/core": "14.1.0-next.0",
13
- "@babel/core": "7.18.2",
14
- "@babel/generator": "7.18.2",
15
- "@babel/helper-annotate-as-pure": "7.16.7",
16
- "@babel/plugin-proposal-async-generator-functions": "7.17.12",
17
- "@babel/plugin-transform-async-to-generator": "7.17.12",
18
- "@babel/plugin-transform-runtime": "7.18.2",
19
- "@babel/preset-env": "7.18.2",
20
- "@babel/runtime": "7.18.3",
21
- "@babel/template": "7.16.7",
10
+ "@angular-devkit/architect": "0.1401.0-next.3",
11
+ "@angular-devkit/build-webpack": "0.1401.0-next.3",
12
+ "@angular-devkit/core": "14.1.0-next.3",
13
+ "@babel/core": "7.18.6",
14
+ "@babel/generator": "7.18.7",
15
+ "@babel/helper-annotate-as-pure": "7.18.6",
16
+ "@babel/plugin-proposal-async-generator-functions": "7.18.6",
17
+ "@babel/plugin-transform-async-to-generator": "7.18.6",
18
+ "@babel/plugin-transform-runtime": "7.18.6",
19
+ "@babel/preset-env": "7.18.6",
20
+ "@babel/runtime": "7.18.6",
21
+ "@babel/template": "7.18.6",
22
22
  "@discoveryjs/json-ext": "0.5.7",
23
- "@ngtools/webpack": "14.1.0-next.0",
23
+ "@ngtools/webpack": "14.1.0-next.3",
24
24
  "ansi-colors": "4.1.3",
25
25
  "babel-loader": "8.2.5",
26
26
  "babel-plugin-istanbul": "6.1.1",
@@ -29,17 +29,17 @@
29
29
  "copy-webpack-plugin": "11.0.0",
30
30
  "critters": "0.0.16",
31
31
  "css-loader": "6.7.1",
32
- "esbuild-wasm": "0.14.42",
32
+ "esbuild-wasm": "0.14.47",
33
33
  "glob": "8.0.3",
34
34
  "https-proxy-agent": "5.0.1",
35
35
  "inquirer": "8.2.4",
36
36
  "jsonc-parser": "3.0.0",
37
37
  "karma-source-map-support": "1.4.0",
38
- "less": "4.1.2",
38
+ "less": "4.1.3",
39
39
  "less-loader": "11.0.0",
40
40
  "license-webpack-plugin": "4.0.2",
41
41
  "loader-utils": "3.2.0",
42
- "mini-css-extract-plugin": "2.6.0",
42
+ "mini-css-extract-plugin": "2.6.1",
43
43
  "minimatch": "5.1.0",
44
44
  "open": "8.4.0",
45
45
  "ora": "5.4.1",
@@ -48,29 +48,29 @@
48
48
  "postcss": "8.4.14",
49
49
  "postcss-import": "14.1.0",
50
50
  "postcss-loader": "7.0.0",
51
- "postcss-preset-env": "7.7.0",
51
+ "postcss-preset-env": "7.7.2",
52
52
  "regenerator-runtime": "0.13.9",
53
53
  "resolve-url-loader": "5.0.0",
54
54
  "rxjs": "6.6.7",
55
- "sass": "1.52.2",
56
- "sass-loader": "13.0.0",
55
+ "sass": "1.53.0",
56
+ "sass-loader": "13.0.2",
57
57
  "semver": "7.3.7",
58
- "source-map-loader": "3.0.1",
58
+ "source-map-loader": "4.0.0",
59
59
  "source-map-support": "0.5.21",
60
60
  "stylus": "0.58.1",
61
61
  "stylus-loader": "7.0.0",
62
- "terser": "5.14.0",
62
+ "terser": "5.14.1",
63
63
  "text-table": "0.2.0",
64
64
  "tree-kill": "1.2.2",
65
65
  "tslib": "2.4.0",
66
66
  "webpack": "5.73.0",
67
67
  "webpack-dev-middleware": "5.3.3",
68
- "webpack-dev-server": "4.9.1",
68
+ "webpack-dev-server": "4.9.2",
69
69
  "webpack-merge": "5.8.0",
70
70
  "webpack-subresource-integrity": "5.1.0"
71
71
  },
72
72
  "optionalDependencies": {
73
- "esbuild": "0.14.42"
73
+ "esbuild": "0.14.47"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@angular/compiler-cli": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
@@ -52,7 +52,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
52
52
  });
53
53
  return {
54
54
  async customOptions(options, { source, map }) {
55
- var _a, _b;
55
+ var _a, _b, _c;
56
56
  const { i18n, scriptTarget, aot, optimize, instrumentCode, supportedBrowsers, ...rawOptions } = options;
57
57
  // Must process file if plugins are added
58
58
  let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
@@ -89,7 +89,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
89
89
  // Comparable behavior to tsconfig target of ES5
90
90
  customOptions.supportedBrowsers = ['IE 9'];
91
91
  }
92
- else if (isJsFile) {
92
+ else if (isJsFile && ((_a = customOptions.supportedBrowsers) === null || _a === void 0 ? void 0 : _a.length)) {
93
93
  // Applications code ES version can be controlled using TypeScript's `target` option.
94
94
  // However, this doesn't effect libraries and hence we use preset-env to downlevel ES fetaures
95
95
  // based on the supported browsers in browserlist.
@@ -142,7 +142,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
142
142
  pureTopLevel: angularPackage,
143
143
  // JavaScript modules that are marked as side effect free are considered to have
144
144
  // no decorators that contain non-local effects.
145
- wrapDecorators: !!((_b = (_a = this._module) === null || _a === void 0 ? void 0 : _a.factoryMeta) === null || _b === void 0 ? void 0 : _b.sideEffectFree),
145
+ wrapDecorators: !!((_c = (_b = this._module) === null || _b === void 0 ? void 0 : _b.factoryMeta) === null || _c === void 0 ? void 0 : _c.sideEffectFree),
146
146
  };
147
147
  shouldProcess = true;
148
148
  }
@@ -34,6 +34,7 @@ const architect_1 = require("@angular-devkit/architect");
34
34
  const fs = __importStar(require("fs"));
35
35
  const path = __importStar(require("path"));
36
36
  const utils_1 = require("../../utils");
37
+ const error_1 = require("../../utils/error");
37
38
  const inline_critical_css_1 = require("../../utils/index-file/inline-critical-css");
38
39
  const service_worker_1 = require("../../utils/service-worker");
39
40
  const spinner_1 = require("../../utils/spinner");
@@ -61,7 +62,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
61
62
  deployUrl: browserOptions.deployUrl,
62
63
  })
63
64
  : undefined;
64
- for (const outputPath of browserResult.outputPaths) {
65
+ for (const { path: outputPath, baseHref } of browserResult.outputs) {
65
66
  const localeDirectory = path.relative(browserResult.baseOutputPath, outputPath);
66
67
  const browserIndexOutputPath = path.join(outputPath, 'index.html');
67
68
  const indexHtml = await fs.promises.readFile(browserIndexOutputPath, 'utf8');
@@ -95,7 +96,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
95
96
  }
96
97
  await fs.promises.writeFile(outputIndexPath, html);
97
98
  if (browserOptions.serviceWorker) {
98
- await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
99
+ await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, baseHref, browserOptions.ngswConfigPath);
99
100
  }
100
101
  }
101
102
  return browserResult;
@@ -152,6 +153,7 @@ async function _appShellBuilder(options, context) {
152
153
  }
153
154
  catch (err) {
154
155
  spinner === null || spinner === void 0 ? void 0 : spinner.fail('Application shell generation failed.');
156
+ (0, error_1.assertIsError)(err);
155
157
  return { success: false, error: err.message };
156
158
  }
157
159
  finally {
@@ -17,11 +17,19 @@ import { Schema as BrowserBuilderSchema } from './schema';
17
17
  */
18
18
  export declare type BrowserBuilderOutput = BuilderOutput & {
19
19
  baseOutputPath: string;
20
+ /**
21
+ * @deprecated in version 14. Use 'outputs' instead.
22
+ */
20
23
  outputPaths: string[];
21
24
  /**
22
- * @deprecated in version 9. Use 'outputPaths' instead.
25
+ * @deprecated in version 9. Use 'outputs' instead.
23
26
  */
24
27
  outputPath: string;
28
+ outputs: {
29
+ locale?: string;
30
+ path: string;
31
+ baseHref: string;
32
+ }[];
25
33
  };
26
34
  /**
27
35
  * Maximum time in milliseconds for single build/rebuild
@@ -42,6 +42,7 @@ const utils_1 = require("../../utils");
42
42
  const bundle_calculator_1 = require("../../utils/bundle-calculator");
43
43
  const color_1 = require("../../utils/color");
44
44
  const copy_assets_1 = require("../../utils/copy-assets");
45
+ const error_1 = require("../../utils/error");
45
46
  const i18n_inlining_1 = require("../../utils/i18n-inlining");
46
47
  const index_html_generator_1 = require("../../utils/index-file/index-html-generator");
47
48
  const normalize_cache_1 = require("../../utils/normalize-cache");
@@ -117,7 +118,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
117
118
  }), (0, operators_1.switchMap)(
118
119
  // eslint-disable-next-line max-lines-per-function
119
120
  ({ config, projectRoot, projectSourceRoot, i18n, target, cacheOptions }) => {
121
+ var _a;
120
122
  const normalizedOptimization = (0, utils_1.normalizeOptimization)(options.optimization);
123
+ const defaultBaseHref = (_a = options.baseHref) !== null && _a !== void 0 ? _a : '/';
121
124
  return (0, build_webpack_1.runWebpack)(config, context, {
122
125
  webpackFactory: require('webpack'),
123
126
  logging: transforms.logging ||
@@ -127,7 +130,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
127
130
  }
128
131
  }),
129
132
  }).pipe((0, operators_1.concatMap)(async (buildEvent) => {
130
- var _a, _b, _c, _d, _e;
133
+ var _a, _b, _c, _d, _e, _f;
131
134
  const spinner = new spinner_1.Spinner();
132
135
  spinner.enabled = options.progress !== false;
133
136
  const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
@@ -193,6 +196,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
193
196
  }
194
197
  catch (err) {
195
198
  spinner.fail(color_1.colors.redBright('Copying of assets failed.'));
199
+ (0, error_1.assertIsError)(err);
196
200
  return { success: false, error: 'Unable to copy assets: ' + err.message };
197
201
  }
198
202
  }
@@ -216,7 +220,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
216
220
  for (const [locale, outputPath] of outputPaths.entries()) {
217
221
  try {
218
222
  const { content, warnings, errors } = await indexHtmlGenerator.process({
219
- baseHref: getLocaleBaseHref(i18n, locale) || options.baseHref,
223
+ baseHref: getLocaleBaseHref(i18n, locale) || defaultBaseHref,
220
224
  // i18nLocale is used when Ivy is disabled
221
225
  lang: locale || undefined,
222
226
  outputPath,
@@ -252,7 +256,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
252
256
  spinner.start('Generating service worker...');
253
257
  for (const [locale, outputPath] of outputPaths.entries()) {
254
258
  try {
255
- await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, getLocaleBaseHref(i18n, locale) || options.baseHref || '/', options.ngswConfigPath);
259
+ await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, (_f = getLocaleBaseHref(i18n, locale)) !== null && _f !== void 0 ? _f : defaultBaseHref, options.ngswConfigPath);
256
260
  }
257
261
  catch (error) {
258
262
  spinner.fail('Service worker generation failed.');
@@ -270,6 +274,18 @@ function buildWebpackBrowser(options, context, transforms = {}) {
270
274
  baseOutputPath,
271
275
  outputPath: baseOutputPath,
272
276
  outputPaths: (outputPaths && Array.from(outputPaths.values())) || [baseOutputPath],
277
+ outputs: (outputPaths &&
278
+ [...outputPaths.entries()].map(([locale, path]) => {
279
+ var _a;
280
+ return ({
281
+ locale,
282
+ path,
283
+ baseHref: (_a = getLocaleBaseHref(i18n, locale)) !== null && _a !== void 0 ? _a : defaultBaseHref,
284
+ });
285
+ })) || {
286
+ path: baseOutputPath,
287
+ baseHref: defaultBaseHref,
288
+ },
273
289
  })));
274
290
  }));
275
291
  function getLocaleBaseHref(i18n, locale) {
@@ -21,9 +21,6 @@ const UNSUPPORTED_OPTIONS = [
21
21
  // The following two have no effect when localize is not enabled
22
22
  // 'i18nDuplicateTranslation',
23
23
  // 'i18nMissingTranslation',
24
- // * Serviceworker support
25
- 'ngswConfigPath',
26
- 'serviceWorker',
27
24
  // * Stylesheet preprocessor support
28
25
  'inlineStyleLanguage',
29
26
  // The following option has no effect until preprocessors are supported
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
9
- import { Schema as BrowserBuilderOptions } from '../browser/schema';
9
+ import { Schema as BrowserBuilderOptions } from './schema';
10
10
  /**
11
11
  * Main execution function for the esbuild-based application builder.
12
12
  * The options are compatible with the Webpack-based builder.
@@ -14,6 +14,6 @@ import { Schema as BrowserBuilderOptions } from '../browser/schema';
14
14
  * @param context The Architect builder context object
15
15
  * @returns A promise with the builder result output
16
16
  */
17
- export declare function execute(options: BrowserBuilderOptions, context: BuilderContext): Promise<BuilderOutput>;
17
+ export declare function buildEsbuildBrowser(options: BrowserBuilderOptions, context: BuilderContext): Promise<BuilderOutput>;
18
18
  declare const _default: import("@angular-devkit/architect/src/internal").Builder<BrowserBuilderOptions & import("../../../../core/src").JsonObject>;
19
19
  export default _default;
@@ -30,15 +30,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.execute = void 0;
33
+ exports.buildEsbuildBrowser = void 0;
34
34
  const architect_1 = require("@angular-devkit/architect");
35
35
  const assert = __importStar(require("assert"));
36
36
  const fs_1 = require("fs");
37
37
  const path = __importStar(require("path"));
38
38
  const utils_1 = require("../../utils");
39
39
  const copy_assets_1 = require("../../utils/copy-assets");
40
+ const error_1 = require("../../utils/error");
40
41
  const index_html_generator_1 = require("../../utils/index-file/index-html-generator");
41
42
  const package_chunk_sort_1 = require("../../utils/package-chunk-sort");
43
+ const service_worker_1 = require("../../utils/service-worker");
42
44
  const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
43
45
  const configs_1 = require("../../webpack/configs");
44
46
  const compiler_plugin_1 = require("./compiler-plugin");
@@ -54,7 +56,7 @@ const stylesheets_1 = require("./stylesheets");
54
56
  * @returns A promise with the builder result output
55
57
  */
56
58
  // eslint-disable-next-line max-lines-per-function
57
- async function execute(options, context) {
59
+ async function buildEsbuildBrowser(options, context) {
58
60
  var _a, _b, _c, _d, _e, _f;
59
61
  const startTime = Date.now();
60
62
  // Only AOT is currently supported
@@ -70,7 +72,7 @@ async function execute(options, context) {
70
72
  context.logger.error(`The 'browser-esbuild' builder requires a target to be specified.`);
71
73
  return { success: false };
72
74
  }
73
- const { workspaceRoot, mainEntryPoint, polyfillsEntryPoint, optimizationOptions, outputPath, sourcemapOptions, tsconfig, assets, outputNames, } = await (0, options_1.normalizeOptions)(context, projectName, options);
75
+ const { projectRoot, workspaceRoot, mainEntryPoint, polyfillsEntryPoint, optimizationOptions, outputPath, sourcemapOptions, tsconfig, assets, outputNames, } = await (0, options_1.normalizeOptions)(context, projectName, options);
74
76
  // Clean output path if enabled
75
77
  if (options.deleteOutputPath) {
76
78
  (0, utils_1.deleteOutputDir)(workspaceRoot, options.outputPath);
@@ -115,8 +117,8 @@ async function execute(options, context) {
115
117
  await fs_1.promises.mkdir(outputPath, { recursive: true });
116
118
  }
117
119
  catch (e) {
118
- const reason = 'message' in e ? e.message : 'Unknown error';
119
- context.logger.error('Unable to create output directory: ' + reason);
120
+ (0, error_1.assertIsError)(e);
121
+ context.logger.error('Unable to create output directory: ' + e.message);
120
122
  return { success: false };
121
123
  }
122
124
  // Process global stylesheets
@@ -201,10 +203,21 @@ async function execute(options, context) {
201
203
  }
202
204
  // Write output files
203
205
  await Promise.all(outputFiles.map((file) => fs_1.promises.writeFile(path.join(outputPath, file.path), file.contents)));
206
+ // Augment the application with service worker support
207
+ // TODO: This should eventually operate on the in-memory files prior to writing the output files
208
+ if (options.serviceWorker) {
209
+ try {
210
+ await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, workspaceRoot, outputPath, options.baseHref || '/', options.ngswConfigPath);
211
+ }
212
+ catch (error) {
213
+ context.logger.error(error instanceof Error ? error.message : `${error}`);
214
+ return { success: false };
215
+ }
216
+ }
204
217
  context.logger.info(`Complete. [${(Date.now() - startTime) / 1000} seconds]`);
205
218
  return { success: true };
206
219
  }
207
- exports.execute = execute;
220
+ exports.buildEsbuildBrowser = buildEsbuildBrowser;
208
221
  function createOutputFileFromText(path, text) {
209
222
  return {
210
223
  path,
@@ -234,6 +247,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
234
247
  sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
235
248
  splitting: true,
236
249
  tsconfig,
250
+ external: options.externalDependencies,
237
251
  write: false,
238
252
  platform: 'browser',
239
253
  preserveSymlinks: options.preserveSymlinks,
@@ -259,4 +273,4 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
259
273
  },
260
274
  });
261
275
  }
262
- exports.default = (0, architect_1.createBuilder)(execute);
276
+ exports.default = (0, architect_1.createBuilder)(buildEsbuildBrowser);