@angular-devkit/build-angular 14.0.1 → 14.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,83 +1,83 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "14.0.1",
3
+ "version": "14.1.0-next.1",
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.1400.1",
11
- "@angular-devkit/build-webpack": "0.1400.1",
12
- "@angular-devkit/core": "14.0.1",
13
- "@babel/core": "7.17.10",
14
- "@babel/generator": "7.17.10",
10
+ "@angular-devkit/architect": "0.1401.0-next.1",
11
+ "@angular-devkit/build-webpack": "0.1401.0-next.1",
12
+ "@angular-devkit/core": "14.1.0-next.1",
13
+ "@babel/core": "7.18.2",
14
+ "@babel/generator": "7.18.2",
15
15
  "@babel/helper-annotate-as-pure": "7.16.7",
16
- "@babel/plugin-proposal-async-generator-functions": "7.16.8",
17
- "@babel/plugin-transform-async-to-generator": "7.16.8",
18
- "@babel/plugin-transform-runtime": "7.17.10",
19
- "@babel/preset-env": "7.17.10",
20
- "@babel/runtime": "7.17.9",
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
21
  "@babel/template": "7.16.7",
22
22
  "@discoveryjs/json-ext": "0.5.7",
23
- "@ngtools/webpack": "14.0.1",
24
- "ansi-colors": "4.1.1",
23
+ "@ngtools/webpack": "14.1.0-next.1",
24
+ "ansi-colors": "4.1.3",
25
25
  "babel-loader": "8.2.5",
26
26
  "babel-plugin-istanbul": "6.1.1",
27
27
  "browserslist": "^4.9.1",
28
- "cacache": "16.0.7",
29
- "copy-webpack-plugin": "10.2.4",
28
+ "cacache": "16.1.1",
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.38",
33
- "glob": "8.0.1",
32
+ "esbuild-wasm": "0.14.42",
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
38
  "less": "4.1.2",
39
- "less-loader": "10.2.0",
39
+ "less-loader": "11.0.0",
40
40
  "license-webpack-plugin": "4.0.2",
41
41
  "loader-utils": "3.2.0",
42
42
  "mini-css-extract-plugin": "2.6.0",
43
- "minimatch": "5.0.1",
43
+ "minimatch": "5.1.0",
44
44
  "open": "8.4.0",
45
45
  "ora": "5.4.1",
46
46
  "parse5-html-rewriting-stream": "6.0.1",
47
47
  "piscina": "3.2.0",
48
- "postcss": "8.4.13",
48
+ "postcss": "8.4.14",
49
49
  "postcss-import": "14.1.0",
50
- "postcss-loader": "6.2.1",
51
- "postcss-preset-env": "7.5.0",
50
+ "postcss-loader": "7.0.0",
51
+ "postcss-preset-env": "7.7.0",
52
52
  "regenerator-runtime": "0.13.9",
53
53
  "resolve-url-loader": "5.0.0",
54
54
  "rxjs": "6.6.7",
55
- "sass": "1.51.0",
56
- "sass-loader": "12.6.0",
55
+ "sass": "1.52.2",
56
+ "sass-loader": "13.0.0",
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
- "stylus": "0.57.0",
61
- "stylus-loader": "6.2.0",
62
- "terser": "5.13.1",
60
+ "stylus": "0.58.1",
61
+ "stylus-loader": "7.0.0",
62
+ "terser": "5.14.0",
63
63
  "text-table": "0.2.0",
64
64
  "tree-kill": "1.2.2",
65
65
  "tslib": "2.4.0",
66
- "webpack": "5.72.1",
67
- "webpack-dev-middleware": "5.3.1",
68
- "webpack-dev-server": "4.9.0",
66
+ "webpack": "5.73.0",
67
+ "webpack-dev-middleware": "5.3.3",
68
+ "webpack-dev-server": "4.9.1",
69
69
  "webpack-merge": "5.8.0",
70
70
  "webpack-subresource-integrity": "5.1.0"
71
71
  },
72
72
  "optionalDependencies": {
73
- "esbuild": "0.14.38"
73
+ "esbuild": "0.14.42"
74
74
  },
75
75
  "peerDependencies": {
76
- "@angular/compiler-cli": "^14.0.0",
77
- "@angular/localize": "^14.0.0",
78
- "@angular/service-worker": "^14.0.0",
76
+ "@angular/compiler-cli": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
77
+ "@angular/localize": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
78
+ "@angular/service-worker": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
79
79
  "karma": "^6.3.0",
80
- "ng-packagr": "^14.0.0",
80
+ "ng-packagr": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
81
81
  "protractor": "^7.0.0",
82
82
  "tailwindcss": "^2.0.0 || ^3.0.0",
83
83
  "typescript": ">=4.6.2 <4.8"
@@ -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");
@@ -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 {
@@ -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");
@@ -193,6 +194,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
193
194
  }
194
195
  catch (err) {
195
196
  spinner.fail(color_1.colors.redBright('Copying of assets failed.'));
197
+ (0, error_1.assertIsError)(err);
196
198
  return { success: false, error: 'Unable to copy assets: ' + err.message };
197
199
  }
198
200
  }
@@ -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
@@ -37,8 +37,10 @@ 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");
@@ -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,6 +203,17 @@ 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
  }
@@ -36,6 +36,7 @@ const core_1 = require("@angular-devkit/core");
36
36
  const path_1 = require("path");
37
37
  const url = __importStar(require("url"));
38
38
  const utils_1 = require("../../utils");
39
+ const error_1 = require("../../utils/error");
39
40
  function runProtractor(root, options) {
40
41
  const additionalProtractorConfig = {
41
42
  baseUrl: options.baseUrl,
@@ -63,6 +64,7 @@ async function updateWebdriver() {
63
64
  path = require.resolve(webdriverDeepImport, { paths: [protractorPath] });
64
65
  }
65
66
  catch (error) {
67
+ (0, error_1.assertIsError)(error);
66
68
  if (error.code !== 'MODULE_NOT_FOUND') {
67
69
  throw error;
68
70
  }
@@ -34,6 +34,7 @@ worker_threads_1.parentPort.on('message', ({ id, hasImporter, options }) => {
34
34
  // The synchronous Sass render function can be up to two times faster than the async variant
35
35
  const result = (0, sass_1.renderSync)(options);
36
36
  worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({ id, result });
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
38
  }
38
39
  catch (error) {
39
40
  // Needed because V8 will only serialize the message and stack properties of an Error instance.
@@ -0,0 +1,10 @@
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
+ export declare function assertIsError(value: unknown): asserts value is Error & {
9
+ code?: string;
10
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.assertIsError = void 0;
14
+ const assert_1 = __importDefault(require("assert"));
15
+ function assertIsError(value) {
16
+ (0, assert_1.default)(value instanceof Error, 'catch clause variable is not an Error instance');
17
+ }
18
+ exports.assertIsError = assertIsError;
@@ -35,6 +35,7 @@ const fs = __importStar(require("fs"));
35
35
  const path = __importStar(require("path"));
36
36
  const action_executor_1 = require("./action-executor");
37
37
  const copy_assets_1 = require("./copy-assets");
38
+ const error_1 = require("./error");
38
39
  const spinner_1 = require("./spinner");
39
40
  function emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emittedPath, outputPath, es5, missingTranslation, context) {
40
41
  const options = [];
@@ -61,6 +62,7 @@ function emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emitte
61
62
  originalFiles.push(originalMapPath);
62
63
  }
63
64
  catch (err) {
65
+ (0, error_1.assertIsError)(err);
64
66
  if (err.code !== 'ENOENT') {
65
67
  throw err;
66
68
  }
@@ -102,6 +104,7 @@ async function i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPat
102
104
  ], outputPaths, '');
103
105
  }
104
106
  catch (err) {
107
+ (0, error_1.assertIsError)(err);
105
108
  spinner.fail('Localized bundle generation failed: ' + err.message);
106
109
  return false;
107
110
  }
@@ -146,12 +146,12 @@ async function configureI18nBuild(context, options) {
146
146
  if (first) {
147
147
  localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
148
148
  if (localeDataPath) {
149
- context.logger.warn(`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`);
149
+ context.logger.warn(`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`);
150
150
  }
151
151
  }
152
152
  }
153
153
  if (!localeDataPath) {
154
- context.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
154
+ context.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
155
155
  }
156
156
  else {
157
157
  desc.dataPath = localeDataPath;
@@ -194,11 +194,8 @@ function findLocaleDataPath(locale, resolver) {
194
194
  return resolver(scrubbedLocale);
195
195
  }
196
196
  catch {
197
- if (scrubbedLocale === 'en-US') {
198
- // fallback to known existing en-US locale data as of 9.0
199
- return findLocaleDataPath('en-US-POSIX', resolver);
200
- }
201
- return null;
197
+ // fallback to known existing en-US locale data as of 14.0
198
+ return scrubbedLocale === 'en-US' ? findLocaleDataPath('en', resolver) : null;
202
199
  }
203
200
  }
204
201
  /** Remove temporary directory used for i18n processing. */
@@ -41,6 +41,7 @@ const fs = __importStar(require("fs"));
41
41
  const path = __importStar(require("path"));
42
42
  const worker_threads_1 = require("worker_threads");
43
43
  const environment_options_1 = require("./environment-options");
44
+ const error_1 = require("./error");
44
45
  const load_esm_1 = require("./load-esm");
45
46
  // Lazy loaded webpack-sources object
46
47
  // Webpack is only imported if needed during the processing
@@ -124,14 +125,13 @@ async function inlineLocales(options) {
124
125
  });
125
126
  }
126
127
  catch (error) {
127
- if (error.message) {
128
- // Make the error more readable.
129
- // Same errors will contain the full content of the file as the error message
130
- // Which makes it hard to find the actual error message.
131
- const index = error.message.indexOf(')\n');
132
- const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
133
- throw new Error(`${msg}\nAn error occurred inlining file "${options.filename}"`);
134
- }
128
+ (0, error_1.assertIsError)(error);
129
+ // Make the error more readable.
130
+ // Same errors will contain the full content of the file as the error message
131
+ // Which makes it hard to find the actual error message.
132
+ const index = error.message.indexOf(')\n');
133
+ const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
134
+ throw new Error(`${msg}\nAn error occurred inlining file "${options.filename}"`);
135
135
  }
136
136
  if (!ast) {
137
137
  throw new Error(`Unknown error occurred inlining file "${options.filename}"`);
@@ -35,6 +35,7 @@ const crypto = __importStar(require("crypto"));
35
35
  const fs_1 = require("fs");
36
36
  const path = __importStar(require("path"));
37
37
  const stream_1 = require("stream");
38
+ const error_1 = require("./error");
38
39
  const load_esm_1 = require("./load-esm");
39
40
  class CliFilesystem {
40
41
  constructor(base) {
@@ -87,6 +88,7 @@ async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, b
87
88
  config = JSON.parse(configurationData);
88
89
  }
89
90
  catch (error) {
91
+ (0, error_1.assertIsError)(error);
90
92
  if (error.code === 'ENOENT') {
91
93
  throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
92
94
  ` in the ${appRoot} folder. Either provide one or` +
@@ -117,6 +119,7 @@ async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, b
117
119
  await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'safety-worker.js'), fs_1.constants.COPYFILE_FICLONE);
118
120
  }
119
121
  catch (error) {
122
+ (0, error_1.assertIsError)(error);
120
123
  if (error.code !== 'ENOENT') {
121
124
  throw error;
122
125
  }
@@ -35,6 +35,7 @@ const core_1 = require("@angular-devkit/core");
35
35
  const fs_1 = require("fs");
36
36
  const path_1 = require("path");
37
37
  const url_1 = require("url");
38
+ const error_1 = require("../../utils/error");
38
39
  const load_esm_1 = require("../../utils/load-esm");
39
40
  const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
40
41
  const hmr_loader_1 = require("../plugins/hmr/hmr-loader");
@@ -187,6 +188,7 @@ async function addProxyConfig(root, proxyConfig) {
187
188
  return require(proxyPath);
188
189
  }
189
190
  catch (e) {
191
+ (0, error_1.assertIsError)(e);
190
192
  if (e.code === 'ERR_REQUIRE_ESM') {
191
193
  // Load the ESM configuration file using the TypeScript dynamic import workaround.
192
194
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.IndexHtmlWebpackPlugin = void 0;
11
11
  const path_1 = require("path");
12
12
  const webpack_1 = require("webpack");
13
+ const error_1 = require("../../utils/error");
13
14
  const index_html_generator_1 = require("../../utils/index-file/index-html-generator");
14
15
  const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
15
16
  const PLUGIN_NAME = 'index-html-webpack-plugin';
@@ -58,6 +59,7 @@ class IndexHtmlWebpackPlugin extends index_html_generator_1.IndexHtmlGenerator {
58
59
  errors.forEach((msg) => (0, webpack_diagnostics_1.addError)(this.compilation, msg));
59
60
  }
60
61
  catch (error) {
62
+ (0, error_1.assertIsError)(error);
61
63
  (0, webpack_diagnostics_1.addError)(this.compilation, error.message);
62
64
  }
63
65
  };
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.JsonStatsPlugin = void 0;
34
34
  const fs_1 = require("fs");
35
35
  const path_1 = require("path");
36
+ const error_1 = require("../../utils/error");
36
37
  const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
37
38
  class JsonStatsPlugin {
38
39
  constructor(statsOutputPath) {
@@ -50,6 +51,7 @@ class JsonStatsPlugin {
50
51
  .on('error', reject));
51
52
  }
52
53
  catch (error) {
54
+ (0, error_1.assertIsError)(error);
53
55
  (0, webpack_diagnostics_1.addError)(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
54
56
  }
55
57
  });
@@ -34,6 +34,7 @@ exports.postcss = void 0;
34
34
  const loader_utils_1 = require("loader-utils");
35
35
  const path = __importStar(require("path"));
36
36
  const url = __importStar(require("url"));
37
+ const error_1 = require("../../utils/error");
37
38
  function wrapUrl(url) {
38
39
  let wrappedUrl;
39
40
  const hasSingleQuotes = url.indexOf("'") >= 0;
@@ -146,6 +147,7 @@ function default_1(options) {
146
147
  processedUrl = await process(originalUrl, context, resourceCache);
147
148
  }
148
149
  catch (err) {
150
+ (0, error_1.assertIsError)(err);
149
151
  loader.emitError(decl.error(err.message, { word: originalUrl }));
150
152
  continue;
151
153
  }