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

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,26 +1,26 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "14.1.0-rc.3",
3
+ "version": "14.2.0-next.0",
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-rc.3",
11
- "@angular-devkit/build-webpack": "0.1401.0-rc.3",
12
- "@angular-devkit/core": "14.1.0-rc.3",
13
- "@babel/core": "7.18.6",
14
- "@babel/generator": "7.18.7",
10
+ "@angular-devkit/architect": "0.1402.0-next.0",
11
+ "@angular-devkit/build-webpack": "0.1402.0-next.0",
12
+ "@angular-devkit/core": "14.2.0-next.0",
13
+ "@babel/core": "7.18.10",
14
+ "@babel/generator": "7.18.10",
15
15
  "@babel/helper-annotate-as-pure": "7.18.6",
16
- "@babel/plugin-proposal-async-generator-functions": "7.18.6",
16
+ "@babel/plugin-proposal-async-generator-functions": "7.18.10",
17
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",
18
+ "@babel/plugin-transform-runtime": "7.18.10",
19
+ "@babel/preset-env": "7.18.10",
20
+ "@babel/runtime": "7.18.9",
21
+ "@babel/template": "7.18.10",
22
22
  "@discoveryjs/json-ext": "0.5.7",
23
- "@ngtools/webpack": "14.1.0-rc.3",
23
+ "@ngtools/webpack": "14.2.0-next.0",
24
24
  "ansi-colors": "4.1.3",
25
25
  "babel-loader": "8.2.5",
26
26
  "babel-plugin-istanbul": "6.1.1",
@@ -29,11 +29,11 @@
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.48",
32
+ "esbuild-wasm": "0.14.53",
33
33
  "glob": "8.0.3",
34
34
  "https-proxy-agent": "5.0.1",
35
35
  "inquirer": "8.2.4",
36
- "jsonc-parser": "3.0.0",
36
+ "jsonc-parser": "3.1.0",
37
37
  "karma-source-map-support": "1.4.0",
38
38
  "less": "4.1.3",
39
39
  "less-loader": "11.0.0",
@@ -47,30 +47,30 @@
47
47
  "piscina": "3.2.0",
48
48
  "postcss": "8.4.14",
49
49
  "postcss-import": "14.1.0",
50
- "postcss-loader": "7.0.0",
50
+ "postcss-loader": "7.0.1",
51
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.53.0",
55
+ "sass": "1.54.1",
56
56
  "sass-loader": "13.0.2",
57
57
  "semver": "7.3.7",
58
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.1",
62
+ "terser": "5.14.2",
63
63
  "text-table": "0.2.0",
64
64
  "tree-kill": "1.2.2",
65
65
  "tslib": "2.4.0",
66
- "webpack": "5.73.0",
66
+ "webpack": "5.74.0",
67
67
  "webpack-dev-middleware": "5.3.3",
68
68
  "webpack-dev-server": "4.9.3",
69
69
  "webpack-merge": "5.8.0",
70
70
  "webpack-subresource-integrity": "5.1.0"
71
71
  },
72
72
  "optionalDependencies": {
73
- "esbuild": "0.14.48"
73
+ "esbuild": "0.14.53"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@angular/compiler-cli": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
@@ -124,7 +124,11 @@ async function buildEsbuildBrowser(options, context) {
124
124
  // Process global stylesheets
125
125
  if (options.styles) {
126
126
  // resolveGlobalStyles is temporarily reused from the Webpack builder code
127
- const { entryPoints: stylesheetEntrypoints, noInjectNames } = (0, configs_1.resolveGlobalStyles)(options.styles, workspaceRoot, !!options.preserveSymlinks);
127
+ const { entryPoints: stylesheetEntrypoints, noInjectNames } = (0, configs_1.resolveGlobalStyles)(options.styles, workspaceRoot,
128
+ // preserveSymlinks is always true here to allow the bundler to handle the option
129
+ true,
130
+ // skipResolution to leverage the bundler's more comprehensive resolution
131
+ true);
128
132
  for (const [name, files] of Object.entries(stylesheetEntrypoints)) {
129
133
  const virtualEntryData = files
130
134
  .map((file) => `@import '${file.replace(/\\/g, '/')}';`)
@@ -135,6 +139,7 @@ async function buildEsbuildBrowser(options, context) {
135
139
  sourcemap: !!sourcemapOptions.styles && (sourcemapOptions.hidden ? 'external' : true),
136
140
  outputNames: noInjectNames.includes(name) ? { media: outputNames.media } : outputNames,
137
141
  includePaths: (_e = options.stylePreprocessorOptions) === null || _e === void 0 ? void 0 : _e.includePaths,
142
+ preserveSymlinks: options.preserveSymlinks,
138
143
  });
139
144
  await (0, esbuild_1.logMessages)(context, sheetResult);
140
145
  if (!sheetResult.path) {
@@ -277,7 +282,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
277
282
  }),
278
283
  ],
279
284
  define: {
280
- 'ngDevMode': optimizationOptions.scripts ? 'false' : 'true',
285
+ ...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
281
286
  'ngJitMode': 'false',
282
287
  },
283
288
  });
@@ -50,8 +50,8 @@ async function bundleStylesheet(entry, options) {
50
50
  write: false,
51
51
  platform: 'browser',
52
52
  preserveSymlinks: options.preserveSymlinks,
53
- conditions: ['style'],
54
- mainFields: ['style'],
53
+ conditions: ['style', 'sass'],
54
+ mainFields: ['style', 'sass'],
55
55
  plugins: [
56
56
  (0, sass_plugin_1.createSassPlugin)({ sourcemap: !!options.sourcemap, includePaths: options.includePaths }),
57
57
  ],
@@ -13,6 +13,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.assertIsError = void 0;
14
14
  const assert_1 = __importDefault(require("assert"));
15
15
  function assertIsError(value) {
16
- (0, assert_1.default)(value instanceof Error, 'catch clause variable is not an Error instance');
16
+ const isError = value instanceof Error ||
17
+ // The following is needing to identify errors coming from RxJs.
18
+ (typeof value === 'object' && value && 'name' in value && 'message' in value);
19
+ (0, assert_1.default)(isError, 'catch clause variable is not an Error instance');
17
20
  }
18
21
  exports.assertIsError = assertIsError;
@@ -43,12 +43,14 @@ const webpack_subresource_integrity_1 = require("webpack-subresource-integrity")
43
43
  const environment_options_1 = require("../../utils/environment-options");
44
44
  const load_esm_1 = require("../../utils/load-esm");
45
45
  const plugins_1 = require("../plugins");
46
+ const devtools_ignore_plugin_1 = require("../plugins/devtools-ignore-plugin");
46
47
  const named_chunks_plugin_1 = require("../plugins/named-chunks-plugin");
47
48
  const progress_plugin_1 = require("../plugins/progress-plugin");
48
49
  const transfer_size_plugin_1 = require("../plugins/transfer-size-plugin");
49
50
  const typescript_2 = require("../plugins/typescript");
50
51
  const watch_files_logs_plugin_1 = require("../plugins/watch-files-logs-plugin");
51
52
  const helpers_1 = require("../utils/helpers");
53
+ const VENDORS_TEST = /[\\/]node_modules[\\/]/;
52
54
  // eslint-disable-next-line max-lines-per-function
53
55
  async function getCommonConfig(wco) {
54
56
  var _a, _b;
@@ -132,6 +134,7 @@ async function getCommonConfig(wco) {
132
134
  if (stylesSourceMap) {
133
135
  include.push(/css$/);
134
136
  }
137
+ extraPlugins.push(new devtools_ignore_plugin_1.DevToolsIgnorePlugin());
135
138
  extraPlugins.push(new webpack_2.SourceMapDevToolPlugin({
136
139
  filename: '[file].map',
137
140
  include,
@@ -307,7 +310,7 @@ async function getCommonConfig(wco) {
307
310
  supportedBrowsers: buildOptions.supportedBrowsers,
308
311
  instrumentCode: codeCoverage
309
312
  ? {
310
- includedBasePath: sourceRoot,
313
+ includedBasePath: sourceRoot !== null && sourceRoot !== void 0 ? sourceRoot : projectRoot,
311
314
  excludedPaths: (0, helpers_1.getInstrumentationExcludedPaths)(root, codeCoverageExclude),
312
315
  }
313
316
  : undefined,
@@ -355,7 +358,7 @@ async function getCommonConfig(wco) {
355
358
  name: 'vendor',
356
359
  chunks: (chunk) => chunk.name === 'main',
357
360
  enforce: true,
358
- test: /[\\/]node_modules[\\/]/,
361
+ test: VENDORS_TEST,
359
362
  },
360
363
  },
361
364
  },
@@ -98,6 +98,23 @@ async function getDevServerConfig(wco) {
98
98
  publicPath: servePath,
99
99
  stats: false,
100
100
  },
101
+ setupMiddlewares: (middlewares, _devServer) => {
102
+ // Temporary workaround for https://github.com/webpack/webpack-dev-server/issues/4180
103
+ middlewares.push({
104
+ name: 'options-request-response',
105
+ path: '*',
106
+ middleware: (req, res, next) => {
107
+ if (req.method === 'OPTIONS') {
108
+ res.statusCode = 204;
109
+ res.setHeader('Content-Length', 0);
110
+ res.end();
111
+ return;
112
+ }
113
+ next();
114
+ },
115
+ });
116
+ return middlewares;
117
+ },
101
118
  liveReload,
102
119
  hot: hmr && !liveReload ? 'only' : hmr,
103
120
  proxy: await addProxyConfig(root, proxyConfig),
@@ -8,7 +8,7 @@
8
8
  import { Configuration } from 'webpack';
9
9
  import { StyleElement } from '../../builders/browser/schema';
10
10
  import { WebpackConfigOptions } from '../../utils/build-options';
11
- export declare function resolveGlobalStyles(styleEntrypoints: StyleElement[], root: string, preserveSymlinks: boolean): {
11
+ export declare function resolveGlobalStyles(styleEntrypoints: StyleElement[], root: string, preserveSymlinks: boolean, skipResolution?: boolean): {
12
12
  entryPoints: Record<string, string[]>;
13
13
  noInjectNames: string[];
14
14
  paths: string[];
@@ -41,7 +41,7 @@ const sass_service_1 = require("../../sass/sass-service");
41
41
  const plugins_1 = require("../plugins");
42
42
  const css_optimizer_plugin_1 = require("../plugins/css-optimizer-plugin");
43
43
  const helpers_1 = require("../utils/helpers");
44
- function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
44
+ function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks, skipResolution = false) {
45
45
  const entryPoints = {};
46
46
  const noInjectNames = [];
47
47
  const paths = [];
@@ -49,29 +49,32 @@ function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
49
49
  return { entryPoints, noInjectNames, paths };
50
50
  }
51
51
  for (const style of (0, helpers_1.normalizeExtraEntryPoints)(styleEntrypoints, 'styles')) {
52
- let resolvedPath = path.resolve(root, style.input);
53
- if (!fs.existsSync(resolvedPath)) {
54
- try {
55
- resolvedPath = require.resolve(style.input, { paths: [root] });
52
+ let stylesheetPath = style.input;
53
+ if (!skipResolution) {
54
+ stylesheetPath = path.resolve(root, stylesheetPath);
55
+ if (!fs.existsSync(stylesheetPath)) {
56
+ try {
57
+ stylesheetPath = require.resolve(style.input, { paths: [root] });
58
+ }
59
+ catch { }
56
60
  }
57
- catch { }
58
61
  }
59
62
  if (!preserveSymlinks) {
60
- resolvedPath = fs.realpathSync(resolvedPath);
63
+ stylesheetPath = fs.realpathSync(stylesheetPath);
61
64
  }
62
65
  // Add style entry points.
63
66
  if (entryPoints[style.bundleName]) {
64
- entryPoints[style.bundleName].push(resolvedPath);
67
+ entryPoints[style.bundleName].push(stylesheetPath);
65
68
  }
66
69
  else {
67
- entryPoints[style.bundleName] = [resolvedPath];
70
+ entryPoints[style.bundleName] = [stylesheetPath];
68
71
  }
69
72
  // Add non injected styles to the list.
70
73
  if (!style.inject) {
71
74
  noInjectNames.push(style.bundleName);
72
75
  }
73
76
  // Add global css paths.
74
- paths.push(resolvedPath);
77
+ paths.push(stylesheetPath);
75
78
  }
76
79
  return { entryPoints, noInjectNames, paths };
77
80
  }
@@ -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
+ import { Compiler } from 'webpack';
9
+ /**
10
+ * This plugin adds a field to source maps that identifies which sources are
11
+ * vendored or runtime-injected (aka third-party) sources. These are consumed by
12
+ * Chrome DevTools to automatically ignore-list sources.
13
+ */
14
+ export declare class DevToolsIgnorePlugin {
15
+ apply(compiler: Compiler): void;
16
+ }
@@ -0,0 +1,56 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DevToolsIgnorePlugin = void 0;
11
+ const webpack_1 = require("webpack");
12
+ // Following the naming conventions from
13
+ // https://sourcemaps.info/spec.html#h.ghqpj1ytqjbm
14
+ const IGNORE_LIST = 'x_google_ignoreList';
15
+ const PLUGIN_NAME = 'devtools-ignore-plugin';
16
+ /**
17
+ * This plugin adds a field to source maps that identifies which sources are
18
+ * vendored or runtime-injected (aka third-party) sources. These are consumed by
19
+ * Chrome DevTools to automatically ignore-list sources.
20
+ */
21
+ class DevToolsIgnorePlugin {
22
+ apply(compiler) {
23
+ const { RawSource } = compiler.webpack.sources;
24
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
25
+ compilation.hooks.processAssets.tap({
26
+ name: PLUGIN_NAME,
27
+ stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
28
+ additionalAssets: true,
29
+ }, (assets) => {
30
+ for (const [name, asset] of Object.entries(assets)) {
31
+ // Instead of using `asset.map()` to fetch the source maps from
32
+ // SourceMapSource assets, process them directly as a RawSource.
33
+ // This is because `.map()` is slow and can take several seconds.
34
+ if (!name.endsWith('.map')) {
35
+ // Ignore non source map files.
36
+ continue;
37
+ }
38
+ const mapContent = asset.source().toString();
39
+ if (!mapContent) {
40
+ continue;
41
+ }
42
+ const map = JSON.parse(mapContent);
43
+ const ignoreList = [];
44
+ for (const [index, path] of map.sources.entries()) {
45
+ if (path.includes('/node_modules/') || path.startsWith('webpack/')) {
46
+ ignoreList.push(index);
47
+ }
48
+ }
49
+ map[IGNORE_LIST] = ignoreList;
50
+ compilation.updateAsset(name, new RawSource(JSON.stringify(map)));
51
+ }
52
+ });
53
+ });
54
+ }
55
+ }
56
+ exports.DevToolsIgnorePlugin = DevToolsIgnorePlugin;
@@ -41,6 +41,6 @@ export declare class EsbuildExecutor implements Pick<typeof import('esbuild'), '
41
41
  * Transitions an executor instance to use the WASM-variant of esbuild.
42
42
  */
43
43
  private useWasm;
44
- transform(input: string, options?: TransformOptions): Promise<TransformResult>;
44
+ transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>;
45
45
  formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
46
46
  }