@angular-devkit/build-angular 14.0.2 → 14.0.5
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 +5 -5
- package/src/babel/webpack-loader.js +3 -3
- 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/index.js +5 -1
- package/src/builders/browser-esbuild/stylesheets.d.ts +1 -1
- package/src/builders/extract-i18n/index.js +3 -1
- package/src/builders/karma/find-tests.js +2 -0
- package/src/builders/karma/index.js +2 -2
- package/src/builders/server/index.d.ts +8 -1
- package/src/builders/server/index.js +7 -0
- 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/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,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.5",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.2.0",
|
|
10
|
-
"@angular-devkit/architect": "0.1400.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1400.
|
|
12
|
-
"@angular-devkit/core": "14.0.
|
|
10
|
+
"@angular-devkit/architect": "0.1400.5",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1400.5",
|
|
12
|
+
"@angular-devkit/core": "14.0.5",
|
|
13
13
|
"@babel/core": "7.17.10",
|
|
14
14
|
"@babel/generator": "7.17.10",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.16.7",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/runtime": "7.17.9",
|
|
21
21
|
"@babel/template": "7.16.7",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "14.0.
|
|
23
|
+
"@ngtools/webpack": "14.0.5",
|
|
24
24
|
"ansi-colors": "4.1.1",
|
|
25
25
|
"babel-loader": "8.2.5",
|
|
26
26
|
"babel-plugin-istanbul": "6.1.1",
|
|
@@ -52,7 +52,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
52
52
|
});
|
|
53
53
|
return {
|
|
54
54
|
async customOptions(options, { source, map }) {
|
|
55
|
-
var _a, _b;
|
|
55
|
+
var _a, _b, _c;
|
|
56
56
|
const { i18n, scriptTarget, aot, optimize, instrumentCode, supportedBrowsers, ...rawOptions } = options;
|
|
57
57
|
// Must process file if plugins are added
|
|
58
58
|
let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
|
|
@@ -89,7 +89,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
89
89
|
// Comparable behavior to tsconfig target of ES5
|
|
90
90
|
customOptions.supportedBrowsers = ['IE 9'];
|
|
91
91
|
}
|
|
92
|
-
else if (isJsFile) {
|
|
92
|
+
else if (isJsFile && ((_a = customOptions.supportedBrowsers) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
93
93
|
// Applications code ES version can be controlled using TypeScript's `target` option.
|
|
94
94
|
// However, this doesn't effect libraries and hence we use preset-env to downlevel ES fetaures
|
|
95
95
|
// based on the supported browsers in browserlist.
|
|
@@ -142,7 +142,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
142
142
|
pureTopLevel: angularPackage,
|
|
143
143
|
// JavaScript modules that are marked as side effect free are considered to have
|
|
144
144
|
// no decorators that contain non-local effects.
|
|
145
|
-
wrapDecorators: !!((
|
|
145
|
+
wrapDecorators: !!((_c = (_b = this._module) === null || _b === void 0 ? void 0 : _b.factoryMeta) === null || _c === void 0 ? void 0 : _c.sideEffectFree),
|
|
146
146
|
};
|
|
147
147
|
shouldProcess = true;
|
|
148
148
|
}
|
|
@@ -61,7 +61,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
61
61
|
deployUrl: browserOptions.deployUrl,
|
|
62
62
|
})
|
|
63
63
|
: undefined;
|
|
64
|
-
for (const outputPath of browserResult.
|
|
64
|
+
for (const { path: outputPath, baseHref } of browserResult.outputs) {
|
|
65
65
|
const localeDirectory = path.relative(browserResult.baseOutputPath, outputPath);
|
|
66
66
|
const browserIndexOutputPath = path.join(outputPath, 'index.html');
|
|
67
67
|
const indexHtml = await fs.promises.readFile(browserIndexOutputPath, 'utf8');
|
|
@@ -95,7 +95,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
95
95
|
}
|
|
96
96
|
await fs.promises.writeFile(outputIndexPath, html);
|
|
97
97
|
if (browserOptions.serviceWorker) {
|
|
98
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath,
|
|
98
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, baseHref !== null && baseHref !== void 0 ? baseHref : '/', browserOptions.ngswConfigPath);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
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
|
|
@@ -127,7 +127,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
127
127
|
}
|
|
128
128
|
}),
|
|
129
129
|
}).pipe((0, operators_1.concatMap)(async (buildEvent) => {
|
|
130
|
-
var _a, _b, _c, _d, _e;
|
|
130
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
131
131
|
const spinner = new spinner_1.Spinner();
|
|
132
132
|
spinner.enabled = options.progress !== false;
|
|
133
133
|
const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
|
|
@@ -216,7 +216,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
216
216
|
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
217
217
|
try {
|
|
218
218
|
const { content, warnings, errors } = await indexHtmlGenerator.process({
|
|
219
|
-
baseHref: getLocaleBaseHref(i18n, locale)
|
|
219
|
+
baseHref: (_f = getLocaleBaseHref(i18n, locale)) !== null && _f !== void 0 ? _f : options.baseHref,
|
|
220
220
|
// i18nLocale is used when Ivy is disabled
|
|
221
221
|
lang: locale || undefined,
|
|
222
222
|
outputPath,
|
|
@@ -252,7 +252,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
252
252
|
spinner.start('Generating service worker...');
|
|
253
253
|
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
254
254
|
try {
|
|
255
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, getLocaleBaseHref(i18n, locale)
|
|
255
|
+
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);
|
|
256
256
|
}
|
|
257
257
|
catch (error) {
|
|
258
258
|
spinner.fail('Service worker generation failed.');
|
|
@@ -270,6 +270,18 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
270
270
|
baseOutputPath,
|
|
271
271
|
outputPath: baseOutputPath,
|
|
272
272
|
outputPaths: (outputPaths && Array.from(outputPaths.values())) || [baseOutputPath],
|
|
273
|
+
outputs: (outputPaths &&
|
|
274
|
+
[...outputPaths.entries()].map(([locale, path]) => {
|
|
275
|
+
var _a;
|
|
276
|
+
return ({
|
|
277
|
+
locale,
|
|
278
|
+
path,
|
|
279
|
+
baseHref: (_a = getLocaleBaseHref(i18n, locale)) !== null && _a !== void 0 ? _a : options.baseHref,
|
|
280
|
+
});
|
|
281
|
+
})) || {
|
|
282
|
+
path: baseOutputPath,
|
|
283
|
+
baseHref: options.baseHref,
|
|
284
|
+
},
|
|
273
285
|
})));
|
|
274
286
|
}));
|
|
275
287
|
function getLocaleBaseHref(i18n, locale) {
|
|
@@ -249,7 +249,11 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
|
|
|
249
249
|
{
|
|
250
250
|
workspaceRoot,
|
|
251
251
|
optimization: !!optimizationOptions.styles.minify,
|
|
252
|
-
sourcemap:
|
|
252
|
+
sourcemap:
|
|
253
|
+
// Hidden component stylesheet sourcemaps are inaccessible which is effectively
|
|
254
|
+
// the same as being disabled. Disabling has the advantage of avoiding the overhead
|
|
255
|
+
// of sourcemap processing.
|
|
256
|
+
!!sourcemapOptions.styles && (sourcemapOptions.hidden ? false : 'inline'),
|
|
253
257
|
outputNames,
|
|
254
258
|
}),
|
|
255
259
|
],
|
|
@@ -10,7 +10,7 @@ export interface BundleStylesheetOptions {
|
|
|
10
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;
|
|
@@ -209,7 +209,9 @@ async function execute(options, context, transforms) {
|
|
|
209
209
|
},
|
|
210
210
|
});
|
|
211
211
|
return partials;
|
|
212
|
-
}
|
|
212
|
+
},
|
|
213
|
+
// During extraction we don't need specific browser support.
|
|
214
|
+
{ supportedBrowsers: undefined });
|
|
213
215
|
// All the localize usages are setup to first try the ESM entry point then fallback to the deep imports.
|
|
214
216
|
// This provides interim compatibility while the framework is transitioned to bundled ESM packages.
|
|
215
217
|
const localizeToolsModule = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
@@ -107,8 +107,8 @@ function execute(options, context, transforms = {}) {
|
|
|
107
107
|
throw new Error('The builder requires a target.');
|
|
108
108
|
}
|
|
109
109
|
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
110
|
-
const
|
|
111
|
-
const projectSourceRoot = path.join(
|
|
110
|
+
const sourceRoot = ((_d = (_c = projectMetadata.sourceRoot) !== null && _c !== void 0 ? _c : projectMetadata.root) !== null && _d !== void 0 ? _d : '');
|
|
111
|
+
const projectSourceRoot = path.join(context.workspaceRoot, sourceRoot);
|
|
112
112
|
const files = await (0, find_tests_1.findTests)(options.include, context.workspaceRoot, projectSourceRoot);
|
|
113
113
|
// early exit, no reason to start karma
|
|
114
114
|
if (!files.length) {
|
|
@@ -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/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) {
|
|
@@ -85,6 +85,10 @@ async function getDevServerConfig(wco) {
|
|
|
85
85
|
},
|
|
86
86
|
],
|
|
87
87
|
},
|
|
88
|
+
// When setupExitSignals is enabled webpack-dev-server will shutdown gracefully which would
|
|
89
|
+
// require CTRL+C to be pressed multiple times to exit.
|
|
90
|
+
// See: https://github.com/webpack/webpack-dev-server/blob/c76b6d11a3821436c5e20207c8a38deb6ab7e33c/lib/Server.js#L1801-L1827
|
|
91
|
+
setupExitSignals: false,
|
|
88
92
|
compress: false,
|
|
89
93
|
static: false,
|
|
90
94
|
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) {
|
|
@@ -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(
|
|
129
|
-
.forEach((p) => excluded.add(path.
|
|
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
|
}
|