@angular-devkit/build-angular 14.1.0-rc.3 → 14.1.2
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 +14 -14
- package/src/builders/browser-esbuild/compiler-plugin.js +45 -9
- package/src/builders/browser-esbuild/css-resource-plugin.d.ts +17 -0
- package/src/builders/browser-esbuild/css-resource-plugin.js +59 -0
- package/src/builders/browser-esbuild/index.js +21 -2
- package/src/builders/browser-esbuild/stylesheets.d.ts +1 -0
- package/src/builders/browser-esbuild/stylesheets.js +5 -2
- package/src/utils/error.js +4 -1
- package/src/webpack/configs/common.js +5 -2
- package/src/webpack/configs/dev-server.js +17 -0
- package/src/webpack/configs/styles.d.ts +1 -1
- package/src/webpack/configs/styles.js +13 -10
- package/src/webpack/plugins/analytics.js +1 -1
- package/src/webpack/plugins/devtools-ignore-plugin.d.ts +16 -0
- package/src/webpack/plugins/devtools-ignore-plugin.js +56 -0
- package/src/webpack/plugins/postcss-cli-resources.js +2 -2
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.2",
|
|
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.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1401.
|
|
12
|
-
"@angular-devkit/core": "14.1.
|
|
10
|
+
"@angular-devkit/architect": "0.1401.2",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1401.2",
|
|
12
|
+
"@angular-devkit/core": "14.1.2",
|
|
13
13
|
"@babel/core": "7.18.6",
|
|
14
14
|
"@babel/generator": "7.18.7",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/runtime": "7.18.6",
|
|
21
21
|
"@babel/template": "7.18.6",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "14.1.
|
|
23
|
+
"@ngtools/webpack": "14.1.2",
|
|
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.
|
|
32
|
+
"esbuild-wasm": "0.14.49",
|
|
33
33
|
"glob": "8.0.3",
|
|
34
34
|
"https-proxy-agent": "5.0.1",
|
|
35
35
|
"inquirer": "8.2.4",
|
|
36
|
-
"jsonc-parser": "3.
|
|
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,7 +47,7 @@
|
|
|
47
47
|
"piscina": "3.2.0",
|
|
48
48
|
"postcss": "8.4.14",
|
|
49
49
|
"postcss-import": "14.1.0",
|
|
50
|
-
"postcss-loader": "7.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",
|
|
@@ -59,7 +59,7 @@
|
|
|
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.
|
|
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",
|
|
@@ -70,14 +70,14 @@
|
|
|
70
70
|
"webpack-subresource-integrity": "5.1.0"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
|
-
"esbuild": "0.14.
|
|
73
|
+
"esbuild": "0.14.49"
|
|
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",
|
|
77
|
+
"@angular/localize": "^14.0.0",
|
|
78
|
+
"@angular/service-worker": "^14.0.0",
|
|
79
79
|
"karma": "^6.3.0",
|
|
80
|
-
"ng-packagr": "^14.0.0
|
|
80
|
+
"ng-packagr": "^14.0.0",
|
|
81
81
|
"protractor": "^7.0.0",
|
|
82
82
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
83
83
|
"typescript": ">=4.6.2 <4.8"
|
|
@@ -162,9 +162,13 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
162
162
|
}
|
|
163
163
|
// The file emitter created during `onStart` that will be used during the build in `onLoad` callbacks for TS files
|
|
164
164
|
let fileEmitter;
|
|
165
|
+
// The stylesheet resources from component stylesheets that will be added to the build results output files
|
|
166
|
+
let stylesheetResourceFiles;
|
|
165
167
|
build.onStart(async () => {
|
|
166
168
|
var _a, _b;
|
|
167
169
|
const result = {};
|
|
170
|
+
// Reset stylesheet resource output files
|
|
171
|
+
stylesheetResourceFiles = [];
|
|
168
172
|
// Create TypeScript compiler host
|
|
169
173
|
const host = typescript_1.default.createIncrementalCompilerHost(compilerOptions);
|
|
170
174
|
// Temporarily process external resources via readResource.
|
|
@@ -176,9 +180,10 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
176
180
|
if (fileName.endsWith('.html')) {
|
|
177
181
|
return (_a = this.readFile(fileName)) !== null && _a !== void 0 ? _a : '';
|
|
178
182
|
}
|
|
179
|
-
const { contents, errors, warnings } = await (0, stylesheets_1.bundleStylesheetFile)(fileName, styleOptions);
|
|
183
|
+
const { contents, resourceFiles, errors, warnings } = await (0, stylesheets_1.bundleStylesheetFile)(fileName, styleOptions);
|
|
180
184
|
((_b = result.errors) !== null && _b !== void 0 ? _b : (result.errors = [])).push(...errors);
|
|
181
185
|
((_c = result.warnings) !== null && _c !== void 0 ? _c : (result.warnings = [])).push(...warnings);
|
|
186
|
+
stylesheetResourceFiles.push(...resourceFiles);
|
|
182
187
|
return contents;
|
|
183
188
|
};
|
|
184
189
|
// Add an AOT compiler resource transform hook
|
|
@@ -191,12 +196,13 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
191
196
|
// The file with the resource content will either be an actual file (resourceFile)
|
|
192
197
|
// or the file containing the inline component style text (containingFile).
|
|
193
198
|
const file = (_a = context.resourceFile) !== null && _a !== void 0 ? _a : context.containingFile;
|
|
194
|
-
const { contents, errors, warnings } = await (0, stylesheets_1.bundleStylesheetText)(data, {
|
|
199
|
+
const { contents, resourceFiles, errors, warnings } = await (0, stylesheets_1.bundleStylesheetText)(data, {
|
|
195
200
|
resolvePath: path.dirname(file),
|
|
196
201
|
virtualName: file,
|
|
197
202
|
}, styleOptions);
|
|
198
203
|
((_b = result.errors) !== null && _b !== void 0 ? _b : (result.errors = [])).push(...errors);
|
|
199
204
|
((_c = result.warnings) !== null && _c !== void 0 ? _c : (result.warnings = [])).push(...warnings);
|
|
205
|
+
stylesheetResourceFiles.push(...resourceFiles);
|
|
200
206
|
return { content: contents };
|
|
201
207
|
};
|
|
202
208
|
// Create the Angular specific program that contains the Angular compiler
|
|
@@ -263,9 +269,20 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
263
269
|
],
|
|
264
270
|
};
|
|
265
271
|
}
|
|
272
|
+
const data = (_a = typescriptResult.content) !== null && _a !== void 0 ? _a : '';
|
|
273
|
+
const forceAsyncTransformation = /for\s+await\s*\(|async\s+function\s*\*/.test(data);
|
|
266
274
|
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
267
275
|
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
268
|
-
|
|
276
|
+
// If no additional transformations are needed, return the TypeScript output directly
|
|
277
|
+
if (!forceAsyncTransformation && !pluginOptions.advancedOptimizations) {
|
|
278
|
+
return {
|
|
279
|
+
// Strip sourcemaps if they should not be used
|
|
280
|
+
contents: useInputSourcemap
|
|
281
|
+
? data
|
|
282
|
+
: data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''),
|
|
283
|
+
loader: 'js',
|
|
284
|
+
};
|
|
285
|
+
}
|
|
269
286
|
const babelResult = await (0, core_1.transformAsync)(data, {
|
|
270
287
|
filename: args.path,
|
|
271
288
|
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
@@ -279,7 +296,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
279
296
|
[
|
|
280
297
|
application_1.default,
|
|
281
298
|
{
|
|
282
|
-
forceAsyncTransformation
|
|
299
|
+
forceAsyncTransformation,
|
|
283
300
|
optimize: pluginOptions.advancedOptimizations && {},
|
|
284
301
|
},
|
|
285
302
|
],
|
|
@@ -292,11 +309,24 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
292
309
|
});
|
|
293
310
|
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
294
311
|
var _a;
|
|
295
|
-
const
|
|
296
|
-
const
|
|
312
|
+
const data = await fs_1.promises.readFile(args.path, 'utf-8');
|
|
313
|
+
const forceAsyncTransformation = !/[\\/][_f]?esm2015[\\/]/.test(args.path) &&
|
|
314
|
+
/for\s+await\s*\(|async\s+function\s*\*/.test(data);
|
|
315
|
+
const shouldLink = await (0, webpack_loader_1.requiresLinking)(args.path, data);
|
|
297
316
|
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
298
317
|
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
299
|
-
|
|
318
|
+
// If no additional transformations are needed, return the TypeScript output directly
|
|
319
|
+
if (!forceAsyncTransformation && !pluginOptions.advancedOptimizations && !shouldLink) {
|
|
320
|
+
return {
|
|
321
|
+
// Strip sourcemaps if they should not be used
|
|
322
|
+
contents: useInputSourcemap
|
|
323
|
+
? data
|
|
324
|
+
: data.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''),
|
|
325
|
+
loader: 'js',
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(args.path);
|
|
329
|
+
const linkerPluginCreator = (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
300
330
|
const result = await (0, core_1.transformAsync)(data, {
|
|
301
331
|
filename: args.path,
|
|
302
332
|
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
@@ -311,11 +341,11 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
311
341
|
application_1.default,
|
|
312
342
|
{
|
|
313
343
|
angularLinker: {
|
|
314
|
-
shouldLink
|
|
344
|
+
shouldLink,
|
|
315
345
|
jitMode: false,
|
|
316
346
|
linkerPluginCreator,
|
|
317
347
|
},
|
|
318
|
-
forceAsyncTransformation
|
|
348
|
+
forceAsyncTransformation,
|
|
319
349
|
optimize: pluginOptions.advancedOptimizations && {
|
|
320
350
|
looseEnums: angularPackage,
|
|
321
351
|
pureTopLevel: angularPackage,
|
|
@@ -329,6 +359,12 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
329
359
|
loader: 'js',
|
|
330
360
|
};
|
|
331
361
|
});
|
|
362
|
+
build.onEnd((result) => {
|
|
363
|
+
var _a;
|
|
364
|
+
if (stylesheetResourceFiles.length) {
|
|
365
|
+
(_a = result.outputFiles) === null || _a === void 0 ? void 0 : _a.push(...stylesheetResourceFiles);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
332
368
|
},
|
|
333
369
|
};
|
|
334
370
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 type { Plugin } from 'esbuild';
|
|
9
|
+
/**
|
|
10
|
+
* Creates an esbuild {@link Plugin} that loads all CSS url token references using the
|
|
11
|
+
* built-in esbuild `file` loader. A plugin is used to allow for all file extensions
|
|
12
|
+
* and types to be supported without needing to manually specify all extensions
|
|
13
|
+
* within the build configuration.
|
|
14
|
+
*
|
|
15
|
+
* @returns An esbuild {@link Plugin} instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createCssResourcePlugin(): Plugin;
|
|
@@ -0,0 +1,59 @@
|
|
|
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.createCssResourcePlugin = void 0;
|
|
11
|
+
const promises_1 = require("fs/promises");
|
|
12
|
+
/**
|
|
13
|
+
* Symbol marker used to indicate CSS resource resolution is being attempted.
|
|
14
|
+
* This is used to prevent an infinite loop within the plugin's resolve hook.
|
|
15
|
+
*/
|
|
16
|
+
const CSS_RESOURCE_RESOLUTION = Symbol('CSS_RESOURCE_RESOLUTION');
|
|
17
|
+
/**
|
|
18
|
+
* Creates an esbuild {@link Plugin} that loads all CSS url token references using the
|
|
19
|
+
* built-in esbuild `file` loader. A plugin is used to allow for all file extensions
|
|
20
|
+
* and types to be supported without needing to manually specify all extensions
|
|
21
|
+
* within the build configuration.
|
|
22
|
+
*
|
|
23
|
+
* @returns An esbuild {@link Plugin} instance.
|
|
24
|
+
*/
|
|
25
|
+
function createCssResourcePlugin() {
|
|
26
|
+
return {
|
|
27
|
+
name: 'angular-css-resource',
|
|
28
|
+
setup(build) {
|
|
29
|
+
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
30
|
+
var _a;
|
|
31
|
+
// Only attempt to resolve url tokens which only exist inside CSS.
|
|
32
|
+
// Also, skip this plugin if already attempting to resolve the url-token.
|
|
33
|
+
if (args.kind !== 'url-token' || ((_a = args.pluginData) === null || _a === void 0 ? void 0 : _a[CSS_RESOURCE_RESOLUTION])) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const { importer, kind, resolveDir, namespace, pluginData = {} } = args;
|
|
37
|
+
pluginData[CSS_RESOURCE_RESOLUTION] = true;
|
|
38
|
+
const result = await build.resolve(args.path, {
|
|
39
|
+
importer,
|
|
40
|
+
kind,
|
|
41
|
+
namespace,
|
|
42
|
+
pluginData,
|
|
43
|
+
resolveDir,
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
...result,
|
|
47
|
+
namespace: 'css-resource',
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
build.onLoad({ filter: /.*/, namespace: 'css-resource' }, async (args) => {
|
|
51
|
+
return {
|
|
52
|
+
contents: await (0, promises_1.readFile)(args.path),
|
|
53
|
+
loader: 'file',
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.createCssResourcePlugin = createCssResourcePlugin;
|
|
@@ -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,
|
|
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,8 @@ 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,
|
|
143
|
+
externalDependencies: options.externalDependencies,
|
|
138
144
|
});
|
|
139
145
|
await (0, esbuild_1.logMessages)(context, sheetResult);
|
|
140
146
|
if (!sheetResult.path) {
|
|
@@ -239,6 +245,18 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
239
245
|
entryNames: outputNames.bundles,
|
|
240
246
|
assetNames: outputNames.media,
|
|
241
247
|
target: 'es2020',
|
|
248
|
+
supported: {
|
|
249
|
+
// Native async/await is not supported with Zone.js. Disabling support here will cause
|
|
250
|
+
// esbuild to downlevel async/await to a Zone.js supported form.
|
|
251
|
+
'async-await': false,
|
|
252
|
+
// Zone.js also does not support async generators or async iterators. However, esbuild does
|
|
253
|
+
// not currently support downleveling either of them. Instead babel is used within the JS/TS
|
|
254
|
+
// loader to perform the downlevel transformation. They are both disabled here to allow
|
|
255
|
+
// esbuild to handle them in the future if support is ever added.
|
|
256
|
+
// NOTE: If esbuild adds support in the future, the babel support for these can be disabled.
|
|
257
|
+
'async-generator': false,
|
|
258
|
+
'for-await': false,
|
|
259
|
+
},
|
|
242
260
|
mainFields: ['es2020', 'browser', 'module', 'main'],
|
|
243
261
|
conditions: ['es2020', 'es2015', 'module'],
|
|
244
262
|
resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
@@ -274,10 +292,11 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
274
292
|
!!sourcemapOptions.styles && (sourcemapOptions.hidden ? false : 'inline'),
|
|
275
293
|
outputNames,
|
|
276
294
|
includePaths: (_a = options.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths,
|
|
295
|
+
externalDependencies: options.externalDependencies,
|
|
277
296
|
}),
|
|
278
297
|
],
|
|
279
298
|
define: {
|
|
280
|
-
|
|
299
|
+
...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
|
|
281
300
|
'ngJitMode': 'false',
|
|
282
301
|
},
|
|
283
302
|
});
|
|
@@ -32,6 +32,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.bundleStylesheetText = exports.bundleStylesheetFile = void 0;
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
|
+
const css_resource_plugin_1 = require("./css-resource-plugin");
|
|
35
36
|
const esbuild_1 = require("./esbuild");
|
|
36
37
|
const sass_plugin_1 = require("./sass-plugin");
|
|
37
38
|
async function bundleStylesheet(entry, options) {
|
|
@@ -50,10 +51,12 @@ async function bundleStylesheet(entry, options) {
|
|
|
50
51
|
write: false,
|
|
51
52
|
platform: 'browser',
|
|
52
53
|
preserveSymlinks: options.preserveSymlinks,
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
external: options.externalDependencies,
|
|
55
|
+
conditions: ['style', 'sass'],
|
|
56
|
+
mainFields: ['style', 'sass'],
|
|
55
57
|
plugins: [
|
|
56
58
|
(0, sass_plugin_1.createSassPlugin)({ sourcemap: !!options.sourcemap, includePaths: options.includePaths }),
|
|
59
|
+
(0, css_resource_plugin_1.createCssResourcePlugin)(),
|
|
57
60
|
],
|
|
58
61
|
});
|
|
59
62
|
// Extract the result of the bundling from the output files
|
package/src/utils/error.js
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
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
|
|
53
|
-
if (!
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
63
|
+
stylesheetPath = fs.realpathSync(stylesheetPath);
|
|
61
64
|
}
|
|
62
65
|
// Add style entry points.
|
|
63
66
|
if (entryPoints[style.bundleName]) {
|
|
64
|
-
entryPoints[style.bundleName].push(
|
|
67
|
+
entryPoints[style.bundleName].push(stylesheetPath);
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
67
|
-
entryPoints[style.bundleName] = [
|
|
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(
|
|
77
|
+
paths.push(stylesheetPath);
|
|
75
78
|
}
|
|
76
79
|
return { entryPoints, noInjectNames, paths };
|
|
77
80
|
}
|
|
@@ -157,7 +157,7 @@ class NgBuildAnalyticsPlugin {
|
|
|
157
157
|
var _a, _b;
|
|
158
158
|
const chunkAssets = new Set();
|
|
159
159
|
for (const chunk of compilation.chunks) {
|
|
160
|
-
if (!chunk.rendered) {
|
|
160
|
+
if (!chunk.rendered || chunk.files.size === 0) {
|
|
161
161
|
continue;
|
|
162
162
|
}
|
|
163
163
|
const firstFile = Array.from(chunk.files)[0];
|
|
@@ -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;
|
|
@@ -131,7 +131,7 @@ function default_1(options) {
|
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
const value = decl.value;
|
|
134
|
-
const urlRegex = /url
|
|
134
|
+
const urlRegex = /url(?:\(\s*['"]?)(.*?)(?:['"]?\s*\))/g;
|
|
135
135
|
const segments = [];
|
|
136
136
|
let match;
|
|
137
137
|
let lastIndex = 0;
|
|
@@ -141,7 +141,7 @@ function default_1(options) {
|
|
|
141
141
|
const context = (inputFile && path.dirname(inputFile)) || loader.context;
|
|
142
142
|
// eslint-disable-next-line no-cond-assign
|
|
143
143
|
while ((match = urlRegex.exec(value))) {
|
|
144
|
-
const originalUrl = match[1]
|
|
144
|
+
const originalUrl = match[1];
|
|
145
145
|
let processedUrl;
|
|
146
146
|
try {
|
|
147
147
|
processedUrl = await process(originalUrl, context, resourceCache);
|