@angular-devkit/build-angular 14.1.0-next.4 → 14.1.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 +14 -14
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +1 -0
- package/src/builders/browser-esbuild/compiler-plugin.js +21 -10
- package/src/builders/browser-esbuild/esbuild.d.ts +0 -2
- package/src/builders/browser-esbuild/esbuild.js +1 -4
- package/src/builders/browser-esbuild/index.js +18 -8
- package/src/builders/browser-esbuild/sass-plugin.d.ts +12 -0
- package/src/builders/browser-esbuild/sass-plugin.js +52 -0
- package/src/builders/browser-esbuild/stylesheets.d.ts +2 -1
- package/src/builders/browser-esbuild/stylesheets.js +6 -5
- 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/devtools-ignore-plugin.d.ts +16 -0
- package/src/webpack/plugins/devtools-ignore-plugin.js +56 -0
- package/src/webpack/plugins/scripts-webpack-plugin.js +20 -6
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.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.1401.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1401.
|
|
12
|
-
"@angular-devkit/core": "14.1.
|
|
10
|
+
"@angular-devkit/architect": "0.1401.1",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1401.1",
|
|
12
|
+
"@angular-devkit/core": "14.1.1",
|
|
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.1",
|
|
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"
|
|
@@ -167,18 +167,25 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
167
167
|
const result = {};
|
|
168
168
|
// Create TypeScript compiler host
|
|
169
169
|
const host = typescript_1.default.createIncrementalCompilerHost(compilerOptions);
|
|
170
|
-
// Temporarily
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
// Temporarily process external resources via readResource.
|
|
171
|
+
// The AOT compiler currently requires this hook to allow for a transformResource hook.
|
|
172
|
+
// Once the AOT compiler allows only a transformResource hook, this can be reevaluated.
|
|
173
|
+
host.readResource = async function (fileName) {
|
|
174
|
+
var _a, _b, _c;
|
|
175
|
+
// Template resources (.html) files are not bundled or transformed
|
|
176
|
+
if (fileName.endsWith('.html')) {
|
|
177
|
+
return (_a = this.readFile(fileName)) !== null && _a !== void 0 ? _a : '';
|
|
178
|
+
}
|
|
179
|
+
const { contents, errors, warnings } = await (0, stylesheets_1.bundleStylesheetFile)(fileName, styleOptions);
|
|
180
|
+
((_b = result.errors) !== null && _b !== void 0 ? _b : (result.errors = [])).push(...errors);
|
|
181
|
+
((_c = result.warnings) !== null && _c !== void 0 ? _c : (result.warnings = [])).push(...warnings);
|
|
182
|
+
return contents;
|
|
176
183
|
};
|
|
177
184
|
// Add an AOT compiler resource transform hook
|
|
178
185
|
host.transformResource = async function (data, context) {
|
|
179
186
|
var _a, _b, _c;
|
|
180
|
-
// Only style resources are transformed currently
|
|
181
|
-
if (context.type !== 'style') {
|
|
187
|
+
// Only inline style resources are transformed separately currently
|
|
188
|
+
if (context.resourceFile || context.type !== 'style') {
|
|
182
189
|
return null;
|
|
183
190
|
}
|
|
184
191
|
// The file with the resource content will either be an actual file (resourceFile)
|
|
@@ -256,10 +263,12 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
256
263
|
],
|
|
257
264
|
};
|
|
258
265
|
}
|
|
266
|
+
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
267
|
+
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
259
268
|
const data = (_a = typescriptResult.content) !== null && _a !== void 0 ? _a : '';
|
|
260
269
|
const babelResult = await (0, core_1.transformAsync)(data, {
|
|
261
270
|
filename: args.path,
|
|
262
|
-
inputSourceMap: (
|
|
271
|
+
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
263
272
|
sourceMaps: pluginOptions.sourcemap ? 'inline' : false,
|
|
264
273
|
compact: false,
|
|
265
274
|
configFile: false,
|
|
@@ -285,10 +294,12 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
285
294
|
var _a;
|
|
286
295
|
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(args.path);
|
|
287
296
|
const linkerPluginCreator = (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
297
|
+
const useInputSourcemap = pluginOptions.sourcemap &&
|
|
298
|
+
(!!pluginOptions.thirdPartySourcemaps || !/[\\/]node_modules[\\/]/.test(args.path));
|
|
288
299
|
const data = await fs_1.promises.readFile(args.path, 'utf-8');
|
|
289
300
|
const result = await (0, core_1.transformAsync)(data, {
|
|
290
301
|
filename: args.path,
|
|
291
|
-
inputSourceMap: (
|
|
302
|
+
inputSourceMap: (useInputSourcemap ? undefined : false),
|
|
292
303
|
sourceMaps: pluginOptions.sourcemap ? 'inline' : false,
|
|
293
304
|
compact: false,
|
|
294
305
|
configFile: false,
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
9
|
import { BuildFailure, BuildOptions, BuildResult, Message, OutputFile } from 'esbuild';
|
|
10
|
-
/** Default outdir setting for esbuild. */
|
|
11
|
-
export declare const DEFAULT_OUTDIR: string;
|
|
12
10
|
/**
|
|
13
11
|
* Determines if an unknown value is an esbuild BuildFailure error object thrown by esbuild.
|
|
14
12
|
* @param value A potential esbuild BuildFailure error object.
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.logMessages = exports.bundle = exports.isEsBuildFailure =
|
|
10
|
+
exports.logMessages = exports.bundle = exports.isEsBuildFailure = void 0;
|
|
11
11
|
const esbuild_1 = require("esbuild");
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
/** Default outdir setting for esbuild. */
|
|
14
|
-
exports.DEFAULT_OUTDIR = (0, path_1.resolve)('/virtual-output');
|
|
15
12
|
/**
|
|
16
13
|
* Determines if an unknown value is an esbuild BuildFailure error object thrown by esbuild.
|
|
17
14
|
* @param value A potential esbuild BuildFailure error object.
|
|
@@ -57,7 +57,7 @@ const stylesheets_1 = require("./stylesheets");
|
|
|
57
57
|
*/
|
|
58
58
|
// eslint-disable-next-line max-lines-per-function
|
|
59
59
|
async function buildEsbuildBrowser(options, context) {
|
|
60
|
-
var _a, _b, _c, _d, _e, _f;
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
61
61
|
const startTime = Date.now();
|
|
62
62
|
// Only AOT is currently supported
|
|
63
63
|
if (options.aot !== true) {
|
|
@@ -101,7 +101,7 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
101
101
|
// Entries in the metafile are relative to the `absWorkingDir` option which is set to the workspaceRoot
|
|
102
102
|
const relativeFilePath = path.relative(workspaceRoot, outputFile.path);
|
|
103
103
|
const entryPoint = (_c = (_b = result.metafile) === null || _b === void 0 ? void 0 : _b.outputs[relativeFilePath]) === null || _c === void 0 ? void 0 : _c.entryPoint;
|
|
104
|
-
outputFile.path =
|
|
104
|
+
outputFile.path = relativeFilePath;
|
|
105
105
|
if (entryPoint) {
|
|
106
106
|
// An entryPoint value indicates an initial file
|
|
107
107
|
initialFiles.push({
|
|
@@ -124,15 +124,22 @@ 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, '/')}';`)
|
|
131
135
|
.join('\n');
|
|
132
136
|
const sheetResult = await (0, stylesheets_1.bundleStylesheetText)(virtualEntryData, { virtualName: `angular:style/global;${name}`, resolvePath: workspaceRoot }, {
|
|
137
|
+
workspaceRoot,
|
|
133
138
|
optimization: !!optimizationOptions.styles.minify,
|
|
134
|
-
sourcemap: !!sourcemapOptions.styles,
|
|
139
|
+
sourcemap: !!sourcemapOptions.styles && (sourcemapOptions.hidden ? 'external' : true),
|
|
135
140
|
outputNames: noInjectNames.includes(name) ? { media: outputNames.media } : outputNames,
|
|
141
|
+
includePaths: (_e = options.stylePreprocessorOptions) === null || _e === void 0 ? void 0 : _e.includePaths,
|
|
142
|
+
preserveSymlinks: options.preserveSymlinks,
|
|
136
143
|
});
|
|
137
144
|
await (0, esbuild_1.logMessages)(context, sheetResult);
|
|
138
145
|
if (!sheetResult.path) {
|
|
@@ -161,8 +168,8 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
161
168
|
// Generate index HTML file
|
|
162
169
|
if (options.index) {
|
|
163
170
|
const entrypoints = (0, package_chunk_sort_1.generateEntryPoints)({
|
|
164
|
-
scripts: (
|
|
165
|
-
styles: (
|
|
171
|
+
scripts: (_f = options.scripts) !== null && _f !== void 0 ? _f : [],
|
|
172
|
+
styles: (_g = options.styles) !== null && _g !== void 0 ? _g : [],
|
|
166
173
|
});
|
|
167
174
|
// Create an index HTML generator that reads from the in-memory output files
|
|
168
175
|
const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
|
|
@@ -228,6 +235,7 @@ function createOutputFileFromText(path, text) {
|
|
|
228
235
|
};
|
|
229
236
|
}
|
|
230
237
|
async function bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig) {
|
|
238
|
+
var _a;
|
|
231
239
|
return (0, esbuild_1.bundle)({
|
|
232
240
|
absWorkingDir: workspaceRoot,
|
|
233
241
|
bundle: true,
|
|
@@ -243,7 +251,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
243
251
|
metafile: true,
|
|
244
252
|
minify: optimizationOptions.scripts,
|
|
245
253
|
pure: ['forwardRef'],
|
|
246
|
-
outdir:
|
|
254
|
+
outdir: workspaceRoot,
|
|
247
255
|
sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
|
|
248
256
|
splitting: true,
|
|
249
257
|
tsconfig,
|
|
@@ -256,6 +264,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
256
264
|
// JS/TS options
|
|
257
265
|
{
|
|
258
266
|
sourcemap: !!sourcemapOptions.scripts,
|
|
267
|
+
thirdPartySourcemaps: sourcemapOptions.vendor,
|
|
259
268
|
tsconfig,
|
|
260
269
|
advancedOptimizations: options.buildOptimizer,
|
|
261
270
|
},
|
|
@@ -269,10 +278,11 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
269
278
|
// of sourcemap processing.
|
|
270
279
|
!!sourcemapOptions.styles && (sourcemapOptions.hidden ? false : 'inline'),
|
|
271
280
|
outputNames,
|
|
281
|
+
includePaths: (_a = options.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths,
|
|
272
282
|
}),
|
|
273
283
|
],
|
|
274
284
|
define: {
|
|
275
|
-
|
|
285
|
+
...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
|
|
276
286
|
'ngJitMode': 'false',
|
|
277
287
|
},
|
|
278
288
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
export declare function createSassPlugin(options: {
|
|
10
|
+
sourcemap: boolean;
|
|
11
|
+
includePaths?: string[];
|
|
12
|
+
}): Plugin;
|
|
@@ -0,0 +1,52 @@
|
|
|
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.createSassPlugin = void 0;
|
|
11
|
+
const sass_service_1 = require("../../sass/sass-service");
|
|
12
|
+
function createSassPlugin(options) {
|
|
13
|
+
return {
|
|
14
|
+
name: 'angular-sass',
|
|
15
|
+
setup(build) {
|
|
16
|
+
let sass;
|
|
17
|
+
build.onStart(() => {
|
|
18
|
+
sass = new sass_service_1.SassWorkerImplementation();
|
|
19
|
+
});
|
|
20
|
+
build.onEnd(() => {
|
|
21
|
+
sass === null || sass === void 0 ? void 0 : sass.close();
|
|
22
|
+
});
|
|
23
|
+
build.onLoad({ filter: /\.s[ac]ss$/ }, async (args) => {
|
|
24
|
+
const result = await new Promise((resolve, reject) => {
|
|
25
|
+
sass.render({
|
|
26
|
+
file: args.path,
|
|
27
|
+
includePaths: options.includePaths,
|
|
28
|
+
indentedSyntax: args.path.endsWith('.sass'),
|
|
29
|
+
outputStyle: 'expanded',
|
|
30
|
+
sourceMap: options.sourcemap,
|
|
31
|
+
sourceMapContents: options.sourcemap,
|
|
32
|
+
sourceMapEmbed: options.sourcemap,
|
|
33
|
+
quietDeps: true,
|
|
34
|
+
}, (error, result) => {
|
|
35
|
+
if (error) {
|
|
36
|
+
reject(error);
|
|
37
|
+
}
|
|
38
|
+
if (result) {
|
|
39
|
+
resolve(result);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
contents: result.css,
|
|
45
|
+
loader: 'css',
|
|
46
|
+
watchFiles: result.stats.includedFiles,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.createSassPlugin = createSassPlugin;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { OutputFile } from 'esbuild';
|
|
9
9
|
export interface BundleStylesheetOptions {
|
|
10
|
-
workspaceRoot
|
|
10
|
+
workspaceRoot: string;
|
|
11
11
|
optimization: boolean;
|
|
12
12
|
preserveSymlinks?: boolean;
|
|
13
13
|
sourcemap: boolean | 'external' | 'inline';
|
|
@@ -15,6 +15,7 @@ export interface BundleStylesheetOptions {
|
|
|
15
15
|
bundles?: string;
|
|
16
16
|
media?: string;
|
|
17
17
|
};
|
|
18
|
+
includePaths?: string[];
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Bundle a stylesheet that exists as a file on the filesystem.
|
|
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
exports.bundleStylesheetText = exports.bundleStylesheetFile = void 0;
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
35
|
const esbuild_1 = require("./esbuild");
|
|
36
|
+
const sass_plugin_1 = require("./sass-plugin");
|
|
36
37
|
async function bundleStylesheet(entry, options) {
|
|
37
38
|
var _a, _b;
|
|
38
39
|
// Execute esbuild
|
|
@@ -45,14 +46,14 @@ async function bundleStylesheet(entry, options) {
|
|
|
45
46
|
logLevel: 'silent',
|
|
46
47
|
minify: options.optimization,
|
|
47
48
|
sourcemap: options.sourcemap,
|
|
48
|
-
outdir:
|
|
49
|
+
outdir: options.workspaceRoot,
|
|
49
50
|
write: false,
|
|
50
51
|
platform: 'browser',
|
|
51
52
|
preserveSymlinks: options.preserveSymlinks,
|
|
52
|
-
conditions: ['style'],
|
|
53
|
-
mainFields: ['style'],
|
|
53
|
+
conditions: ['style', 'sass'],
|
|
54
|
+
mainFields: ['style', 'sass'],
|
|
54
55
|
plugins: [
|
|
55
|
-
|
|
56
|
+
(0, sass_plugin_1.createSassPlugin)({ sourcemap: !!options.sourcemap, includePaths: options.includePaths }),
|
|
56
57
|
],
|
|
57
58
|
});
|
|
58
59
|
// Extract the result of the bundling from the output files
|
|
@@ -62,7 +63,7 @@ async function bundleStylesheet(entry, options) {
|
|
|
62
63
|
const resourceFiles = [];
|
|
63
64
|
if (result.outputFiles) {
|
|
64
65
|
for (const outputFile of result.outputFiles) {
|
|
65
|
-
outputFile.path = path.relative(
|
|
66
|
+
outputFile.path = path.relative(options.workspaceRoot, outputFile.path);
|
|
66
67
|
const filename = path.basename(outputFile.path);
|
|
67
68
|
if (filename.endsWith('.css')) {
|
|
68
69
|
outputPath = outputFile.path;
|
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
|
}
|
|
@@ -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;
|
|
@@ -35,6 +35,10 @@ const loader_utils_1 = require("loader-utils");
|
|
|
35
35
|
const path = __importStar(require("path"));
|
|
36
36
|
const webpack_1 = require("webpack");
|
|
37
37
|
const Entrypoint = require('webpack/lib/Entrypoint');
|
|
38
|
+
/**
|
|
39
|
+
* The name of the plugin provided to Webpack when tapping Webpack compiler hooks.
|
|
40
|
+
*/
|
|
41
|
+
const PLUGIN_NAME = 'scripts-webpack-plugin';
|
|
38
42
|
function addDependencies(compilation, scripts) {
|
|
39
43
|
for (const script of scripts) {
|
|
40
44
|
compilation.fileDependencies.add(script);
|
|
@@ -88,8 +92,8 @@ class ScriptsWebpackPlugin {
|
|
|
88
92
|
const scripts = this.options.scripts
|
|
89
93
|
.filter((script) => !!script)
|
|
90
94
|
.map((script) => path.resolve(this.options.basePath || '', script));
|
|
91
|
-
compiler.hooks.thisCompilation.tap(
|
|
92
|
-
compilation.hooks.additionalAssets.tapPromise(
|
|
95
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
96
|
+
compilation.hooks.additionalAssets.tapPromise(PLUGIN_NAME, async () => {
|
|
93
97
|
if (await this.shouldSkip(compilation, scripts)) {
|
|
94
98
|
if (this._cachedOutput) {
|
|
95
99
|
this._insertOutput(compilation, this._cachedOutput, true);
|
|
@@ -129,14 +133,24 @@ class ScriptsWebpackPlugin {
|
|
|
129
133
|
concatSource.add('\n;');
|
|
130
134
|
});
|
|
131
135
|
const combinedSource = new webpack_1.sources.CachedSource(concatSource);
|
|
132
|
-
const
|
|
133
|
-
content: combinedSource.source(),
|
|
134
|
-
});
|
|
135
|
-
const output = { filename, source: combinedSource };
|
|
136
|
+
const output = { filename: this.options.filename, source: combinedSource };
|
|
136
137
|
this._insertOutput(compilation, output);
|
|
137
138
|
this._cachedOutput = output;
|
|
138
139
|
addDependencies(compilation, scripts);
|
|
139
140
|
});
|
|
141
|
+
compilation.hooks.processAssets.tapPromise({
|
|
142
|
+
name: PLUGIN_NAME,
|
|
143
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
|
|
144
|
+
}, async () => {
|
|
145
|
+
const assetName = this.options.filename;
|
|
146
|
+
const asset = compilation.getAsset(assetName);
|
|
147
|
+
if (asset) {
|
|
148
|
+
const interpolatedFilename = (0, loader_utils_1.interpolateName)({ resourcePath: 'scripts.js' }, assetName, { content: asset.source.source() });
|
|
149
|
+
if (assetName !== interpolatedFilename) {
|
|
150
|
+
compilation.renameAsset(assetName, interpolatedFilename);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
140
154
|
});
|
|
141
155
|
}
|
|
142
156
|
}
|