@angular-devkit/build-angular 13.0.0-next.9 → 13.0.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 +29 -29
- package/src/babel/presets/application.d.ts +8 -0
- package/src/babel/presets/application.js +18 -0
- package/src/babel/webpack-loader.d.ts +9 -0
- package/src/babel/webpack-loader.js +14 -17
- package/src/builders/app-shell/index.js +1 -1
- package/src/builders/browser/index.js +1 -1
- package/src/builders/browser/schema.json +1 -1
- package/src/builders/dev-server/index.js +3 -0
- package/src/builders/extract-i18n/index.js +10 -10
- package/src/sass/sass-service.js +2 -2
- package/src/sass/worker.js +0 -1
- package/src/utils/action-executor.js +4 -5
- package/src/utils/build-options.d.ts +1 -0
- package/src/utils/normalize-optimization.js +2 -4
- package/src/utils/service-worker.d.ts +1 -1
- package/src/utils/service-worker.js +7 -20
- package/src/utils/webpack-browser-config.d.ts +1 -1
- package/src/utils/webpack-browser-config.js +3 -2
- package/src/webpack/configs/analytics.js +4 -1
- package/src/webpack/configs/common.d.ts +2 -2
- package/src/webpack/configs/common.js +9 -2
- package/src/webpack/configs/server.js +2 -1
- package/src/webpack/configs/test.js +1 -22
- package/src/webpack/plugins/analytics.d.ts +2 -2
- package/src/webpack/plugins/analytics.js +3 -3
- package/src/webpack/utils/helpers.d.ts +1 -0
- package/src/webpack/utils/helpers.js +15 -1
package/package.json
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "13.0.0-
|
|
3
|
+
"version": "13.0.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": "1.0.1",
|
|
10
|
-
"@angular-devkit/architect": "0.1300.0-
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1300.0-
|
|
12
|
-
"@angular-devkit/core": "13.0.0-
|
|
13
|
-
"@babel/core": "7.15.
|
|
14
|
-
"@babel/generator": "7.15.
|
|
10
|
+
"@angular-devkit/architect": "0.1300.0-rc.3",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1300.0-rc.3",
|
|
12
|
+
"@angular-devkit/core": "13.0.0-rc.3",
|
|
13
|
+
"@babel/core": "7.15.8",
|
|
14
|
+
"@babel/generator": "7.15.8",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.15.4",
|
|
16
|
-
"@babel/plugin-proposal-async-generator-functions": "7.15.
|
|
16
|
+
"@babel/plugin-proposal-async-generator-functions": "7.15.8",
|
|
17
17
|
"@babel/plugin-transform-async-to-generator": "7.14.5",
|
|
18
|
-
"@babel/plugin-transform-runtime": "7.15.
|
|
19
|
-
"@babel/preset-env": "7.15.
|
|
18
|
+
"@babel/plugin-transform-runtime": "7.15.8",
|
|
19
|
+
"@babel/preset-env": "7.15.8",
|
|
20
20
|
"@babel/runtime": "7.15.4",
|
|
21
21
|
"@babel/template": "7.15.4",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.5",
|
|
23
|
-
"@
|
|
24
|
-
"@ngtools/webpack": "13.0.0-next.9",
|
|
23
|
+
"@ngtools/webpack": "13.0.0-rc.3",
|
|
25
24
|
"ansi-colors": "4.1.1",
|
|
26
|
-
"babel-loader": "8.2.
|
|
25
|
+
"babel-loader": "8.2.3",
|
|
26
|
+
"babel-plugin-istanbul": "6.1.1",
|
|
27
27
|
"browserslist": "^4.9.1",
|
|
28
28
|
"cacache": "15.3.0",
|
|
29
29
|
"caniuse-lite": "^1.0.30001032",
|
|
30
30
|
"circular-dependency-plugin": "5.2.2",
|
|
31
31
|
"copy-webpack-plugin": "9.0.1",
|
|
32
|
-
"core-js": "3.
|
|
33
|
-
"critters": "0.0.
|
|
34
|
-
"css-loader": "6.
|
|
35
|
-
"esbuild-wasm": "0.13.
|
|
32
|
+
"core-js": "3.19.0",
|
|
33
|
+
"critters": "0.0.14",
|
|
34
|
+
"css-loader": "6.5.0",
|
|
35
|
+
"esbuild-wasm": "0.13.12",
|
|
36
36
|
"glob": "7.2.0",
|
|
37
37
|
"https-proxy-agent": "5.0.0",
|
|
38
38
|
"inquirer": "8.2.0",
|
|
39
39
|
"karma-source-map-support": "1.4.0",
|
|
40
40
|
"less": "4.1.2",
|
|
41
|
-
"less-loader": "10.0
|
|
41
|
+
"less-loader": "10.2.0",
|
|
42
42
|
"license-webpack-plugin": "3.0.0",
|
|
43
|
-
"loader-utils": "
|
|
44
|
-
"mini-css-extract-plugin": "2.4.
|
|
43
|
+
"loader-utils": "3.0.0",
|
|
44
|
+
"mini-css-extract-plugin": "2.4.3",
|
|
45
45
|
"minimatch": "3.0.4",
|
|
46
|
-
"open": "8.
|
|
46
|
+
"open": "8.4.0",
|
|
47
47
|
"ora": "5.4.1",
|
|
48
48
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
49
49
|
"piscina": "3.1.0",
|
|
50
|
-
"postcss": "8.3.
|
|
50
|
+
"postcss": "8.3.11",
|
|
51
51
|
"postcss-import": "14.0.2",
|
|
52
|
-
"postcss-loader": "6.
|
|
52
|
+
"postcss-loader": "6.2.0",
|
|
53
53
|
"postcss-preset-env": "6.7.0",
|
|
54
54
|
"regenerator-runtime": "0.13.9",
|
|
55
55
|
"resolve-url-loader": "4.0.0",
|
|
56
56
|
"rxjs": "6.6.7",
|
|
57
|
-
"sass": "1.
|
|
58
|
-
"sass-loader": "12.
|
|
57
|
+
"sass": "1.43.4",
|
|
58
|
+
"sass-loader": "12.3.0",
|
|
59
59
|
"semver": "7.3.5",
|
|
60
60
|
"source-map-loader": "3.0.0",
|
|
61
61
|
"source-map-support": "0.5.20",
|
|
62
62
|
"stylus": "0.55.0",
|
|
63
|
-
"stylus-loader": "6.
|
|
63
|
+
"stylus-loader": "6.2.0",
|
|
64
64
|
"terser": "5.9.0",
|
|
65
65
|
"text-table": "0.2.0",
|
|
66
66
|
"tree-kill": "1.2.2",
|
|
67
67
|
"tslib": "2.3.1",
|
|
68
|
-
"webpack": "5.
|
|
68
|
+
"webpack": "5.60.0",
|
|
69
69
|
"webpack-dev-middleware": "5.2.1",
|
|
70
|
-
"webpack-dev-server": "4.
|
|
70
|
+
"webpack-dev-server": "4.4.0",
|
|
71
71
|
"webpack-merge": "5.8.0",
|
|
72
72
|
"webpack-subresource-integrity": "5.0.0"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"esbuild": "0.13.
|
|
75
|
+
"esbuild": "0.13.12"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@angular/compiler-cli": "^13.0.0 || ^13.0.0-next",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
},
|
|
118
118
|
"engines": {
|
|
119
119
|
"node": "^12.20.0 || ^14.15.0 || >=16.10.0",
|
|
120
|
-
"npm": "^6.11.0 || ^7.5.6",
|
|
120
|
+
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
121
121
|
"yarn": ">= 1.13.0"
|
|
122
122
|
},
|
|
123
123
|
"author": "Angular Authors",
|
|
@@ -32,6 +32,14 @@ export interface ApplicationPresetOptions {
|
|
|
32
32
|
};
|
|
33
33
|
forceES5?: boolean;
|
|
34
34
|
forceAsyncTransformation?: boolean;
|
|
35
|
+
instrumentCode?: {
|
|
36
|
+
includedBasePath: string;
|
|
37
|
+
};
|
|
38
|
+
optimize?: {
|
|
39
|
+
looseEnums: boolean;
|
|
40
|
+
pureTopLevel: boolean;
|
|
41
|
+
wrapDecorators: boolean;
|
|
42
|
+
};
|
|
35
43
|
diagnosticReporter?: DiagnosticReporter;
|
|
36
44
|
}
|
|
37
45
|
export default function (api: unknown, options: ApplicationPresetOptions): {
|
|
@@ -145,6 +145,24 @@ function default_1(api, options) {
|
|
|
145
145
|
plugins.push(require('@babel/plugin-transform-async-to-generator').default, require('@babel/plugin-proposal-async-generator-functions').default);
|
|
146
146
|
needRuntimeTransform = true;
|
|
147
147
|
}
|
|
148
|
+
if (options.optimize) {
|
|
149
|
+
if (options.optimize.pureTopLevel) {
|
|
150
|
+
plugins.push(require('../plugins/pure-toplevel-functions').default);
|
|
151
|
+
}
|
|
152
|
+
plugins.push(require('../plugins/elide-angular-metadata').default, [
|
|
153
|
+
require('../plugins/adjust-typescript-enums').default,
|
|
154
|
+
{ loose: options.optimize.looseEnums },
|
|
155
|
+
], [
|
|
156
|
+
require('../plugins/adjust-static-class-members').default,
|
|
157
|
+
{ wrapDecorators: options.optimize.wrapDecorators },
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
160
|
+
if (options.instrumentCode) {
|
|
161
|
+
plugins.push([
|
|
162
|
+
require('babel-plugin-istanbul').default,
|
|
163
|
+
{ inputSourceMap: false, cwd: options.instrumentCode.includedBasePath },
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
148
166
|
if (needRuntimeTransform) {
|
|
149
167
|
// Babel equivalent to TypeScript's `importHelpers` option
|
|
150
168
|
plugins.push([
|
|
@@ -5,5 +5,14 @@
|
|
|
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 { ApplicationPresetOptions } from './presets/application';
|
|
9
|
+
interface AngularCustomOptions extends Omit<ApplicationPresetOptions, 'instrumentCode'> {
|
|
10
|
+
instrumentCode?: {
|
|
11
|
+
/** node_modules and test files are always excluded. */
|
|
12
|
+
excludedPaths: Set<String>;
|
|
13
|
+
includedBasePath: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare type AngularBabelLoaderOptions = AngularCustomOptions & Record<string, unknown>;
|
|
8
17
|
declare const _default: any;
|
|
9
18
|
export default _default;
|
|
@@ -51,8 +51,9 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
51
51
|
inputSourceMap: false,
|
|
52
52
|
});
|
|
53
53
|
return {
|
|
54
|
-
async customOptions(
|
|
54
|
+
async customOptions(options, { source }) {
|
|
55
55
|
var _a, _b;
|
|
56
|
+
const { i18n, scriptTarget, aot, optimize, instrumentCode, ...rawOptions } = options;
|
|
56
57
|
// Must process file if plugins are added
|
|
57
58
|
let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
|
|
58
59
|
const customOptions = {
|
|
@@ -60,6 +61,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
60
61
|
forceES5: false,
|
|
61
62
|
angularLinker: undefined,
|
|
62
63
|
i18n: undefined,
|
|
64
|
+
instrumentCode: undefined,
|
|
63
65
|
};
|
|
64
66
|
// Analyze file for linking
|
|
65
67
|
if (await requiresLinking(this.resourcePath, source)) {
|
|
@@ -91,7 +93,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
91
93
|
customOptions.forceAsyncTransformation =
|
|
92
94
|
!/[\\/][_f]?esm2015[\\/]/.test(this.resourcePath) && source.includes('async');
|
|
93
95
|
}
|
|
94
|
-
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation || customOptions.forceES5);
|
|
96
|
+
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation || customOptions.forceES5 || false);
|
|
95
97
|
}
|
|
96
98
|
// Analyze for i18n inlining
|
|
97
99
|
if (i18n &&
|
|
@@ -131,6 +133,16 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
131
133
|
};
|
|
132
134
|
shouldProcess = true;
|
|
133
135
|
}
|
|
136
|
+
if (instrumentCode &&
|
|
137
|
+
!instrumentCode.excludedPaths.has(this.resourcePath) &&
|
|
138
|
+
!/\.(e2e|spec)\.tsx?$|[\\/]node_modules[\\/]/.test(this.resourcePath) &&
|
|
139
|
+
this.resourcePath.startsWith(instrumentCode.includedBasePath)) {
|
|
140
|
+
// `babel-plugin-istanbul` has it's own includes but we do the below so that we avoid running the the loader.
|
|
141
|
+
customOptions.instrumentCode = {
|
|
142
|
+
includedBasePath: instrumentCode.includedBasePath,
|
|
143
|
+
};
|
|
144
|
+
shouldProcess = true;
|
|
145
|
+
}
|
|
134
146
|
// Add provided loader options to default base options
|
|
135
147
|
const loaderOptions = {
|
|
136
148
|
...baseOptions,
|
|
@@ -150,27 +162,12 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
150
162
|
return { custom: customOptions, loader: loaderOptions };
|
|
151
163
|
},
|
|
152
164
|
config(configuration, { customOptions }) {
|
|
153
|
-
var _a;
|
|
154
|
-
const plugins = (_a = configuration.options.plugins) !== null && _a !== void 0 ? _a : [];
|
|
155
|
-
if (customOptions.optimize) {
|
|
156
|
-
if (customOptions.optimize.pureTopLevel) {
|
|
157
|
-
plugins.push(require('./plugins/pure-toplevel-functions').default);
|
|
158
|
-
}
|
|
159
|
-
plugins.push(require('./plugins/elide-angular-metadata').default, [
|
|
160
|
-
require('./plugins/adjust-typescript-enums').default,
|
|
161
|
-
{ loose: customOptions.optimize.looseEnums },
|
|
162
|
-
], [
|
|
163
|
-
require('./plugins/adjust-static-class-members').default,
|
|
164
|
-
{ wrapDecorators: customOptions.optimize.wrapDecorators },
|
|
165
|
-
]);
|
|
166
|
-
}
|
|
167
165
|
return {
|
|
168
166
|
...configuration.options,
|
|
169
167
|
// Using `false` disables babel from attempting to locate sourcemaps or process any inline maps.
|
|
170
168
|
// The babel types do not include the false option even though it is valid
|
|
171
169
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
170
|
inputSourceMap: false,
|
|
173
|
-
plugins,
|
|
174
171
|
presets: [
|
|
175
172
|
...(configuration.options.presets || []),
|
|
176
173
|
[
|
|
@@ -91,7 +91,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
91
91
|
}
|
|
92
92
|
await fs.promises.writeFile(outputIndexPath, html);
|
|
93
93
|
if (browserOptions.serviceWorker) {
|
|
94
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(
|
|
94
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, (0, core_1.normalize)(outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
return browserResult;
|
|
@@ -244,7 +244,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
244
244
|
spinner.start('Generating service worker...');
|
|
245
245
|
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
246
246
|
try {
|
|
247
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(
|
|
247
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)((0, core_1.normalize)(projectRoot), (0, core_1.normalize)(outputPath), getLocaleBaseHref(i18n, locale) || options.baseHref || '/', options.ngswConfigPath);
|
|
248
248
|
}
|
|
249
249
|
catch (error) {
|
|
250
250
|
spinner.fail('Service worker generation failed.');
|
|
@@ -216,6 +216,9 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
216
216
|
if (buildEvent.success) {
|
|
217
217
|
logger.info(`\n${color_1.colors.greenBright(color_1.colors.symbols.check)} Compiled successfully.`);
|
|
218
218
|
}
|
|
219
|
+
else {
|
|
220
|
+
logger.info(`\n${color_1.colors.redBright(color_1.colors.symbols.cross)} Failed to compile.`);
|
|
221
|
+
}
|
|
219
222
|
return { ...buildEvent, baseUrl: serverAddress };
|
|
220
223
|
}));
|
|
221
224
|
}));
|
|
@@ -132,6 +132,16 @@ async function execute(options, context, transforms) {
|
|
|
132
132
|
if (!context.target || !context.target.project) {
|
|
133
133
|
throw new Error('The builder requires a target.');
|
|
134
134
|
}
|
|
135
|
+
try {
|
|
136
|
+
require.resolve('@angular/localize');
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return {
|
|
140
|
+
success: false,
|
|
141
|
+
error: `i18n extraction requires the '@angular/localize' package.`,
|
|
142
|
+
outputPath: outFile,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
135
145
|
const metadata = await context.getProjectMetadata(context.target);
|
|
136
146
|
const i18n = (0, i18n_options_1.createI18nOptions)(metadata);
|
|
137
147
|
let useLegacyIds = true;
|
|
@@ -196,16 +206,6 @@ async function execute(options, context, transforms) {
|
|
|
196
206
|
});
|
|
197
207
|
return partials;
|
|
198
208
|
});
|
|
199
|
-
try {
|
|
200
|
-
require.resolve('@angular/localize');
|
|
201
|
-
}
|
|
202
|
-
catch {
|
|
203
|
-
return {
|
|
204
|
-
success: false,
|
|
205
|
-
error: `Ivy extraction requires the '@angular/localize' package.`,
|
|
206
|
-
outputPath: outFile,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
209
|
// All the localize usages are setup to first try the ESM entry point then fallback to the deep imports.
|
|
210
210
|
// This provides interim compatibility while the framework is transitioned to bundled ESM packages.
|
|
211
211
|
const localizeToolsModule = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
package/src/sass/sass-service.js
CHANGED
|
@@ -48,9 +48,9 @@ class SassWorkerImplementation {
|
|
|
48
48
|
* @param callback The function to execute when the rendering is complete.
|
|
49
49
|
*/
|
|
50
50
|
render(options, callback) {
|
|
51
|
-
// The `functions` and `importer` options are JavaScript functions that cannot be transferred.
|
|
51
|
+
// The `functions`, `logger` and `importer` options are JavaScript functions that cannot be transferred.
|
|
52
52
|
// If any additional function options are added in the future, they must be excluded as well.
|
|
53
|
-
const { functions, importer, ...serializableOptions } = options;
|
|
53
|
+
const { functions, importer, logger, ...serializableOptions } = options;
|
|
54
54
|
// The CLI's configuration does not use or expose the ability to defined custom Sass functions
|
|
55
55
|
if (functions && Object.keys(functions).length > 0) {
|
|
56
56
|
throw new Error('Sass custom functions are not supported.');
|
package/src/sass/worker.js
CHANGED
|
@@ -25,7 +25,6 @@ worker_threads_1.parentPort.on('message', ({ id, hasImporter, options }) => {
|
|
|
25
25
|
options.importer = function (url, prev) {
|
|
26
26
|
var _a;
|
|
27
27
|
Atomics.store(importerSignal, 0, 0);
|
|
28
|
-
// `this.fromImport` was added in dart-sass in 1.33.0, `@types/sass` doesn't include it yet.
|
|
29
28
|
const { fromImport } = this;
|
|
30
29
|
workerImporterPort.postMessage({ id, url, prev, fromImport });
|
|
31
30
|
Atomics.wait(importerSignal, 0, 0);
|
|
@@ -40,13 +40,12 @@ class BundleActionExecutor {
|
|
|
40
40
|
const executions = new Map();
|
|
41
41
|
for (const action of actions) {
|
|
42
42
|
const execution = executor(action);
|
|
43
|
-
executions.set(execution, execution.then((result) =>
|
|
44
|
-
executions.delete(execution);
|
|
45
|
-
return result;
|
|
46
|
-
}));
|
|
43
|
+
executions.set(execution, execution.then((result) => [execution, result]));
|
|
47
44
|
}
|
|
48
45
|
while (executions.size > 0) {
|
|
49
|
-
|
|
46
|
+
const [execution, result] = await Promise.race(executions.values());
|
|
47
|
+
executions.delete(execution);
|
|
48
|
+
yield result;
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
stop() {
|
|
@@ -16,8 +16,7 @@ function normalizeOptimization(optimization = true) {
|
|
|
16
16
|
? optimization.styles
|
|
17
17
|
: {
|
|
18
18
|
minify: !!optimization.styles,
|
|
19
|
-
|
|
20
|
-
inlineCritical: false,
|
|
19
|
+
inlineCritical: !!optimization.styles,
|
|
21
20
|
},
|
|
22
21
|
fonts: typeof optimization.fonts === 'object'
|
|
23
22
|
? optimization.fonts
|
|
@@ -30,8 +29,7 @@ function normalizeOptimization(optimization = true) {
|
|
|
30
29
|
scripts: optimization,
|
|
31
30
|
styles: {
|
|
32
31
|
minify: optimization,
|
|
33
|
-
|
|
34
|
-
inlineCritical: false,
|
|
32
|
+
inlineCritical: optimization,
|
|
35
33
|
},
|
|
36
34
|
fonts: {
|
|
37
35
|
inline: optimization,
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { Path } from '@angular-devkit/core';
|
|
9
|
-
export declare function augmentAppWithServiceWorker(
|
|
9
|
+
export declare function augmentAppWithServiceWorker(appRoot: Path, outputPath: Path, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
@@ -32,7 +32,6 @@ const crypto = __importStar(require("crypto"));
|
|
|
32
32
|
const fs_1 = require("fs");
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const stream_1 = require("stream");
|
|
35
|
-
const url_1 = require("url");
|
|
36
35
|
const load_esm_1 = require("./load-esm");
|
|
37
36
|
class CliFilesystem {
|
|
38
37
|
constructor(base) {
|
|
@@ -73,26 +72,12 @@ class CliFilesystem {
|
|
|
73
72
|
return items;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
|
-
async function augmentAppWithServiceWorker(
|
|
75
|
+
async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswConfigPath) {
|
|
77
76
|
const distPath = (0, core_1.getSystemPath)((0, core_1.normalize)(outputPath));
|
|
78
|
-
const systemProjectRoot = (0, core_1.getSystemPath)(projectRoot);
|
|
79
|
-
// Find the service worker package
|
|
80
|
-
const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js', {
|
|
81
|
-
paths: [systemProjectRoot],
|
|
82
|
-
});
|
|
83
|
-
// Absolute paths on Windows must be `file://` URLs when using ESM. Otherwise,
|
|
84
|
-
// `c:` would be interpreted as a protocol instead of a drive letter.
|
|
85
|
-
const swConfigPath = (0, url_1.pathToFileURL)(require.resolve('@angular/service-worker/config', {
|
|
86
|
-
paths: [systemProjectRoot],
|
|
87
|
-
}));
|
|
88
77
|
// Determine the configuration file path
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
configPath = path.join((0, core_1.getSystemPath)(appRoot), 'ngsw-config.json');
|
|
95
|
-
}
|
|
78
|
+
const configPath = ngswConfigPath
|
|
79
|
+
? (0, core_1.getSystemPath)((0, core_1.normalize)(ngswConfigPath))
|
|
80
|
+
: path.join((0, core_1.getSystemPath)(appRoot), 'ngsw-config.json');
|
|
96
81
|
// Read the configuration file
|
|
97
82
|
let config;
|
|
98
83
|
try {
|
|
@@ -112,13 +97,15 @@ async function augmentAppWithServiceWorker(projectRoot, appRoot, outputPath, bas
|
|
|
112
97
|
// Load ESM `@angular/service-worker/config` using the TypeScript dynamic import workaround.
|
|
113
98
|
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
114
99
|
// changed to a direct dynamic import.
|
|
115
|
-
const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)(
|
|
100
|
+
const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)('@angular/service-worker/config')).Generator;
|
|
116
101
|
// Generate the manifest
|
|
117
102
|
const generator = new GeneratorConstructor(new CliFilesystem(distPath), baseHref);
|
|
118
103
|
const output = await generator.process(config);
|
|
119
104
|
// Write the manifest
|
|
120
105
|
const manifest = JSON.stringify(output, null, 2);
|
|
121
106
|
await fs_1.promises.writeFile(path.join(distPath, 'ngsw.json'), manifest);
|
|
107
|
+
// Find the service worker package
|
|
108
|
+
const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js');
|
|
122
109
|
// Write the worker code
|
|
123
110
|
await fs_1.promises.copyFile(workerPath, path.join(distPath, 'ngsw-worker.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
124
111
|
// If present, write the safety worker code
|
|
@@ -15,7 +15,7 @@ import { WebpackConfigOptions } from '../utils/build-options';
|
|
|
15
15
|
import { I18nOptions } from './i18n-options';
|
|
16
16
|
export declare type BrowserWebpackConfigOptions = WebpackConfigOptions<NormalizedBrowserBuilderSchema>;
|
|
17
17
|
export declare type WebpackPartialGenerator = (configurationOptions: BrowserWebpackConfigOptions) => (Promise<Configuration> | Configuration)[];
|
|
18
|
-
export declare function generateWebpackConfig(workspaceRoot: string, projectRoot: string, sourceRoot: string | undefined, options: NormalizedBrowserBuilderSchema, webpackPartialGenerator: WebpackPartialGenerator, logger: logging.LoggerApi, extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>): Promise<Configuration>;
|
|
18
|
+
export declare function generateWebpackConfig(workspaceRoot: string, projectRoot: string, sourceRoot: string | undefined, projectName: string, options: NormalizedBrowserBuilderSchema, webpackPartialGenerator: WebpackPartialGenerator, logger: logging.LoggerApi, extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>): Promise<Configuration>;
|
|
19
19
|
export declare function generateI18nBrowserWebpackConfigFromContext(options: BrowserBuilderSchema, context: BuilderContext, webpackPartialGenerator: WebpackPartialGenerator, extraBuildOptions?: Partial<NormalizedBrowserBuilderSchema>): Promise<{
|
|
20
20
|
config: Configuration;
|
|
21
21
|
projectRoot: string;
|
|
@@ -36,7 +36,7 @@ const utils_1 = require("../utils");
|
|
|
36
36
|
const read_tsconfig_1 = require("../utils/read-tsconfig");
|
|
37
37
|
const builder_watch_plugin_1 = require("../webpack/plugins/builder-watch-plugin");
|
|
38
38
|
const i18n_options_1 = require("./i18n-options");
|
|
39
|
-
async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, options, webpackPartialGenerator, logger, extraBuildOptions) {
|
|
39
|
+
async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, projectName, options, webpackPartialGenerator, logger, extraBuildOptions) {
|
|
40
40
|
// Ensure Build Optimizer is only used with AOT.
|
|
41
41
|
if (options.buildOptimizer && !options.aot) {
|
|
42
42
|
throw new Error(`The 'buildOptimizer' option cannot be used without 'aot'.`);
|
|
@@ -54,6 +54,7 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, opt
|
|
|
54
54
|
buildOptions,
|
|
55
55
|
tsConfig,
|
|
56
56
|
tsConfigPath,
|
|
57
|
+
projectName,
|
|
57
58
|
scriptTarget,
|
|
58
59
|
};
|
|
59
60
|
wco.buildOptions.progress = (0, utils_1.defaultProgress)(wco.buildOptions.progress);
|
|
@@ -119,7 +120,7 @@ async function generateBrowserWebpackConfigFromContext(options, context, webpack
|
|
|
119
120
|
? (0, core_1.resolve)(workspaceRoot, (0, core_1.normalize)(projectSourceRoot))
|
|
120
121
|
: undefined;
|
|
121
122
|
const normalizedOptions = (0, utils_1.normalizeBrowserSchema)(workspaceRoot, projectRoot, sourceRoot, options, projectMetadata);
|
|
122
|
-
const config = await generateWebpackConfig((0, core_1.getSystemPath)(workspaceRoot), (0, core_1.getSystemPath)(projectRoot), sourceRoot && (0, core_1.getSystemPath)(sourceRoot), normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
|
|
123
|
+
const config = await generateWebpackConfig((0, core_1.getSystemPath)(workspaceRoot), (0, core_1.getSystemPath)(projectRoot), sourceRoot && (0, core_1.getSystemPath)(sourceRoot), projectName, normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
|
|
123
124
|
// If builder watch support is present in the context, add watch plugin
|
|
124
125
|
// This is internal only and currently only used for testing
|
|
125
126
|
const watcherFactory = context.watcherFactory;
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.getAnalyticsConfig = void 0;
|
|
11
11
|
const analytics_1 = require("../plugins/analytics");
|
|
12
12
|
function getAnalyticsConfig(wco, context) {
|
|
13
|
+
var _a;
|
|
13
14
|
if (!context.analytics) {
|
|
14
15
|
return {};
|
|
15
16
|
}
|
|
@@ -21,7 +22,9 @@ function getAnalyticsConfig(wco, context) {
|
|
|
21
22
|
}
|
|
22
23
|
// The category is the builder name if it's an angular builder.
|
|
23
24
|
return {
|
|
24
|
-
plugins: [
|
|
25
|
+
plugins: [
|
|
26
|
+
new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category, (_a = wco.buildOptions.aot) !== null && _a !== void 0 ? _a : false),
|
|
27
|
+
],
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
exports.getAnalyticsConfig = getAnalyticsConfig;
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { Configuration } from 'webpack';
|
|
9
|
-
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
10
|
-
export declare function getCommonConfig(wco: WebpackConfigOptions): Promise<Configuration>;
|
|
9
|
+
import { WebpackConfigOptions, WebpackTestOptions } from '../../utils/build-options';
|
|
10
|
+
export declare function getCommonConfig(wco: WebpackConfigOptions<WebpackTestOptions>): Promise<Configuration>;
|
|
@@ -47,8 +47,8 @@ const helpers_1 = require("../utils/helpers");
|
|
|
47
47
|
// eslint-disable-next-line max-lines-per-function
|
|
48
48
|
async function getCommonConfig(wco) {
|
|
49
49
|
var _a, _b;
|
|
50
|
-
const { root, projectRoot, buildOptions, tsConfig } = wco;
|
|
51
|
-
const { cache, platform = 'browser', sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, } = buildOptions;
|
|
50
|
+
const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot } = wco;
|
|
51
|
+
const { cache, codeCoverage, codeCoverageExclude = [], platform = 'browser', sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, } = buildOptions;
|
|
52
52
|
const extraPlugins = [];
|
|
53
53
|
const extraRules = [];
|
|
54
54
|
const entryPoints = {};
|
|
@@ -282,6 +282,7 @@ async function getCommonConfig(wco) {
|
|
|
282
282
|
context: root,
|
|
283
283
|
entry: entryPoints,
|
|
284
284
|
output: {
|
|
285
|
+
uniqueName: projectName,
|
|
285
286
|
hashFunction: 'xxhash64',
|
|
286
287
|
clean: (_a = buildOptions.deleteOutputPath) !== null && _a !== void 0 ? _a : true,
|
|
287
288
|
path: path.resolve(root, buildOptions.outputPath),
|
|
@@ -324,6 +325,12 @@ async function getCommonConfig(wco) {
|
|
|
324
325
|
scriptTarget: wco.scriptTarget,
|
|
325
326
|
aot: buildOptions.aot,
|
|
326
327
|
optimize: buildOptions.buildOptimizer,
|
|
328
|
+
instrumentCode: codeCoverage
|
|
329
|
+
? {
|
|
330
|
+
includedBasePath: sourceRoot,
|
|
331
|
+
excludedPaths: (0, helpers_1.getInstrumentationExcludedPaths)(root, codeCoverageExclude),
|
|
332
|
+
}
|
|
333
|
+
: undefined,
|
|
327
334
|
},
|
|
328
335
|
},
|
|
329
336
|
],
|
|
@@ -27,32 +27,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getTestConfig = void 0;
|
|
30
|
-
const glob = __importStar(require("glob"));
|
|
31
30
|
const path = __importStar(require("path"));
|
|
32
31
|
const typescript_1 = require("typescript");
|
|
33
32
|
const helpers_1 = require("../utils/helpers");
|
|
34
33
|
function getTestConfig(wco) {
|
|
35
|
-
const { buildOptions: {
|
|
36
|
-
const extraRules = [];
|
|
34
|
+
const { buildOptions: { main, sourceMap, webWorkerTsConfig }, root, } = wco;
|
|
37
35
|
const extraPlugins = [];
|
|
38
|
-
if (codeCoverage) {
|
|
39
|
-
const exclude = [/\.(e2e|spec)\.tsx?$/, /node_modules/];
|
|
40
|
-
if (codeCoverageExclude) {
|
|
41
|
-
for (const excludeGlob of codeCoverageExclude) {
|
|
42
|
-
glob
|
|
43
|
-
.sync(path.join(root, excludeGlob), { nodir: true })
|
|
44
|
-
.forEach((file) => exclude.push(path.normalize(file)));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
extraRules.push({
|
|
48
|
-
test: /\.[cm]?[tj]sx?$/,
|
|
49
|
-
loader: require.resolve('@jsdevtools/coverage-istanbul-loader'),
|
|
50
|
-
options: { esModules: true },
|
|
51
|
-
enforce: 'post',
|
|
52
|
-
exclude,
|
|
53
|
-
include: sourceRoot,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
36
|
if (sourceMap.scripts || sourceMap.styles) {
|
|
57
37
|
extraPlugins.push((0, helpers_1.getSourceMapDevTool)(sourceMap.scripts, sourceMap.styles, false, true));
|
|
58
38
|
}
|
|
@@ -68,7 +48,6 @@ function getTestConfig(wco) {
|
|
|
68
48
|
main: path.resolve(root, main),
|
|
69
49
|
},
|
|
70
50
|
module: {
|
|
71
|
-
rules: extraRules,
|
|
72
51
|
parser: webWorkerTsConfig === undefined
|
|
73
52
|
? {
|
|
74
53
|
javascript: {
|
|
@@ -40,10 +40,10 @@ export declare class NgBuildAnalyticsPlugin {
|
|
|
40
40
|
protected _projectRoot: string;
|
|
41
41
|
protected _analytics: analytics.Analytics;
|
|
42
42
|
protected _category: string;
|
|
43
|
-
private
|
|
43
|
+
private aotEnabled;
|
|
44
44
|
protected _built: boolean;
|
|
45
45
|
protected _stats: AnalyticsBuildStats;
|
|
46
|
-
constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string,
|
|
46
|
+
constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string, aotEnabled: boolean);
|
|
47
47
|
protected _reset(): void;
|
|
48
48
|
protected _getMetrics(stats: Stats): (string | number)[];
|
|
49
49
|
protected _getDimensions(): (string | number | boolean)[];
|
|
@@ -73,11 +73,11 @@ class AnalyticsBuildStats {
|
|
|
73
73
|
* Analytics plugin that reports the analytics we want from the CLI.
|
|
74
74
|
*/
|
|
75
75
|
class NgBuildAnalyticsPlugin {
|
|
76
|
-
constructor(_projectRoot, _analytics, _category,
|
|
76
|
+
constructor(_projectRoot, _analytics, _category, aotEnabled) {
|
|
77
77
|
this._projectRoot = _projectRoot;
|
|
78
78
|
this._analytics = _analytics;
|
|
79
79
|
this._category = _category;
|
|
80
|
-
this.
|
|
80
|
+
this.aotEnabled = aotEnabled;
|
|
81
81
|
this._built = false;
|
|
82
82
|
this._stats = new AnalyticsBuildStats();
|
|
83
83
|
}
|
|
@@ -108,7 +108,7 @@ class NgBuildAnalyticsPlugin {
|
|
|
108
108
|
// Adding commas before and after so the regex are easier to define filters.
|
|
109
109
|
dimensions[core_1.analytics.NgCliAnalyticsDimensions.BuildErrors] = `,${this._stats.errors.join()},`;
|
|
110
110
|
}
|
|
111
|
-
dimensions[core_1.analytics.NgCliAnalyticsDimensions.
|
|
111
|
+
dimensions[core_1.analytics.NgCliAnalyticsDimensions.AotEnabled] = this.aotEnabled;
|
|
112
112
|
return dimensions;
|
|
113
113
|
}
|
|
114
114
|
_reportBuildMetrics(stats) {
|
|
@@ -20,3 +20,4 @@ export declare function getSourceMapDevTool(scriptsSourceMap: boolean | undefine
|
|
|
20
20
|
export declare function isPolyfillsEntry(name: string): boolean;
|
|
21
21
|
export declare function getWatchOptions(poll: number | undefined): NonNullable<Configuration['watchOptions']>;
|
|
22
22
|
export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
|
|
23
|
+
export declare function getInstrumentationExcludedPaths(sourceRoot: string, excludedPaths: string[]): Set<string>;
|
|
@@ -25,8 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
__setModuleDefault(result, mod);
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
28
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.assetNameTemplateFactory = exports.getWatchOptions = exports.isPolyfillsEntry = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
|
|
32
|
+
exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.getWatchOptions = exports.isPolyfillsEntry = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
|
|
33
|
+
const glob_1 = __importDefault(require("glob"));
|
|
30
34
|
const path = __importStar(require("path"));
|
|
31
35
|
const webpack_1 = require("webpack");
|
|
32
36
|
function getOutputHashFormat(option, length = 20) {
|
|
@@ -126,3 +130,13 @@ function assetNameTemplateFactory(hashFormat) {
|
|
|
126
130
|
};
|
|
127
131
|
}
|
|
128
132
|
exports.assetNameTemplateFactory = assetNameTemplateFactory;
|
|
133
|
+
function getInstrumentationExcludedPaths(sourceRoot, excludedPaths) {
|
|
134
|
+
const excluded = new Set();
|
|
135
|
+
for (const excludeGlob of excludedPaths) {
|
|
136
|
+
glob_1.default
|
|
137
|
+
.sync(path.join(sourceRoot, excludeGlob), { nodir: true })
|
|
138
|
+
.forEach((p) => excluded.add(path.normalize(p)));
|
|
139
|
+
}
|
|
140
|
+
return excluded;
|
|
141
|
+
}
|
|
142
|
+
exports.getInstrumentationExcludedPaths = getInstrumentationExcludedPaths;
|