@angular-devkit/build-angular 14.1.0-next.2 → 14.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +23 -23
- package/src/builders/app-shell/index.js +2 -2
- package/src/builders/browser/index.d.ts +9 -1
- package/src/builders/browser/index.js +15 -3
- 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 +16 -7
- 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 +3 -2
- package/src/builders/browser-esbuild/stylesheets.js +4 -3
- package/src/builders/karma/find-tests.js +2 -0
- package/src/builders/server/index.d.ts +8 -1
- package/src/builders/server/index.js +7 -0
- package/src/utils/color.js +0 -1
- package/src/utils/copy-assets.js +5 -4
- package/src/utils/i18n-options.js +7 -12
- package/src/webpack/configs/dev-server.js +4 -0
- package/src/webpack/plugins/common-js-usage-warn-plugin.js +6 -1
- package/src/webpack/plugins/scripts-webpack-plugin.js +20 -6
- package/src/webpack/plugins/typescript.js +1 -5
- package/src/webpack/utils/helpers.d.ts +2 -3
- package/src/webpack/utils/helpers.js +4 -3
- package/src/webpack/utils/stats.d.ts +3 -2
- package/src/webpack/utils/stats.js +22 -5
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "14.1.0-
|
|
3
|
+
"version": "14.1.0-rc.3",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.2.0",
|
|
10
|
-
"@angular-devkit/architect": "0.1401.0-
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1401.0-
|
|
12
|
-
"@angular-devkit/core": "14.1.0-
|
|
13
|
-
"@babel/core": "7.18.
|
|
14
|
-
"@babel/generator": "7.18.
|
|
15
|
-
"@babel/helper-annotate-as-pure": "7.
|
|
16
|
-
"@babel/plugin-proposal-async-generator-functions": "7.
|
|
17
|
-
"@babel/plugin-transform-async-to-generator": "7.
|
|
18
|
-
"@babel/plugin-transform-runtime": "7.18.
|
|
19
|
-
"@babel/preset-env": "7.18.
|
|
20
|
-
"@babel/runtime": "7.18.
|
|
21
|
-
"@babel/template": "7.
|
|
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",
|
|
15
|
+
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
16
|
+
"@babel/plugin-proposal-async-generator-functions": "7.18.6",
|
|
17
|
+
"@babel/plugin-transform-async-to-generator": "7.18.6",
|
|
18
|
+
"@babel/plugin-transform-runtime": "7.18.6",
|
|
19
|
+
"@babel/preset-env": "7.18.6",
|
|
20
|
+
"@babel/runtime": "7.18.6",
|
|
21
|
+
"@babel/template": "7.18.6",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "14.1.0-
|
|
23
|
+
"@ngtools/webpack": "14.1.0-rc.3",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"babel-loader": "8.2.5",
|
|
26
26
|
"babel-plugin-istanbul": "6.1.1",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"copy-webpack-plugin": "11.0.0",
|
|
30
30
|
"critters": "0.0.16",
|
|
31
31
|
"css-loader": "6.7.1",
|
|
32
|
-
"esbuild-wasm": "0.14.
|
|
32
|
+
"esbuild-wasm": "0.14.48",
|
|
33
33
|
"glob": "8.0.3",
|
|
34
34
|
"https-proxy-agent": "5.0.1",
|
|
35
35
|
"inquirer": "8.2.4",
|
|
36
36
|
"jsonc-parser": "3.0.0",
|
|
37
37
|
"karma-source-map-support": "1.4.0",
|
|
38
|
-
"less": "4.1.
|
|
38
|
+
"less": "4.1.3",
|
|
39
39
|
"less-loader": "11.0.0",
|
|
40
40
|
"license-webpack-plugin": "4.0.2",
|
|
41
41
|
"loader-utils": "3.2.0",
|
|
42
|
-
"mini-css-extract-plugin": "2.6.
|
|
42
|
+
"mini-css-extract-plugin": "2.6.1",
|
|
43
43
|
"minimatch": "5.1.0",
|
|
44
44
|
"open": "8.4.0",
|
|
45
45
|
"ora": "5.4.1",
|
|
@@ -48,29 +48,29 @@
|
|
|
48
48
|
"postcss": "8.4.14",
|
|
49
49
|
"postcss-import": "14.1.0",
|
|
50
50
|
"postcss-loader": "7.0.0",
|
|
51
|
-
"postcss-preset-env": "7.7.
|
|
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.
|
|
56
|
-
"sass-loader": "13.0.
|
|
55
|
+
"sass": "1.53.0",
|
|
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.
|
|
62
|
+
"terser": "5.14.1",
|
|
63
63
|
"text-table": "0.2.0",
|
|
64
64
|
"tree-kill": "1.2.2",
|
|
65
65
|
"tslib": "2.4.0",
|
|
66
66
|
"webpack": "5.73.0",
|
|
67
67
|
"webpack-dev-middleware": "5.3.3",
|
|
68
|
-
"webpack-dev-server": "4.9.
|
|
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.
|
|
73
|
+
"esbuild": "0.14.48"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"@angular/compiler-cli": "^14.0.0 || ^14.0.0-next || ^14.1.0-next",
|
|
@@ -62,7 +62,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
62
62
|
deployUrl: browserOptions.deployUrl,
|
|
63
63
|
})
|
|
64
64
|
: undefined;
|
|
65
|
-
for (const outputPath of browserResult.
|
|
65
|
+
for (const { path: outputPath, baseHref } of browserResult.outputs) {
|
|
66
66
|
const localeDirectory = path.relative(browserResult.baseOutputPath, outputPath);
|
|
67
67
|
const browserIndexOutputPath = path.join(outputPath, 'index.html');
|
|
68
68
|
const indexHtml = await fs.promises.readFile(browserIndexOutputPath, 'utf8');
|
|
@@ -96,7 +96,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
96
96
|
}
|
|
97
97
|
await fs.promises.writeFile(outputIndexPath, html);
|
|
98
98
|
if (browserOptions.serviceWorker) {
|
|
99
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath,
|
|
99
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, baseHref !== null && baseHref !== void 0 ? baseHref : '/', browserOptions.ngswConfigPath);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
return browserResult;
|
|
@@ -17,11 +17,19 @@ import { Schema as BrowserBuilderSchema } from './schema';
|
|
|
17
17
|
*/
|
|
18
18
|
export declare type BrowserBuilderOutput = BuilderOutput & {
|
|
19
19
|
baseOutputPath: string;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated in version 14. Use 'outputs' instead.
|
|
22
|
+
*/
|
|
20
23
|
outputPaths: string[];
|
|
21
24
|
/**
|
|
22
|
-
* @deprecated in version 9. Use '
|
|
25
|
+
* @deprecated in version 9. Use 'outputs' instead.
|
|
23
26
|
*/
|
|
24
27
|
outputPath: string;
|
|
28
|
+
outputs: {
|
|
29
|
+
locale?: string;
|
|
30
|
+
path: string;
|
|
31
|
+
baseHref?: string;
|
|
32
|
+
}[];
|
|
25
33
|
};
|
|
26
34
|
/**
|
|
27
35
|
* Maximum time in milliseconds for single build/rebuild
|
|
@@ -128,7 +128,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
128
128
|
}
|
|
129
129
|
}),
|
|
130
130
|
}).pipe((0, operators_1.concatMap)(async (buildEvent) => {
|
|
131
|
-
var _a, _b, _c, _d, _e;
|
|
131
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
132
132
|
const spinner = new spinner_1.Spinner();
|
|
133
133
|
spinner.enabled = options.progress !== false;
|
|
134
134
|
const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
|
|
@@ -218,7 +218,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
218
218
|
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
219
219
|
try {
|
|
220
220
|
const { content, warnings, errors } = await indexHtmlGenerator.process({
|
|
221
|
-
baseHref: getLocaleBaseHref(i18n, locale)
|
|
221
|
+
baseHref: (_f = getLocaleBaseHref(i18n, locale)) !== null && _f !== void 0 ? _f : options.baseHref,
|
|
222
222
|
// i18nLocale is used when Ivy is disabled
|
|
223
223
|
lang: locale || undefined,
|
|
224
224
|
outputPath,
|
|
@@ -254,7 +254,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
254
254
|
spinner.start('Generating service worker...');
|
|
255
255
|
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
256
256
|
try {
|
|
257
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, getLocaleBaseHref(i18n, locale)
|
|
257
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, (_h = (_g = getLocaleBaseHref(i18n, locale)) !== null && _g !== void 0 ? _g : options.baseHref) !== null && _h !== void 0 ? _h : '/', options.ngswConfigPath);
|
|
258
258
|
}
|
|
259
259
|
catch (error) {
|
|
260
260
|
spinner.fail('Service worker generation failed.');
|
|
@@ -272,6 +272,18 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
272
272
|
baseOutputPath,
|
|
273
273
|
outputPath: baseOutputPath,
|
|
274
274
|
outputPaths: (outputPaths && Array.from(outputPaths.values())) || [baseOutputPath],
|
|
275
|
+
outputs: (outputPaths &&
|
|
276
|
+
[...outputPaths.entries()].map(([locale, path]) => {
|
|
277
|
+
var _a;
|
|
278
|
+
return ({
|
|
279
|
+
locale,
|
|
280
|
+
path,
|
|
281
|
+
baseHref: (_a = getLocaleBaseHref(i18n, locale)) !== null && _a !== void 0 ? _a : options.baseHref,
|
|
282
|
+
});
|
|
283
|
+
})) || {
|
|
284
|
+
path: baseOutputPath,
|
|
285
|
+
baseHref: options.baseHref,
|
|
286
|
+
},
|
|
275
287
|
})));
|
|
276
288
|
}));
|
|
277
289
|
function getLocaleBaseHref(i18n, locale) {
|
|
@@ -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({
|
|
@@ -130,9 +130,11 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
130
130
|
.map((file) => `@import '${file.replace(/\\/g, '/')}';`)
|
|
131
131
|
.join('\n');
|
|
132
132
|
const sheetResult = await (0, stylesheets_1.bundleStylesheetText)(virtualEntryData, { virtualName: `angular:style/global;${name}`, resolvePath: workspaceRoot }, {
|
|
133
|
+
workspaceRoot,
|
|
133
134
|
optimization: !!optimizationOptions.styles.minify,
|
|
134
|
-
sourcemap: !!sourcemapOptions.styles,
|
|
135
|
+
sourcemap: !!sourcemapOptions.styles && (sourcemapOptions.hidden ? 'external' : true),
|
|
135
136
|
outputNames: noInjectNames.includes(name) ? { media: outputNames.media } : outputNames,
|
|
137
|
+
includePaths: (_e = options.stylePreprocessorOptions) === null || _e === void 0 ? void 0 : _e.includePaths,
|
|
136
138
|
});
|
|
137
139
|
await (0, esbuild_1.logMessages)(context, sheetResult);
|
|
138
140
|
if (!sheetResult.path) {
|
|
@@ -161,8 +163,8 @@ async function buildEsbuildBrowser(options, context) {
|
|
|
161
163
|
// Generate index HTML file
|
|
162
164
|
if (options.index) {
|
|
163
165
|
const entrypoints = (0, package_chunk_sort_1.generateEntryPoints)({
|
|
164
|
-
scripts: (
|
|
165
|
-
styles: (
|
|
166
|
+
scripts: (_f = options.scripts) !== null && _f !== void 0 ? _f : [],
|
|
167
|
+
styles: (_g = options.styles) !== null && _g !== void 0 ? _g : [],
|
|
166
168
|
});
|
|
167
169
|
// Create an index HTML generator that reads from the in-memory output files
|
|
168
170
|
const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
|
|
@@ -228,6 +230,7 @@ function createOutputFileFromText(path, text) {
|
|
|
228
230
|
};
|
|
229
231
|
}
|
|
230
232
|
async function bundleCode(workspaceRoot, entryPoints, outputNames, options, optimizationOptions, sourcemapOptions, tsconfig) {
|
|
233
|
+
var _a;
|
|
231
234
|
return (0, esbuild_1.bundle)({
|
|
232
235
|
absWorkingDir: workspaceRoot,
|
|
233
236
|
bundle: true,
|
|
@@ -243,7 +246,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
243
246
|
metafile: true,
|
|
244
247
|
minify: optimizationOptions.scripts,
|
|
245
248
|
pure: ['forwardRef'],
|
|
246
|
-
outdir:
|
|
249
|
+
outdir: workspaceRoot,
|
|
247
250
|
sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
|
|
248
251
|
splitting: true,
|
|
249
252
|
tsconfig,
|
|
@@ -256,6 +259,7 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
256
259
|
// JS/TS options
|
|
257
260
|
{
|
|
258
261
|
sourcemap: !!sourcemapOptions.scripts,
|
|
262
|
+
thirdPartySourcemaps: sourcemapOptions.vendor,
|
|
259
263
|
tsconfig,
|
|
260
264
|
advancedOptimizations: options.buildOptimizer,
|
|
261
265
|
},
|
|
@@ -263,8 +267,13 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
263
267
|
{
|
|
264
268
|
workspaceRoot,
|
|
265
269
|
optimization: !!optimizationOptions.styles.minify,
|
|
266
|
-
sourcemap:
|
|
270
|
+
sourcemap:
|
|
271
|
+
// Hidden component stylesheet sourcemaps are inaccessible which is effectively
|
|
272
|
+
// the same as being disabled. Disabling has the advantage of avoiding the overhead
|
|
273
|
+
// of sourcemap processing.
|
|
274
|
+
!!sourcemapOptions.styles && (sourcemapOptions.hidden ? false : 'inline'),
|
|
267
275
|
outputNames,
|
|
276
|
+
includePaths: (_a = options.stylePreprocessorOptions) === null || _a === void 0 ? void 0 : _a.includePaths,
|
|
268
277
|
}),
|
|
269
278
|
],
|
|
270
279
|
define: {
|
|
@@ -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,14 +7,15 @@
|
|
|
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
|
-
sourcemap: boolean | 'external';
|
|
13
|
+
sourcemap: boolean | 'external' | 'inline';
|
|
14
14
|
outputNames?: {
|
|
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
53
|
conditions: ['style'],
|
|
53
54
|
mainFields: ['style'],
|
|
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;
|
|
@@ -15,11 +15,18 @@ import { Schema as ServerBuilderOptions } from './schema';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare type ServerBuilderOutput = BuilderOutput & {
|
|
17
17
|
baseOutputPath: string;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated in version 14. Use 'outputs' instead.
|
|
20
|
+
*/
|
|
18
21
|
outputPaths: string[];
|
|
19
22
|
/**
|
|
20
|
-
* @deprecated in version 9. Use '
|
|
23
|
+
* @deprecated in version 9. Use 'outputs' instead.
|
|
21
24
|
*/
|
|
22
25
|
outputPath: string;
|
|
26
|
+
outputs: {
|
|
27
|
+
locale?: string;
|
|
28
|
+
path: string;
|
|
29
|
+
}[];
|
|
23
30
|
};
|
|
24
31
|
export { ServerBuilderOptions };
|
|
25
32
|
/**
|
|
@@ -102,6 +102,13 @@ function execute(options, context, transforms = {}) {
|
|
|
102
102
|
baseOutputPath,
|
|
103
103
|
outputPath: baseOutputPath,
|
|
104
104
|
outputPaths: outputPaths || [baseOutputPath],
|
|
105
|
+
outputs: (outputPaths &&
|
|
106
|
+
[...outputPaths.entries()].map(([locale, path]) => ({
|
|
107
|
+
locale,
|
|
108
|
+
path,
|
|
109
|
+
}))) || {
|
|
110
|
+
path: baseOutputPath,
|
|
111
|
+
},
|
|
105
112
|
};
|
|
106
113
|
}));
|
|
107
114
|
}
|
package/src/utils/color.js
CHANGED
|
@@ -64,7 +64,6 @@ function removeColor(text) {
|
|
|
64
64
|
}
|
|
65
65
|
exports.removeColor = removeColor;
|
|
66
66
|
// Create a separate instance to prevent unintended global changes to the color configuration
|
|
67
|
-
// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
|
|
68
67
|
const colors = ansiColors.create();
|
|
69
68
|
exports.colors = colors;
|
|
70
69
|
colors.enabled = supportColor();
|
package/src/utils/copy-assets.js
CHANGED
|
@@ -37,17 +37,18 @@ exports.copyAssets = void 0;
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const glob_1 = __importDefault(require("glob"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
40
|
+
const util_1 = require("util");
|
|
41
|
+
const globPromise = (0, util_1.promisify)(glob_1.default);
|
|
43
42
|
async function copyAssets(entries, basePaths, root, changed) {
|
|
44
43
|
const defaultIgnore = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db'];
|
|
45
44
|
for (const entry of entries) {
|
|
46
45
|
const cwd = path.resolve(root, entry.input);
|
|
47
|
-
const files = await
|
|
46
|
+
const files = await globPromise(entry.glob, {
|
|
48
47
|
cwd,
|
|
49
48
|
dot: true,
|
|
50
49
|
nodir: true,
|
|
50
|
+
root: cwd,
|
|
51
|
+
nomount: true,
|
|
51
52
|
ignore: entry.ignore ? defaultIgnore.concat(entry.ignore) : defaultIgnore,
|
|
52
53
|
follow: entry.followSymlinks,
|
|
53
54
|
});
|
|
@@ -175,13 +175,15 @@ async function configureI18nBuild(context, options) {
|
|
|
175
175
|
}
|
|
176
176
|
// If inlining store the output in a temporary location to facilitate post-processing
|
|
177
177
|
if (i18n.shouldInline) {
|
|
178
|
+
// TODO: we should likely save these in the .angular directory in the next major version.
|
|
179
|
+
// We'd need to do a migration to add the temp directory to gitignore.
|
|
178
180
|
const tempPath = fs_1.default.mkdtempSync(path_1.default.join(fs_1.default.realpathSync(os_1.default.tmpdir()), 'angular-cli-i18n-'));
|
|
179
181
|
buildOptions.outputPath = tempPath;
|
|
180
|
-
process.on('exit', () =>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
process.on('exit', () => {
|
|
183
|
+
try {
|
|
184
|
+
fs_1.default.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
|
|
185
|
+
}
|
|
186
|
+
catch { }
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
return { buildOptions, i18n };
|
|
@@ -198,13 +200,6 @@ function findLocaleDataPath(locale, resolver) {
|
|
|
198
200
|
return scrubbedLocale === 'en-US' ? findLocaleDataPath('en', resolver) : null;
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
|
-
/** Remove temporary directory used for i18n processing. */
|
|
202
|
-
function deleteTempDirectory(tempPath) {
|
|
203
|
-
try {
|
|
204
|
-
fs_1.default.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
|
|
205
|
-
}
|
|
206
|
-
catch { }
|
|
207
|
-
}
|
|
208
203
|
function loadTranslations(locale, desc, workspaceRoot, loader, logger, usedFormats, duplicateTranslation) {
|
|
209
204
|
let translations = undefined;
|
|
210
205
|
for (const file of desc.files) {
|
|
@@ -86,6 +86,10 @@ async function getDevServerConfig(wco) {
|
|
|
86
86
|
},
|
|
87
87
|
],
|
|
88
88
|
},
|
|
89
|
+
// When setupExitSignals is enabled webpack-dev-server will shutdown gracefully which would
|
|
90
|
+
// require CTRL+C to be pressed multiple times to exit.
|
|
91
|
+
// See: https://github.com/webpack/webpack-dev-server/blob/c76b6d11a3821436c5e20207c8a38deb6ab7e33c/lib/Server.js#L1801-L1827
|
|
92
|
+
setupExitSignals: false,
|
|
89
93
|
compress: false,
|
|
90
94
|
static: false,
|
|
91
95
|
server: getServerConfig(root, wco.buildOptions),
|
|
@@ -12,7 +12,9 @@ const path_1 = require("path");
|
|
|
12
12
|
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
13
13
|
// Webpack doesn't export these so the deep imports can potentially break.
|
|
14
14
|
const AMDDefineDependency = require('webpack/lib/dependencies/AMDDefineDependency');
|
|
15
|
+
const CommonJsExportsDependency = require('webpack/lib/dependencies/CommonJsExportsDependency');
|
|
15
16
|
const CommonJsRequireDependency = require('webpack/lib/dependencies/CommonJsRequireDependency');
|
|
17
|
+
const CommonJsSelfReferenceDependency = require('webpack/lib/dependencies/CommonJsSelfReferenceDependency');
|
|
16
18
|
class CommonJsUsageWarnPlugin {
|
|
17
19
|
constructor(options = {}) {
|
|
18
20
|
this.options = options;
|
|
@@ -81,7 +83,10 @@ class CommonJsUsageWarnPlugin {
|
|
|
81
83
|
}
|
|
82
84
|
hasCommonJsDependencies(compilation, dependencies, checkParentModules = false) {
|
|
83
85
|
for (const dep of dependencies) {
|
|
84
|
-
if (dep instanceof CommonJsRequireDependency ||
|
|
86
|
+
if (dep instanceof CommonJsRequireDependency ||
|
|
87
|
+
dep instanceof CommonJsExportsDependency ||
|
|
88
|
+
dep instanceof CommonJsSelfReferenceDependency ||
|
|
89
|
+
dep instanceof AMDDefineDependency) {
|
|
85
90
|
return true;
|
|
86
91
|
}
|
|
87
92
|
if (checkParentModules) {
|
|
@@ -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
|
}
|
|
@@ -20,7 +20,6 @@ function ensureIvy(wco) {
|
|
|
20
20
|
'\nFor additional information or if the build fails, please see https://angular.io/guide/ivy');
|
|
21
21
|
wco.tsConfig.options.enableIvy = true;
|
|
22
22
|
}
|
|
23
|
-
let es5TargetWarningsShown = false;
|
|
24
23
|
function createIvyPlugin(wco, aot, tsconfig) {
|
|
25
24
|
if (aot) {
|
|
26
25
|
ensureIvy(wco);
|
|
@@ -40,10 +39,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
|
|
|
40
39
|
// as for third-party libraries. This greatly reduces the complexity of static analysis.
|
|
41
40
|
if (wco.scriptTarget < typescript_1.ScriptTarget.ES2015) {
|
|
42
41
|
compilerOptions.target = typescript_1.ScriptTarget.ES2015;
|
|
43
|
-
|
|
44
|
-
wco.logger.warn('DEPRECATED: ES5 output is deprecated. Please update TypeScript `target` compiler option to ES2015 or later.');
|
|
45
|
-
es5TargetWarningsShown = true;
|
|
46
|
-
}
|
|
42
|
+
wco.logger.warn('DEPRECATED: ES5 output is deprecated. Please update TypeScript `target` compiler option to ES2015 or later.');
|
|
47
43
|
}
|
|
48
44
|
const fileReplacements = {};
|
|
49
45
|
if (buildOptions.fileReplacements) {
|
|
@@ -16,11 +16,12 @@ export interface HashFormat {
|
|
|
16
16
|
file: string;
|
|
17
17
|
script: string;
|
|
18
18
|
}
|
|
19
|
+
export declare type WebpackStatsOptions = Exclude<Configuration['stats'], string | boolean | undefined>;
|
|
19
20
|
export declare function getOutputHashFormat(outputHashing?: OutputHashing, length?: number): HashFormat;
|
|
20
21
|
export declare type NormalizedEntryPoint = Required<Exclude<ScriptElement | StyleElement, string>>;
|
|
21
22
|
export declare function normalizeExtraEntryPoints(extraEntryPoints: (ScriptElement | StyleElement)[], defaultBundleName: string): NormalizedEntryPoint[];
|
|
22
23
|
export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
|
|
23
|
-
export declare function getInstrumentationExcludedPaths(
|
|
24
|
+
export declare function getInstrumentationExcludedPaths(root: string, excludedPaths: string[]): Set<string>;
|
|
24
25
|
export declare function getCacheSettings(wco: WebpackConfigOptions, angularVersion: string): WebpackOptionsNormalized['cache'];
|
|
25
26
|
export declare function globalScriptsByBundleName(root: string, scripts: ScriptElement[]): {
|
|
26
27
|
bundleName: string;
|
|
@@ -29,7 +30,5 @@ export declare function globalScriptsByBundleName(root: string, scripts: ScriptE
|
|
|
29
30
|
}[];
|
|
30
31
|
export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
|
|
31
32
|
export declare function externalizePackages(context: string, request: string | undefined, callback: (error?: Error, result?: string) => void): void;
|
|
32
|
-
declare type WebpackStatsOptions = Exclude<Configuration['stats'], string | boolean>;
|
|
33
33
|
export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
|
|
34
34
|
export declare function getMainFieldsAndConditionNames(target: ScriptTarget, platformServer: boolean): Pick<WebpackOptionsNormalized['resolve'], 'mainFields' | 'conditionNames'>;
|
|
35
|
-
export {};
|
|
@@ -121,12 +121,12 @@ function assetNameTemplateFactory(hashFormat) {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
exports.assetNameTemplateFactory = assetNameTemplateFactory;
|
|
124
|
-
function getInstrumentationExcludedPaths(
|
|
124
|
+
function getInstrumentationExcludedPaths(root, excludedPaths) {
|
|
125
125
|
const excluded = new Set();
|
|
126
126
|
for (const excludeGlob of excludedPaths) {
|
|
127
127
|
glob_1.default
|
|
128
|
-
.sync(excludeGlob, { nodir: true, cwd:
|
|
129
|
-
.forEach((p) => excluded.add(path.join(
|
|
128
|
+
.sync(excludeGlob, { nodir: true, cwd: root, root, nomount: true })
|
|
129
|
+
.forEach((p) => excluded.add(path.join(root, p)));
|
|
130
130
|
}
|
|
131
131
|
return excluded;
|
|
132
132
|
}
|
|
@@ -278,6 +278,7 @@ function getStatsOptions(verbose = false) {
|
|
|
278
278
|
version: true,
|
|
279
279
|
chunkModules: true,
|
|
280
280
|
errorDetails: true,
|
|
281
|
+
errorStack: true,
|
|
281
282
|
moduleTrace: true,
|
|
282
283
|
logging: 'verbose',
|
|
283
284
|
modulesSpace: Infinity,
|
|
@@ -10,6 +10,7 @@ import { logging } from '@angular-devkit/core';
|
|
|
10
10
|
import { Configuration, StatsCompilation } from 'webpack';
|
|
11
11
|
import { Schema as BrowserBuilderOptions } from '../../builders/browser/schema';
|
|
12
12
|
import { BudgetCalculatorResult } from '../../utils/bundle-calculator';
|
|
13
|
+
import { WebpackStatsOptions } from './helpers';
|
|
13
14
|
export declare function formatSize(size: number): string;
|
|
14
15
|
export declare type BundleStatsData = [
|
|
15
16
|
files: string,
|
|
@@ -29,8 +30,8 @@ export declare function generateBundleStats(info: {
|
|
|
29
30
|
initial?: boolean;
|
|
30
31
|
rendered?: boolean;
|
|
31
32
|
}): BundleStats;
|
|
32
|
-
export declare function statsWarningsToString(json: StatsCompilation, statsConfig:
|
|
33
|
-
export declare function statsErrorsToString(json: StatsCompilation, statsConfig:
|
|
33
|
+
export declare function statsWarningsToString(json: StatsCompilation, statsConfig: WebpackStatsOptions): string;
|
|
34
|
+
export declare function statsErrorsToString(json: StatsCompilation, statsConfig: WebpackStatsOptions): string;
|
|
34
35
|
export declare function statsHasErrors(json: StatsCompilation): boolean;
|
|
35
36
|
export declare function statsHasWarnings(json: StatsCompilation): boolean;
|
|
36
37
|
export declare function createWebpackLoggingCallback(options: BrowserBuilderOptions, logger: logging.LoggerApi): WebpackLoggingCallback;
|
|
@@ -261,7 +261,6 @@ statsConfig, budgetFailures) {
|
|
|
261
261
|
`));
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
264
|
function statsWarningsToString(json, statsConfig) {
|
|
266
265
|
const colors = statsConfig.colors;
|
|
267
266
|
const c = (x) => (colors ? color_1.colors.reset.cyan(x) : x);
|
|
@@ -294,8 +293,8 @@ function statsWarningsToString(json, statsConfig) {
|
|
|
294
293
|
return output ? '\n' + output : output;
|
|
295
294
|
}
|
|
296
295
|
exports.statsWarningsToString = statsWarningsToString;
|
|
297
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
298
296
|
function statsErrorsToString(json, statsConfig) {
|
|
297
|
+
var _a, _b;
|
|
299
298
|
const colors = statsConfig.colors;
|
|
300
299
|
const c = (x) => (colors ? color_1.colors.reset.cyan(x) : x);
|
|
301
300
|
const yb = (x) => (colors ? color_1.colors.reset.yellowBright(x) : x);
|
|
@@ -310,7 +309,16 @@ function statsErrorsToString(json, statsConfig) {
|
|
|
310
309
|
output += r(`Error: ${error}\n\n`);
|
|
311
310
|
}
|
|
312
311
|
else {
|
|
313
|
-
|
|
312
|
+
let file = error.file || error.moduleName;
|
|
313
|
+
// Clean up error paths
|
|
314
|
+
// Ex: ./src/app/styles.scss.webpack[javascript/auto]!=!./node_modules/css-loader/dist/cjs.js....
|
|
315
|
+
// to ./src/app/styles.scss.webpack
|
|
316
|
+
if (file && !statsConfig.errorDetails) {
|
|
317
|
+
const webpackPathIndex = file.indexOf('.webpack[');
|
|
318
|
+
if (webpackPathIndex !== -1) {
|
|
319
|
+
file = file.substring(0, webpackPathIndex);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
314
322
|
if (file) {
|
|
315
323
|
output += c(file);
|
|
316
324
|
if (error.loc) {
|
|
@@ -318,10 +326,16 @@ function statsErrorsToString(json, statsConfig) {
|
|
|
318
326
|
}
|
|
319
327
|
output += ' - ';
|
|
320
328
|
}
|
|
321
|
-
|
|
329
|
+
// In most cases webpack will add stack traces to error messages.
|
|
330
|
+
// This below cleans up the error from stacks.
|
|
331
|
+
// See: https://github.com/webpack/webpack/issues/15980
|
|
332
|
+
const message = statsConfig.errorStack
|
|
333
|
+
? error.message
|
|
334
|
+
: (_b = (_a = /[\s\S]+?(?=[\n\s]+at)/.exec(error.message)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : error.message;
|
|
335
|
+
if (!/^error/i.test(message)) {
|
|
322
336
|
output += r('Error: ');
|
|
323
337
|
}
|
|
324
|
-
output += `${
|
|
338
|
+
output += `${message}\n\n`;
|
|
325
339
|
}
|
|
326
340
|
}
|
|
327
341
|
return output ? '\n' + output : output;
|
|
@@ -358,6 +372,9 @@ function createWebpackLoggingCallback(options, logger) {
|
|
|
358
372
|
exports.createWebpackLoggingCallback = createWebpackLoggingCallback;
|
|
359
373
|
function webpackStatsLogger(logger, json, config, budgetFailures) {
|
|
360
374
|
logger.info(statsToString(json, config.stats, budgetFailures));
|
|
375
|
+
if (typeof config.stats !== 'object') {
|
|
376
|
+
throw new Error('Invalid Webpack stats configuration.');
|
|
377
|
+
}
|
|
361
378
|
if (statsHasWarnings(json)) {
|
|
362
379
|
logger.warn(statsWarningsToString(json, config.stats));
|
|
363
380
|
}
|