@angular-devkit/build-angular 13.0.0 → 13.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/builders/browser/index.js +0 -4
- package/src/builders/dev-server/index.js +0 -4
- package/src/builders/extract-i18n/index.js +1 -4
- package/src/builders/karma/index.d.ts +2 -2
- package/src/builders/karma/index.js +1 -7
- package/src/builders/server/index.js +1 -7
- package/src/utils/build-options.d.ts +0 -2
- package/src/utils/i18n-inlining.js +18 -2
- package/src/webpack/configs/common.d.ts +2 -2
- package/src/webpack/configs/common.js +127 -156
- package/src/webpack/configs/dev-server.d.ts +2 -2
- package/src/webpack/configs/index.d.ts +0 -6
- package/src/webpack/configs/index.js +0 -6
- package/src/webpack/configs/styles.d.ts +2 -2
- package/src/webpack/plugins/index.d.ts +2 -0
- package/src/webpack/plugins/index.js +5 -1
- package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
- package/src/webpack/plugins/json-stats-plugin.js +54 -0
- package/src/webpack/{configs/worker.d.ts → plugins/progress-plugin.d.ts} +4 -3
- package/src/webpack/plugins/progress-plugin.js +38 -0
- package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
- package/src/webpack/{configs → plugins}/typescript.js +5 -24
- package/src/webpack/utils/helpers.d.ts +15 -5
- package/src/webpack/utils/helpers.js +160 -34
- package/src/webpack/utils/stats.js +1 -2
- package/src/webpack/configs/browser.js +0 -81
- package/src/webpack/configs/server.d.ts +0 -14
- package/src/webpack/configs/server.js +0 -73
- package/src/webpack/configs/stats.d.ts +0 -38
- package/src/webpack/configs/stats.js +0 -53
- package/src/webpack/configs/test.d.ts +0 -10
- package/src/webpack/configs/test.js +0 -77
- package/src/webpack/configs/typescript.d.ts +0 -12
- package/src/webpack/configs/worker.js +0 -22
|
@@ -6,12 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export * from './analytics';
|
|
9
|
-
export * from './browser';
|
|
10
9
|
export * from './common';
|
|
11
10
|
export * from './dev-server';
|
|
12
|
-
export * from './server';
|
|
13
11
|
export * from './styles';
|
|
14
|
-
export * from './test';
|
|
15
|
-
export * from './typescript';
|
|
16
|
-
export * from './stats';
|
|
17
|
-
export * from './worker';
|
|
@@ -18,12 +18,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
__exportStar(require("./analytics"), exports);
|
|
21
|
-
__exportStar(require("./browser"), exports);
|
|
22
21
|
__exportStar(require("./common"), exports);
|
|
23
22
|
__exportStar(require("./dev-server"), exports);
|
|
24
|
-
__exportStar(require("./server"), exports);
|
|
25
23
|
__exportStar(require("./styles"), exports);
|
|
26
|
-
__exportStar(require("./test"), exports);
|
|
27
|
-
__exportStar(require("./typescript"), exports);
|
|
28
|
-
__exportStar(require("./stats"), exports);
|
|
29
|
-
__exportStar(require("./worker"), exports);
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { Configuration } from 'webpack';
|
|
9
9
|
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
|
-
export declare function getStylesConfig(wco: WebpackConfigOptions):
|
|
10
|
+
export declare function getStylesConfig(wco: WebpackConfigOptions): Configuration;
|
|
@@ -11,4 +11,6 @@ export { SuppressExtractedTextChunksWebpackPlugin } from './suppress-entry-chunk
|
|
|
11
11
|
export { RemoveHashPlugin, RemoveHashPluginOptions } from './remove-hash-plugin';
|
|
12
12
|
export { DedupeModuleResolvePlugin } from './dedupe-module-resolve-plugin';
|
|
13
13
|
export { CommonJsUsageWarnPlugin } from './common-js-usage-warn-plugin';
|
|
14
|
+
export { JsonStatsPlugin } from './json-stats-plugin';
|
|
15
|
+
export { JavaScriptOptimizerPlugin } from './javascript-optimizer-plugin';
|
|
14
16
|
export { default as PostcssCliResources, PostcssCliResourcesOptions, } from './postcss-cli-resources';
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
|
|
13
|
+
exports.PostcssCliResources = exports.JavaScriptOptimizerPlugin = exports.JsonStatsPlugin = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
|
|
14
14
|
// Exports the webpack plugins we use internally.
|
|
15
15
|
var any_component_style_budget_checker_1 = require("./any-component-style-budget-checker");
|
|
16
16
|
Object.defineProperty(exports, "AnyComponentStyleBudgetChecker", { enumerable: true, get: function () { return any_component_style_budget_checker_1.AnyComponentStyleBudgetChecker; } });
|
|
@@ -24,5 +24,9 @@ var dedupe_module_resolve_plugin_1 = require("./dedupe-module-resolve-plugin");
|
|
|
24
24
|
Object.defineProperty(exports, "DedupeModuleResolvePlugin", { enumerable: true, get: function () { return dedupe_module_resolve_plugin_1.DedupeModuleResolvePlugin; } });
|
|
25
25
|
var common_js_usage_warn_plugin_1 = require("./common-js-usage-warn-plugin");
|
|
26
26
|
Object.defineProperty(exports, "CommonJsUsageWarnPlugin", { enumerable: true, get: function () { return common_js_usage_warn_plugin_1.CommonJsUsageWarnPlugin; } });
|
|
27
|
+
var json_stats_plugin_1 = require("./json-stats-plugin");
|
|
28
|
+
Object.defineProperty(exports, "JsonStatsPlugin", { enumerable: true, get: function () { return json_stats_plugin_1.JsonStatsPlugin; } });
|
|
29
|
+
var javascript_optimizer_plugin_1 = require("./javascript-optimizer-plugin");
|
|
30
|
+
Object.defineProperty(exports, "JavaScriptOptimizerPlugin", { enumerable: true, get: function () { return javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin; } });
|
|
27
31
|
var postcss_cli_resources_1 = require("./postcss-cli-resources");
|
|
28
32
|
Object.defineProperty(exports, "PostcssCliResources", { enumerable: true, get: function () { return __importDefault(postcss_cli_resources_1).default; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
export declare class JsonStatsPlugin {
|
|
10
|
+
private readonly statsOutputPath;
|
|
11
|
+
constructor(statsOutputPath: string);
|
|
12
|
+
apply(compiler: Compiler): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.JsonStatsPlugin = void 0;
|
|
30
|
+
const fs_1 = require("fs");
|
|
31
|
+
const path_1 = require("path");
|
|
32
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
33
|
+
class JsonStatsPlugin {
|
|
34
|
+
constructor(statsOutputPath) {
|
|
35
|
+
this.statsOutputPath = statsOutputPath;
|
|
36
|
+
}
|
|
37
|
+
apply(compiler) {
|
|
38
|
+
compiler.hooks.done.tapPromise('angular-json-stats', async (stats) => {
|
|
39
|
+
const { stringifyStream } = await Promise.resolve().then(() => __importStar(require('@discoveryjs/json-ext')));
|
|
40
|
+
const data = stats.toJson('verbose');
|
|
41
|
+
try {
|
|
42
|
+
await fs_1.promises.mkdir((0, path_1.dirname)(this.statsOutputPath), { recursive: true });
|
|
43
|
+
await new Promise((resolve, reject) => stringifyStream(data)
|
|
44
|
+
.pipe((0, fs_1.createWriteStream)(this.statsOutputPath))
|
|
45
|
+
.on('close', resolve)
|
|
46
|
+
.on('error', reject));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
(0, webpack_diagnostics_1.addError)(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.JsonStatsPlugin = JsonStatsPlugin;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { ProgressPlugin as WebpackProgressPlugin } from 'webpack';
|
|
9
|
+
export declare class ProgressPlugin extends WebpackProgressPlugin {
|
|
10
|
+
constructor(platform: 'server' | 'browser');
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.ProgressPlugin = void 0;
|
|
11
|
+
const webpack_1 = require("webpack");
|
|
12
|
+
const spinner_1 = require("../../utils/spinner");
|
|
13
|
+
class ProgressPlugin extends webpack_1.ProgressPlugin {
|
|
14
|
+
constructor(platform) {
|
|
15
|
+
const platformCapitalFirst = platform.replace(/^\w/, (s) => s.toUpperCase());
|
|
16
|
+
const spinner = new spinner_1.Spinner();
|
|
17
|
+
spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
|
|
18
|
+
super({
|
|
19
|
+
handler: (percentage, message) => {
|
|
20
|
+
const phase = message ? ` (phase: ${message})` : '';
|
|
21
|
+
spinner.text = `Generating ${platform} application bundles${phase}...`;
|
|
22
|
+
switch (percentage) {
|
|
23
|
+
case 1:
|
|
24
|
+
if (spinner.isSpinning) {
|
|
25
|
+
spinner.succeed(`${platformCapitalFirst} application bundle generation complete.`);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case 0:
|
|
29
|
+
if (!spinner.isSpinning) {
|
|
30
|
+
spinner.start();
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ProgressPlugin = ProgressPlugin;
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { AngularWebpackPlugin } from '@ngtools/webpack';
|
|
9
9
|
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function createIvyPlugin(wco: WebpackConfigOptions, aot: boolean, tsconfig: string): AngularWebpackPlugin;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.createIvyPlugin = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const webpack_1 = require("@ngtools/webpack");
|
|
13
13
|
const typescript_1 = require("typescript");
|
|
@@ -22,6 +22,9 @@ function ensureIvy(wco) {
|
|
|
22
22
|
wco.tsConfig.options.enableIvy = true;
|
|
23
23
|
}
|
|
24
24
|
function createIvyPlugin(wco, aot, tsconfig) {
|
|
25
|
+
if (aot) {
|
|
26
|
+
ensureIvy(wco);
|
|
27
|
+
}
|
|
25
28
|
const { buildOptions } = wco;
|
|
26
29
|
const optimize = buildOptions.optimization.scripts;
|
|
27
30
|
const compilerOptions = {
|
|
@@ -69,26 +72,4 @@ function createIvyPlugin(wco, aot, tsconfig) {
|
|
|
69
72
|
inlineStyleFileExtension,
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
const { buildOptions: { aot = false, main, polyfills }, tsConfigPath, } = wco;
|
|
74
|
-
if (main || polyfills) {
|
|
75
|
-
ensureIvy(wco);
|
|
76
|
-
return {
|
|
77
|
-
module: {
|
|
78
|
-
rules: [
|
|
79
|
-
{
|
|
80
|
-
test: /\.[jt]sx?$/,
|
|
81
|
-
loader: webpack_1.AngularWebpackLoaderPath,
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
plugins: [createIvyPlugin(wco, aot, tsConfigPath)],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return {};
|
|
89
|
-
}
|
|
90
|
-
exports.getTypeScriptConfig = getTypeScriptConfig;
|
|
91
|
-
function getTypescriptWorkerPlugin(wco, workerTsConfigPath) {
|
|
92
|
-
return createIvyPlugin(wco, false, workerTsConfigPath);
|
|
93
|
-
}
|
|
94
|
-
exports.getTypescriptWorkerPlugin = getTypescriptWorkerPlugin;
|
|
75
|
+
exports.createIvyPlugin = createIvyPlugin;
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import type { ObjectPattern } from 'copy-webpack-plugin';
|
|
9
|
+
import type { Configuration, WebpackOptionsNormalized } from 'webpack';
|
|
10
|
+
import { AssetPatternClass, ExtraEntryPoint, ExtraEntryPointClass } from '../../builders/browser/schema';
|
|
11
|
+
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
12
|
export interface HashFormat {
|
|
11
13
|
chunk: string;
|
|
12
14
|
extract: string;
|
|
@@ -16,8 +18,16 @@ export interface HashFormat {
|
|
|
16
18
|
export declare function getOutputHashFormat(option: string, length?: number): HashFormat;
|
|
17
19
|
export declare type NormalizedEntryPoint = Required<ExtraEntryPointClass>;
|
|
18
20
|
export declare function normalizeExtraEntryPoints(extraEntryPoints: ExtraEntryPoint[], defaultBundleName: string): NormalizedEntryPoint[];
|
|
19
|
-
export declare function getSourceMapDevTool(scriptsSourceMap: boolean | undefined, stylesSourceMap: boolean | undefined, hiddenSourceMap?: boolean, inlineSourceMap?: boolean): SourceMapDevToolPlugin;
|
|
20
|
-
export declare function isPolyfillsEntry(name: string): boolean;
|
|
21
|
-
export declare function getWatchOptions(poll: number | undefined): NonNullable<Configuration['watchOptions']>;
|
|
22
21
|
export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
|
|
23
22
|
export declare function getInstrumentationExcludedPaths(sourceRoot: string, excludedPaths: string[]): Set<string>;
|
|
23
|
+
export declare function getCacheSettings(wco: WebpackConfigOptions, supportedBrowsers: string[], angularVersion: string): WebpackOptionsNormalized['cache'];
|
|
24
|
+
export declare function globalScriptsByBundleName(root: string, scripts: ExtraEntryPoint[]): {
|
|
25
|
+
bundleName: string;
|
|
26
|
+
inject: boolean;
|
|
27
|
+
paths: string[];
|
|
28
|
+
}[];
|
|
29
|
+
export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
|
|
30
|
+
export declare function externalizePackages(context: string, request: string | undefined, callback: (error?: Error, result?: string) => void): void;
|
|
31
|
+
declare type WebpackStatsOptions = Exclude<Configuration['stats'], string | boolean>;
|
|
32
|
+
export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
|
|
33
|
+
export {};
|
|
@@ -29,10 +29,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
32
|
+
exports.getStatsOptions = exports.externalizePackages = exports.assetPatterns = exports.globalScriptsByBundleName = exports.getCacheSettings = exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
|
|
33
|
+
const crypto_1 = require("crypto");
|
|
34
|
+
const fs_1 = require("fs");
|
|
33
35
|
const glob_1 = __importDefault(require("glob"));
|
|
34
36
|
const path = __importStar(require("path"));
|
|
35
|
-
const webpack_1 = require("webpack");
|
|
36
37
|
function getOutputHashFormat(option, length = 20) {
|
|
37
38
|
const hashFormats = {
|
|
38
39
|
none: { chunk: '', extract: '', file: '', script: '' },
|
|
@@ -74,38 +75,6 @@ function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
|
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
exports.normalizeExtraEntryPoints = normalizeExtraEntryPoints;
|
|
77
|
-
function getSourceMapDevTool(scriptsSourceMap, stylesSourceMap, hiddenSourceMap = false, inlineSourceMap = false) {
|
|
78
|
-
const include = [];
|
|
79
|
-
if (scriptsSourceMap) {
|
|
80
|
-
include.push(/js$/);
|
|
81
|
-
}
|
|
82
|
-
if (stylesSourceMap) {
|
|
83
|
-
include.push(/css$/);
|
|
84
|
-
}
|
|
85
|
-
return new webpack_1.SourceMapDevToolPlugin({
|
|
86
|
-
filename: inlineSourceMap ? undefined : '[file].map',
|
|
87
|
-
include,
|
|
88
|
-
// We want to set sourceRoot to `webpack:///` for non
|
|
89
|
-
// inline sourcemaps as otherwise paths to sourcemaps will be broken in browser
|
|
90
|
-
// `webpack:///` is needed for Visual Studio breakpoints to work properly as currently
|
|
91
|
-
// there is no way to set the 'webRoot'
|
|
92
|
-
sourceRoot: 'webpack:///',
|
|
93
|
-
moduleFilenameTemplate: '[resource-path]',
|
|
94
|
-
append: hiddenSourceMap ? false : undefined,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
exports.getSourceMapDevTool = getSourceMapDevTool;
|
|
98
|
-
function isPolyfillsEntry(name) {
|
|
99
|
-
return name === 'polyfills';
|
|
100
|
-
}
|
|
101
|
-
exports.isPolyfillsEntry = isPolyfillsEntry;
|
|
102
|
-
function getWatchOptions(poll) {
|
|
103
|
-
return {
|
|
104
|
-
poll,
|
|
105
|
-
ignored: poll === undefined ? '**/$_lazy_route_resources' : 'node_modules/**',
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
exports.getWatchOptions = getWatchOptions;
|
|
109
78
|
function assetNameTemplateFactory(hashFormat) {
|
|
110
79
|
const visitedFiles = new Map();
|
|
111
80
|
return (resourcePath) => {
|
|
@@ -140,3 +109,160 @@ function getInstrumentationExcludedPaths(sourceRoot, excludedPaths) {
|
|
|
140
109
|
return excluded;
|
|
141
110
|
}
|
|
142
111
|
exports.getInstrumentationExcludedPaths = getInstrumentationExcludedPaths;
|
|
112
|
+
function getCacheSettings(wco, supportedBrowsers, angularVersion) {
|
|
113
|
+
const { enabled, path: cacheDirectory } = wco.buildOptions.cache;
|
|
114
|
+
if (enabled) {
|
|
115
|
+
const packageVersion = require('../../../package.json').version;
|
|
116
|
+
return {
|
|
117
|
+
type: 'filesystem',
|
|
118
|
+
cacheDirectory: path.join(cacheDirectory, 'angular-webpack'),
|
|
119
|
+
maxMemoryGenerations: 1,
|
|
120
|
+
// We use the versions and build options as the cache name. The Webpack configurations are too
|
|
121
|
+
// dynamic and shared among different build types: test, build and serve.
|
|
122
|
+
// None of which are "named".
|
|
123
|
+
name: (0, crypto_1.createHash)('sha1')
|
|
124
|
+
.update(angularVersion)
|
|
125
|
+
.update(packageVersion)
|
|
126
|
+
.update(wco.projectRoot)
|
|
127
|
+
.update(JSON.stringify(wco.tsConfig))
|
|
128
|
+
.update(JSON.stringify({
|
|
129
|
+
...wco.buildOptions,
|
|
130
|
+
// Needed because outputPath changes on every build when using i18n extraction
|
|
131
|
+
// https://github.com/angular/angular-cli/blob/736a5f89deaca85f487b78aec9ff66d4118ceb6a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L264-L265
|
|
132
|
+
outputPath: undefined,
|
|
133
|
+
}))
|
|
134
|
+
.update(supportedBrowsers.join(''))
|
|
135
|
+
.digest('hex'),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (wco.buildOptions.watch) {
|
|
139
|
+
return {
|
|
140
|
+
type: 'memory',
|
|
141
|
+
maxGenerations: 1,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
exports.getCacheSettings = getCacheSettings;
|
|
147
|
+
function globalScriptsByBundleName(root, scripts) {
|
|
148
|
+
return normalizeExtraEntryPoints(scripts, 'scripts').reduce((prev, curr) => {
|
|
149
|
+
const { bundleName, inject, input } = curr;
|
|
150
|
+
let resolvedPath = path.resolve(root, input);
|
|
151
|
+
if (!(0, fs_1.existsSync)(resolvedPath)) {
|
|
152
|
+
try {
|
|
153
|
+
resolvedPath = require.resolve(input, { paths: [root] });
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
throw new Error(`Script file ${input} does not exist.`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const existingEntry = prev.find((el) => el.bundleName === bundleName);
|
|
160
|
+
if (existingEntry) {
|
|
161
|
+
if (existingEntry.inject && !inject) {
|
|
162
|
+
// All entries have to be lazy for the bundle to be lazy.
|
|
163
|
+
throw new Error(`The ${bundleName} bundle is mixing injected and non-injected scripts.`);
|
|
164
|
+
}
|
|
165
|
+
existingEntry.paths.push(resolvedPath);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
prev.push({
|
|
169
|
+
bundleName,
|
|
170
|
+
inject,
|
|
171
|
+
paths: [resolvedPath],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return prev;
|
|
175
|
+
}, []);
|
|
176
|
+
}
|
|
177
|
+
exports.globalScriptsByBundleName = globalScriptsByBundleName;
|
|
178
|
+
function assetPatterns(root, assets) {
|
|
179
|
+
return assets.map((asset, index) => {
|
|
180
|
+
// Resolve input paths relative to workspace root and add slash at the end.
|
|
181
|
+
// eslint-disable-next-line prefer-const
|
|
182
|
+
let { input, output, ignore = [], glob } = asset;
|
|
183
|
+
input = path.resolve(root, input).replace(/\\/g, '/');
|
|
184
|
+
input = input.endsWith('/') ? input : input + '/';
|
|
185
|
+
output = output.endsWith('/') ? output : output + '/';
|
|
186
|
+
if (output.startsWith('..')) {
|
|
187
|
+
throw new Error('An asset cannot be written to a location outside of the output path.');
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
context: input,
|
|
191
|
+
// Now we remove starting slash to make Webpack place it from the output root.
|
|
192
|
+
to: output.replace(/^\//, ''),
|
|
193
|
+
from: glob,
|
|
194
|
+
noErrorOnMissing: true,
|
|
195
|
+
force: true,
|
|
196
|
+
globOptions: {
|
|
197
|
+
dot: true,
|
|
198
|
+
followSymbolicLinks: !!asset.followSymlinks,
|
|
199
|
+
ignore: [
|
|
200
|
+
'.gitkeep',
|
|
201
|
+
'**/.DS_Store',
|
|
202
|
+
'**/Thumbs.db',
|
|
203
|
+
// Negate patterns needs to be absolute because copy-webpack-plugin uses absolute globs which
|
|
204
|
+
// causes negate patterns not to match.
|
|
205
|
+
// See: https://github.com/webpack-contrib/copy-webpack-plugin/issues/498#issuecomment-639327909
|
|
206
|
+
...ignore,
|
|
207
|
+
].map((i) => path.posix.join(input, i)),
|
|
208
|
+
},
|
|
209
|
+
priority: index,
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
exports.assetPatterns = assetPatterns;
|
|
214
|
+
function externalizePackages(context, request, callback) {
|
|
215
|
+
if (!request) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// Absolute & Relative paths are not externals
|
|
219
|
+
if (request.startsWith('.') || path.isAbsolute(request)) {
|
|
220
|
+
callback();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
require.resolve(request, { paths: [context] });
|
|
225
|
+
callback(undefined, request);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
// Node couldn't find it, so it must be user-aliased
|
|
229
|
+
callback();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
exports.externalizePackages = externalizePackages;
|
|
233
|
+
function getStatsOptions(verbose = false) {
|
|
234
|
+
const webpackOutputOptions = {
|
|
235
|
+
all: false,
|
|
236
|
+
colors: true,
|
|
237
|
+
hash: true,
|
|
238
|
+
timings: true,
|
|
239
|
+
chunks: true,
|
|
240
|
+
builtAt: true,
|
|
241
|
+
warnings: true,
|
|
242
|
+
errors: true,
|
|
243
|
+
assets: true,
|
|
244
|
+
cachedAssets: true,
|
|
245
|
+
// Needed for markAsyncChunksNonInitial.
|
|
246
|
+
ids: true,
|
|
247
|
+
entrypoints: true,
|
|
248
|
+
};
|
|
249
|
+
const verboseWebpackOutputOptions = {
|
|
250
|
+
// The verbose output will most likely be piped to a file, so colors just mess it up.
|
|
251
|
+
colors: false,
|
|
252
|
+
usedExports: true,
|
|
253
|
+
optimizationBailout: true,
|
|
254
|
+
reasons: true,
|
|
255
|
+
children: true,
|
|
256
|
+
assets: true,
|
|
257
|
+
version: true,
|
|
258
|
+
chunkModules: true,
|
|
259
|
+
errorDetails: true,
|
|
260
|
+
moduleTrace: true,
|
|
261
|
+
logging: 'verbose',
|
|
262
|
+
modulesSpace: Infinity,
|
|
263
|
+
};
|
|
264
|
+
return verbose
|
|
265
|
+
? { ...webpackOutputOptions, ...verboseWebpackOutputOptions }
|
|
266
|
+
: webpackOutputOptions;
|
|
267
|
+
}
|
|
268
|
+
exports.getStatsOptions = getStatsOptions;
|
|
@@ -34,7 +34,6 @@ const core_1 = require("@angular-devkit/core");
|
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
35
|
const text_table_1 = __importDefault(require("text-table"));
|
|
36
36
|
const color_1 = require("../../utils/color");
|
|
37
|
-
const stats_1 = require("../configs/stats");
|
|
38
37
|
const async_chunks_1 = require("./async-chunks");
|
|
39
38
|
const helpers_1 = require("./helpers");
|
|
40
39
|
function formatSize(size) {
|
|
@@ -266,7 +265,7 @@ function createWebpackLoggingCallback(options, logger) {
|
|
|
266
265
|
if (verbose) {
|
|
267
266
|
logger.info(stats.toString(config.stats));
|
|
268
267
|
}
|
|
269
|
-
const rawStats = stats.toJson((0,
|
|
268
|
+
const rawStats = stats.toJson((0, helpers_1.getStatsOptions)(false));
|
|
270
269
|
const webpackStats = {
|
|
271
270
|
...rawStats,
|
|
272
271
|
chunks: (0, async_chunks_1.markAsyncChunksNonInitial)(rawStats, extraEntryPoints),
|
|
@@ -1,81 +0,0 @@
|
|
|
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.getBrowserConfig = void 0;
|
|
11
|
-
const webpack_subresource_integrity_1 = require("webpack-subresource-integrity");
|
|
12
|
-
const plugins_1 = require("../plugins");
|
|
13
|
-
const helpers_1 = require("../utils/helpers");
|
|
14
|
-
function getBrowserConfig(wco) {
|
|
15
|
-
const { buildOptions } = wco;
|
|
16
|
-
const { crossOrigin = 'none', subresourceIntegrity, vendorChunk, commonChunk, allowedCommonJsDependencies, } = buildOptions;
|
|
17
|
-
const extraPlugins = [];
|
|
18
|
-
const { styles: stylesSourceMap, scripts: scriptsSourceMap, hidden: hiddenSourceMap, } = buildOptions.sourceMap;
|
|
19
|
-
if (subresourceIntegrity) {
|
|
20
|
-
extraPlugins.push(new webpack_subresource_integrity_1.SubresourceIntegrityPlugin({
|
|
21
|
-
hashFuncNames: ['sha384'],
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
if (scriptsSourceMap || stylesSourceMap) {
|
|
25
|
-
extraPlugins.push((0, helpers_1.getSourceMapDevTool)(scriptsSourceMap, stylesSourceMap, hiddenSourceMap, false));
|
|
26
|
-
}
|
|
27
|
-
let crossOriginLoading = false;
|
|
28
|
-
if (subresourceIntegrity && crossOrigin === 'none') {
|
|
29
|
-
crossOriginLoading = 'anonymous';
|
|
30
|
-
}
|
|
31
|
-
else if (crossOrigin !== 'none') {
|
|
32
|
-
crossOriginLoading = crossOrigin;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
devtool: false,
|
|
36
|
-
resolve: {
|
|
37
|
-
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
|
|
38
|
-
conditionNames: ['es2020', 'es2015', '...'],
|
|
39
|
-
},
|
|
40
|
-
output: {
|
|
41
|
-
crossOriginLoading,
|
|
42
|
-
trustedTypes: 'angular#bundler',
|
|
43
|
-
scriptType: 'module',
|
|
44
|
-
},
|
|
45
|
-
optimization: {
|
|
46
|
-
runtimeChunk: 'single',
|
|
47
|
-
splitChunks: {
|
|
48
|
-
maxAsyncRequests: Infinity,
|
|
49
|
-
cacheGroups: {
|
|
50
|
-
default: !!commonChunk && {
|
|
51
|
-
chunks: 'async',
|
|
52
|
-
minChunks: 2,
|
|
53
|
-
priority: 10,
|
|
54
|
-
},
|
|
55
|
-
common: !!commonChunk && {
|
|
56
|
-
name: 'common',
|
|
57
|
-
chunks: 'async',
|
|
58
|
-
minChunks: 2,
|
|
59
|
-
enforce: true,
|
|
60
|
-
priority: 5,
|
|
61
|
-
},
|
|
62
|
-
vendors: false,
|
|
63
|
-
defaultVendors: !!vendorChunk && {
|
|
64
|
-
name: 'vendor',
|
|
65
|
-
chunks: (chunk) => chunk.name === 'main',
|
|
66
|
-
enforce: true,
|
|
67
|
-
test: /[\\/]node_modules[\\/]/,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
plugins: [
|
|
73
|
-
new plugins_1.CommonJsUsageWarnPlugin({
|
|
74
|
-
allowedDependencies: allowedCommonJsDependencies,
|
|
75
|
-
}),
|
|
76
|
-
...extraPlugins,
|
|
77
|
-
],
|
|
78
|
-
node: false,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
exports.getBrowserConfig = getBrowserConfig;
|
|
@@ -1,14 +0,0 @@
|
|
|
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 { Configuration } from 'webpack';
|
|
9
|
-
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
|
-
/**
|
|
11
|
-
* Returns a partial Webpack configuration specific to creating a bundle for node
|
|
12
|
-
* @param wco Options which include the build options and app config
|
|
13
|
-
*/
|
|
14
|
-
export declare function getServerConfig(wco: WebpackConfigOptions): Configuration;
|