@angular-devkit/build-angular 14.0.0-next.6 → 14.0.0-next.9
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 +21 -22
- package/src/builders/app-shell/index.js +1 -2
- package/src/builders/browser/index.js +3 -4
- package/src/builders/karma/index.d.ts +1 -1
- package/src/builders/karma/index.js +5 -5
- package/src/typings.d.ts +0 -4
- package/src/utils/check-port.js +3 -3
- package/src/utils/normalize-asset-patterns.d.ts +2 -2
- package/src/utils/normalize-asset-patterns.js +34 -10
- package/src/utils/normalize-builder-schema.js +2 -3
- package/src/utils/normalize-file-replacements.d.ts +4 -4
- package/src/utils/normalize-file-replacements.js +38 -18
- package/src/utils/process-bundle.js +1 -1
- package/src/utils/purge-cache.js +3 -4
- package/src/utils/service-worker.d.ts +1 -2
- package/src/utils/service-worker.js +8 -10
- package/src/webpack/configs/analytics.js +1 -4
- package/src/webpack/configs/common.js +5 -11
- package/src/webpack/configs/dev-server.js +1 -1
- package/src/webpack/configs/styles.js +9 -20
- package/src/webpack/plugins/analytics.d.ts +1 -2
- package/src/webpack/plugins/analytics.js +1 -3
- package/src/webpack/plugins/css-optimizer-plugin.js +7 -3
- package/src/webpack/plugins/esbuild-executor.d.ts +2 -2
- package/src/webpack/plugins/esbuild-executor.js +6 -16
- package/src/webpack/plugins/javascript-optimizer-plugin.js +8 -4
- package/src/webpack/plugins/postcss-cli-resources.js +2 -2
- package/src/webpack/plugins/transfer-size-plugin.js +3 -2
- package/src/webpack/plugins/typescript.js +1 -2
- package/esbuild-check.js +0 -16
package/package.json
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "14.0.0-next.
|
|
3
|
+
"version": "14.0.0-next.9",
|
|
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.1.2",
|
|
10
|
-
"@angular-devkit/architect": "0.1400.0-next.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1400.0-next.
|
|
12
|
-
"@angular-devkit/core": "14.0.0-next.
|
|
13
|
-
"@babel/core": "7.17.
|
|
14
|
-
"@babel/generator": "7.17.
|
|
10
|
+
"@angular-devkit/architect": "0.1400.0-next.9",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1400.0-next.9",
|
|
12
|
+
"@angular-devkit/core": "14.0.0-next.9",
|
|
13
|
+
"@babel/core": "7.17.9",
|
|
14
|
+
"@babel/generator": "7.17.9",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.16.7",
|
|
16
16
|
"@babel/plugin-proposal-async-generator-functions": "7.16.8",
|
|
17
17
|
"@babel/plugin-transform-async-to-generator": "7.16.8",
|
|
18
18
|
"@babel/plugin-transform-runtime": "7.17.0",
|
|
19
19
|
"@babel/preset-env": "7.16.11",
|
|
20
|
-
"@babel/runtime": "7.17.
|
|
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.0-next.
|
|
23
|
+
"@ngtools/webpack": "14.0.0-next.9",
|
|
24
24
|
"ansi-colors": "4.1.1",
|
|
25
|
-
"babel-loader": "8.2.
|
|
25
|
+
"babel-loader": "8.2.4",
|
|
26
26
|
"babel-plugin-istanbul": "6.1.1",
|
|
27
27
|
"browserslist": "^4.9.1",
|
|
28
|
-
"cacache": "16.0.
|
|
28
|
+
"cacache": "16.0.4",
|
|
29
29
|
"copy-webpack-plugin": "10.2.4",
|
|
30
|
-
"core-js": "3.21.1",
|
|
31
30
|
"critters": "0.0.16",
|
|
32
31
|
"css-loader": "6.7.1",
|
|
33
|
-
"esbuild-wasm": "0.14.
|
|
32
|
+
"esbuild-wasm": "0.14.36",
|
|
34
33
|
"glob": "7.2.0",
|
|
35
34
|
"https-proxy-agent": "5.0.0",
|
|
36
|
-
"inquirer": "8.2.
|
|
35
|
+
"inquirer": "8.2.2",
|
|
37
36
|
"jsonc-parser": "3.0.0",
|
|
38
37
|
"karma-source-map-support": "1.4.0",
|
|
39
38
|
"less": "4.1.2",
|
|
@@ -47,31 +46,31 @@
|
|
|
47
46
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
48
47
|
"piscina": "3.2.0",
|
|
49
48
|
"postcss": "8.4.12",
|
|
50
|
-
"postcss-import": "14.0
|
|
49
|
+
"postcss-import": "14.1.0",
|
|
51
50
|
"postcss-loader": "6.2.1",
|
|
52
|
-
"postcss-preset-env": "7.4.
|
|
51
|
+
"postcss-preset-env": "7.4.3",
|
|
53
52
|
"regenerator-runtime": "0.13.9",
|
|
54
53
|
"resolve-url-loader": "5.0.0",
|
|
55
54
|
"rxjs": "6.6.7",
|
|
56
|
-
"sass": "1.
|
|
55
|
+
"sass": "1.50.0",
|
|
57
56
|
"sass-loader": "12.6.0",
|
|
58
|
-
"semver": "7.3.
|
|
57
|
+
"semver": "7.3.6",
|
|
59
58
|
"source-map-loader": "3.0.1",
|
|
60
59
|
"source-map-support": "0.5.21",
|
|
61
|
-
"stylus": "0.
|
|
60
|
+
"stylus": "0.57.0",
|
|
62
61
|
"stylus-loader": "6.2.0",
|
|
63
62
|
"terser": "5.12.1",
|
|
64
63
|
"text-table": "0.2.0",
|
|
65
64
|
"tree-kill": "1.2.2",
|
|
66
65
|
"tslib": "2.3.1",
|
|
67
|
-
"webpack": "5.
|
|
66
|
+
"webpack": "5.72.0",
|
|
68
67
|
"webpack-dev-middleware": "5.3.1",
|
|
69
|
-
"webpack-dev-server": "4.
|
|
68
|
+
"webpack-dev-server": "4.8.1",
|
|
70
69
|
"webpack-merge": "5.8.0",
|
|
71
70
|
"webpack-subresource-integrity": "5.1.0"
|
|
72
71
|
},
|
|
73
72
|
"optionalDependencies": {
|
|
74
|
-
"esbuild": "0.14.
|
|
73
|
+
"esbuild": "0.14.36"
|
|
75
74
|
},
|
|
76
75
|
"peerDependencies": {
|
|
77
76
|
"@angular/compiler-cli": "^14.0.0 || ^14.0.0-next",
|
|
@@ -81,7 +80,7 @@
|
|
|
81
80
|
"ng-packagr": "^14.0.0 || ^14.0.0-next",
|
|
82
81
|
"protractor": "^7.0.0",
|
|
83
82
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
84
|
-
"typescript": "
|
|
83
|
+
"typescript": "~4.6.2"
|
|
85
84
|
},
|
|
86
85
|
"peerDependenciesMeta": {
|
|
87
86
|
"@angular/localize": {
|
|
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
const architect_1 = require("@angular-devkit/architect");
|
|
34
|
-
const core_1 = require("@angular-devkit/core");
|
|
35
34
|
const fs = __importStar(require("fs"));
|
|
36
35
|
const path = __importStar(require("path"));
|
|
37
36
|
const utils_1 = require("../../utils");
|
|
@@ -96,7 +95,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
96
95
|
}
|
|
97
96
|
await fs.promises.writeFile(outputIndexPath, html);
|
|
98
97
|
if (browserOptions.serviceWorker) {
|
|
99
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(
|
|
98
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, outputPath, browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
return browserResult;
|
|
@@ -33,7 +33,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
exports.buildWebpackBrowser = exports.BUILD_TIMEOUT = void 0;
|
|
34
34
|
const architect_1 = require("@angular-devkit/architect");
|
|
35
35
|
const build_webpack_1 = require("@angular-devkit/build-webpack");
|
|
36
|
-
const core_1 = require("@angular-devkit/core");
|
|
37
36
|
const fs = __importStar(require("fs"));
|
|
38
37
|
const path = __importStar(require("path"));
|
|
39
38
|
const rxjs_1 = require("rxjs");
|
|
@@ -75,7 +74,7 @@ async function initialize(options, context, webpackConfigurationTransform) {
|
|
|
75
74
|
]);
|
|
76
75
|
// Validate asset option values if processed directly
|
|
77
76
|
if (((_a = options.assets) === null || _a === void 0 ? void 0 : _a.length) && !((_b = adjustedOptions.assets) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
78
|
-
(0, utils_1.normalizeAssetPatterns)(options.assets,
|
|
77
|
+
(0, utils_1.normalizeAssetPatterns)(options.assets, context.workspaceRoot, projectRoot, projectSourceRoot).forEach(({ output }) => {
|
|
79
78
|
if (output.startsWith('..')) {
|
|
80
79
|
throw new Error('An asset cannot be written to a location outside of the output path.');
|
|
81
80
|
}
|
|
@@ -189,7 +188,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
189
188
|
if (!options.watch && ((_c = options.assets) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
190
189
|
spinner.start('Copying assets...');
|
|
191
190
|
try {
|
|
192
|
-
await (0, copy_assets_1.copyAssets)((0, utils_1.normalizeAssetPatterns)(options.assets,
|
|
191
|
+
await (0, copy_assets_1.copyAssets)((0, utils_1.normalizeAssetPatterns)(options.assets, context.workspaceRoot, projectRoot, projectSourceRoot), Array.from(outputPaths.values()), context.workspaceRoot);
|
|
193
192
|
spinner.succeed('Copying assets complete.');
|
|
194
193
|
}
|
|
195
194
|
catch (err) {
|
|
@@ -253,7 +252,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
253
252
|
spinner.start('Generating service worker...');
|
|
254
253
|
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
255
254
|
try {
|
|
256
|
-
await (0, service_worker_1.augmentAppWithServiceWorker)(
|
|
255
|
+
await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, outputPath, getLocaleBaseHref(i18n, locale) || options.baseHref || '/', options.ngswConfigPath);
|
|
257
256
|
}
|
|
258
257
|
catch (error) {
|
|
259
258
|
spinner.fail('Service worker generation failed.');
|
|
@@ -23,5 +23,5 @@ export declare function execute(options: KarmaBuilderOptions, context: BuilderCo
|
|
|
23
23
|
karmaOptions?: (options: KarmaConfigOptions) => KarmaConfigOptions;
|
|
24
24
|
}): Observable<BuilderOutput>;
|
|
25
25
|
export { KarmaBuilderOptions };
|
|
26
|
-
declare const _default: import("@angular-devkit/architect/src/internal").Builder<Record<string, string> & KarmaBuilderOptions & import("
|
|
26
|
+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<Record<string, string> & KarmaBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
27
27
|
export default _default;
|
|
@@ -32,8 +32,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.execute = void 0;
|
|
34
34
|
const architect_1 = require("@angular-devkit/architect");
|
|
35
|
-
const
|
|
36
|
-
const path_1 = require("path");
|
|
35
|
+
const path = __importStar(require("path"));
|
|
37
36
|
const rxjs_1 = require("rxjs");
|
|
38
37
|
const operators_1 = require("rxjs/operators");
|
|
39
38
|
const purge_cache_1 = require("../../utils/purge-cache");
|
|
@@ -108,7 +107,8 @@ function execute(options, context, transforms = {}) {
|
|
|
108
107
|
throw new Error('The builder requires a target.');
|
|
109
108
|
}
|
|
110
109
|
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
111
|
-
const
|
|
110
|
+
const projectRoot = path.join(context.workspaceRoot, (_c = projectMetadata.root) !== null && _c !== void 0 ? _c : '');
|
|
111
|
+
const projectSourceRoot = path.join(projectRoot, (_d = projectMetadata.sourceRoot) !== null && _d !== void 0 ? _d : '');
|
|
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) {
|
|
@@ -123,7 +123,7 @@ function execute(options, context, transforms = {}) {
|
|
|
123
123
|
webpackConfig.module.rules = rules;
|
|
124
124
|
}
|
|
125
125
|
rules.unshift({
|
|
126
|
-
test:
|
|
126
|
+
test: path.resolve(context.workspaceRoot, options.main),
|
|
127
127
|
use: {
|
|
128
128
|
// cannot be a simple path as it differs between environments
|
|
129
129
|
loader: single_test_transform_1.SingleTestTransformLoader,
|
|
@@ -139,7 +139,7 @@ function execute(options, context, transforms = {}) {
|
|
|
139
139
|
webpackConfig,
|
|
140
140
|
logger: context.logger,
|
|
141
141
|
};
|
|
142
|
-
const config = await karma.config.parseConfig(
|
|
142
|
+
const config = await karma.config.parseConfig(path.resolve(context.workspaceRoot, options.karmaConfig), transforms.karmaOptions ? transforms.karmaOptions(karmaOptions) : karmaOptions, { promiseConfig: true, throwErrors: true });
|
|
143
143
|
return [karma, config];
|
|
144
144
|
}), (0, operators_1.switchMap)(([karma, karmaConfig]) => new rxjs_1.Observable((subscriber) => {
|
|
145
145
|
var _a, _b, _c;
|
package/src/typings.d.ts
CHANGED
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
declare module '@discoveryjs/json-ext' {
|
|
10
|
-
export function stringifyStream(value: unknown): import('stream').Readable;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
9
|
declare module '@babel/helper-annotate-as-pure' {
|
|
14
10
|
export default function annotateAsPure(
|
|
15
11
|
pathOrNode: import('@babel/types').Node | { node: import('@babel/types').Node },
|
package/src/utils/check-port.js
CHANGED
|
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.checkPort = void 0;
|
|
34
|
-
const inquirer_1 = require("inquirer");
|
|
35
34
|
const net = __importStar(require("net"));
|
|
36
35
|
const tty_1 = require("./tty");
|
|
37
36
|
function createInUseError(port) {
|
|
@@ -53,12 +52,13 @@ async function checkPort(port, host) {
|
|
|
53
52
|
reject(createInUseError(port));
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
|
-
(
|
|
55
|
+
Promise.resolve().then(() => __importStar(require('inquirer'))).then(({ prompt }) => prompt({
|
|
57
56
|
type: 'confirm',
|
|
58
57
|
name: 'useDifferent',
|
|
59
58
|
message: `Port ${port} is already in use.\nWould you like to use a different port?`,
|
|
60
59
|
default: true,
|
|
61
|
-
})
|
|
60
|
+
}))
|
|
61
|
+
.then((answers) => (answers.useDifferent ? resolve(0) : reject(createInUseError(port))), () => reject(createInUseError(port)));
|
|
62
62
|
})
|
|
63
63
|
.once('listening', () => {
|
|
64
64
|
server.close();
|
|
@@ -5,9 +5,9 @@
|
|
|
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 { BaseException
|
|
8
|
+
import { BaseException } from '@angular-devkit/core';
|
|
9
9
|
import { AssetPattern, AssetPatternClass } from '../builders/browser/schema';
|
|
10
10
|
export declare class MissingAssetSourceRootException extends BaseException {
|
|
11
11
|
constructor(path: String);
|
|
12
12
|
}
|
|
13
|
-
export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[],
|
|
13
|
+
export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): AssetPatternClass[];
|
|
@@ -6,28 +6,52 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
9
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
33
|
exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void 0;
|
|
11
34
|
const core_1 = require("@angular-devkit/core");
|
|
12
35
|
const fs_1 = require("fs");
|
|
36
|
+
const path = __importStar(require("path"));
|
|
13
37
|
class MissingAssetSourceRootException extends core_1.BaseException {
|
|
14
38
|
constructor(path) {
|
|
15
39
|
super(`The ${path} asset path must start with the project source root.`);
|
|
16
40
|
}
|
|
17
41
|
}
|
|
18
42
|
exports.MissingAssetSourceRootException = MissingAssetSourceRootException;
|
|
19
|
-
function normalizeAssetPatterns(assetPatterns,
|
|
20
|
-
// When sourceRoot is not available, we default to ${projectRoot}/src.
|
|
21
|
-
const sourceRoot = maybeSourceRoot || (0, core_1.join)(projectRoot, 'src');
|
|
22
|
-
const resolvedSourceRoot = (0, core_1.resolve)(root, sourceRoot);
|
|
43
|
+
function normalizeAssetPatterns(assetPatterns, workspaceRoot, projectRoot, projectSourceRoot) {
|
|
23
44
|
if (assetPatterns.length === 0) {
|
|
24
45
|
return [];
|
|
25
46
|
}
|
|
47
|
+
// When sourceRoot is not available, we default to ${projectRoot}/src.
|
|
48
|
+
const sourceRoot = projectSourceRoot || path.join(projectRoot, 'src');
|
|
49
|
+
const resolvedSourceRoot = path.resolve(workspaceRoot, sourceRoot);
|
|
26
50
|
return assetPatterns.map((assetPattern) => {
|
|
27
51
|
// Normalize string asset patterns to objects.
|
|
28
52
|
if (typeof assetPattern === 'string') {
|
|
29
|
-
const assetPath =
|
|
30
|
-
const resolvedAssetPath =
|
|
53
|
+
const assetPath = path.normalize(assetPattern);
|
|
54
|
+
const resolvedAssetPath = path.resolve(workspaceRoot, assetPath);
|
|
31
55
|
// Check if the string asset is within sourceRoot.
|
|
32
56
|
if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
|
|
33
57
|
throw new MissingAssetSourceRootException(assetPattern);
|
|
@@ -35,7 +59,7 @@ function normalizeAssetPatterns(assetPatterns, root, projectRoot, maybeSourceRoo
|
|
|
35
59
|
let glob, input;
|
|
36
60
|
let isDirectory = false;
|
|
37
61
|
try {
|
|
38
|
-
isDirectory = (0, fs_1.statSync)(
|
|
62
|
+
isDirectory = (0, fs_1.statSync)(resolvedAssetPath).isDirectory();
|
|
39
63
|
}
|
|
40
64
|
catch {
|
|
41
65
|
isDirectory = true;
|
|
@@ -48,12 +72,12 @@ function normalizeAssetPatterns(assetPatterns, root, projectRoot, maybeSourceRoo
|
|
|
48
72
|
}
|
|
49
73
|
else {
|
|
50
74
|
// Files are their own glob.
|
|
51
|
-
glob =
|
|
75
|
+
glob = path.basename(assetPath);
|
|
52
76
|
// Input directory is their original dirname.
|
|
53
|
-
input =
|
|
77
|
+
input = path.dirname(assetPath);
|
|
54
78
|
}
|
|
55
79
|
// Output directory for both is the relative path from source root to input.
|
|
56
|
-
const output =
|
|
80
|
+
const output = path.relative(resolvedSourceRoot, path.resolve(workspaceRoot, input));
|
|
57
81
|
// Return the asset pattern in object format.
|
|
58
82
|
return { glob, input, output };
|
|
59
83
|
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.normalizeBrowserSchema = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const normalize_asset_patterns_1 = require("./normalize-asset-patterns");
|
|
13
12
|
const normalize_cache_1 = require("./normalize-cache");
|
|
14
13
|
const normalize_file_replacements_1 = require("./normalize-file-replacements");
|
|
@@ -20,8 +19,8 @@ function normalizeBrowserSchema(workspaceRoot, projectRoot, projectSourceRoot, o
|
|
|
20
19
|
return {
|
|
21
20
|
...options,
|
|
22
21
|
cache: (0, normalize_cache_1.normalizeCacheOptions)(metadata, workspaceRoot),
|
|
23
|
-
assets: (0, normalize_asset_patterns_1.normalizeAssetPatterns)(options.assets || [],
|
|
24
|
-
fileReplacements: (0, normalize_file_replacements_1.normalizeFileReplacements)(options.fileReplacements || [],
|
|
22
|
+
assets: (0, normalize_asset_patterns_1.normalizeAssetPatterns)(options.assets || [], workspaceRoot, projectRoot, projectSourceRoot),
|
|
23
|
+
fileReplacements: (0, normalize_file_replacements_1.normalizeFileReplacements)(options.fileReplacements || [], workspaceRoot),
|
|
25
24
|
optimization: (0, normalize_optimization_1.normalizeOptimization)(options.optimization),
|
|
26
25
|
sourceMap: normalizedSourceMapOptions,
|
|
27
26
|
preserveSymlinks: options.preserveSymlinks === undefined
|
|
@@ -5,13 +5,13 @@
|
|
|
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 { BaseException
|
|
8
|
+
import { BaseException } from '@angular-devkit/core';
|
|
9
9
|
import { FileReplacement } from '../builders/browser/schema';
|
|
10
10
|
export declare class MissingFileReplacementException extends BaseException {
|
|
11
11
|
constructor(path: String);
|
|
12
12
|
}
|
|
13
13
|
export interface NormalizedFileReplacement {
|
|
14
|
-
replace:
|
|
15
|
-
with:
|
|
14
|
+
replace: string;
|
|
15
|
+
with: string;
|
|
16
16
|
}
|
|
17
|
-
export declare function normalizeFileReplacements(fileReplacements: FileReplacement[],
|
|
17
|
+
export declare function normalizeFileReplacements(fileReplacements: FileReplacement[], workspaceRoot: string): NormalizedFileReplacement[];
|
|
@@ -6,27 +6,51 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
9
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
33
|
exports.normalizeFileReplacements = exports.MissingFileReplacementException = void 0;
|
|
11
34
|
const core_1 = require("@angular-devkit/core");
|
|
12
35
|
const fs_1 = require("fs");
|
|
36
|
+
const path = __importStar(require("path"));
|
|
13
37
|
class MissingFileReplacementException extends core_1.BaseException {
|
|
14
38
|
constructor(path) {
|
|
15
39
|
super(`The ${path} path in file replacements does not exist.`);
|
|
16
40
|
}
|
|
17
41
|
}
|
|
18
42
|
exports.MissingFileReplacementException = MissingFileReplacementException;
|
|
19
|
-
function normalizeFileReplacements(fileReplacements,
|
|
43
|
+
function normalizeFileReplacements(fileReplacements, workspaceRoot) {
|
|
20
44
|
if (fileReplacements.length === 0) {
|
|
21
45
|
return [];
|
|
22
46
|
}
|
|
23
|
-
const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement,
|
|
47
|
+
const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement, workspaceRoot));
|
|
24
48
|
for (const { replace, with: replacementWith } of normalizedReplacement) {
|
|
25
|
-
if (!(0, fs_1.existsSync)(
|
|
26
|
-
throw new MissingFileReplacementException(
|
|
49
|
+
if (!(0, fs_1.existsSync)(replacementWith)) {
|
|
50
|
+
throw new MissingFileReplacementException(replacementWith);
|
|
27
51
|
}
|
|
28
|
-
if (!(0, fs_1.existsSync)(
|
|
29
|
-
throw new MissingFileReplacementException(
|
|
52
|
+
if (!(0, fs_1.existsSync)(replace)) {
|
|
53
|
+
throw new MissingFileReplacementException(replace);
|
|
30
54
|
}
|
|
31
55
|
}
|
|
32
56
|
return normalizedReplacement;
|
|
@@ -36,22 +60,18 @@ function normalizeFileReplacement(fileReplacement, root) {
|
|
|
36
60
|
let replacePath;
|
|
37
61
|
let withPath;
|
|
38
62
|
if (fileReplacement.src && fileReplacement.replaceWith) {
|
|
39
|
-
replacePath =
|
|
40
|
-
withPath =
|
|
63
|
+
replacePath = fileReplacement.src;
|
|
64
|
+
withPath = fileReplacement.replaceWith;
|
|
41
65
|
}
|
|
42
66
|
else if (fileReplacement.replace && fileReplacement.with) {
|
|
43
|
-
replacePath =
|
|
44
|
-
withPath =
|
|
67
|
+
replacePath = fileReplacement.replace;
|
|
68
|
+
withPath = fileReplacement.with;
|
|
45
69
|
}
|
|
46
70
|
else {
|
|
47
71
|
throw new Error(`Invalid file replacement: ${JSON.stringify(fileReplacement)}`);
|
|
48
72
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
if (root) {
|
|
54
|
-
withPath = (0, core_1.join)(root, withPath);
|
|
55
|
-
}
|
|
56
|
-
return { replace: replacePath, with: withPath };
|
|
73
|
+
return {
|
|
74
|
+
replace: path.join(root, replacePath),
|
|
75
|
+
with: path.join(root, withPath),
|
|
76
|
+
};
|
|
57
77
|
}
|
|
@@ -129,7 +129,7 @@ async function inlineLocales(options) {
|
|
|
129
129
|
// Same errors will contain the full content of the file as the error message
|
|
130
130
|
// Which makes it hard to find the actual error message.
|
|
131
131
|
const index = error.message.indexOf(')\n');
|
|
132
|
-
const msg = index !== -1 ? error.message.
|
|
132
|
+
const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
|
|
133
133
|
throw new Error(`${msg}\nAn error occurred inlining file "${options.filename}"`);
|
|
134
134
|
}
|
|
135
135
|
}
|
package/src/utils/purge-cache.js
CHANGED
|
@@ -27,10 +27,9 @@ async function purgeStaleBuildCache(context) {
|
|
|
27
27
|
.filter((d) => (0, path_1.join)(basePath, d.name) !== path && d.isDirectory())
|
|
28
28
|
.map((d) => {
|
|
29
29
|
const subPath = (0, path_1.join)(basePath, d.name);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
catch { }
|
|
30
|
+
return fs_1.promises
|
|
31
|
+
.rm(subPath, { force: true, recursive: true, maxRetries: 3 })
|
|
32
|
+
.catch(() => void 0);
|
|
34
33
|
});
|
|
35
34
|
await Promise.all(entriesToDelete);
|
|
36
35
|
}
|
|
@@ -5,5 +5,4 @@
|
|
|
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
|
-
|
|
9
|
-
export declare function augmentAppWithServiceWorker(appRoot: Path, outputPath: Path, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
8
|
+
export declare function augmentAppWithServiceWorker(appRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.augmentAppWithServiceWorker = void 0;
|
|
34
|
-
const core_1 = require("@angular-devkit/core");
|
|
35
34
|
const crypto = __importStar(require("crypto"));
|
|
36
35
|
const fs_1 = require("fs");
|
|
37
36
|
const path = __importStar(require("path"));
|
|
@@ -77,11 +76,10 @@ class CliFilesystem {
|
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswConfigPath) {
|
|
80
|
-
const distPath = (0, core_1.getSystemPath)((0, core_1.normalize)(outputPath));
|
|
81
79
|
// Determine the configuration file path
|
|
82
80
|
const configPath = ngswConfigPath
|
|
83
|
-
?
|
|
84
|
-
: path.join(
|
|
81
|
+
? path.normalize(ngswConfigPath)
|
|
82
|
+
: path.join(appRoot, 'ngsw-config.json');
|
|
85
83
|
// Read the configuration file
|
|
86
84
|
let config;
|
|
87
85
|
try {
|
|
@@ -91,7 +89,7 @@ async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswCo
|
|
|
91
89
|
catch (error) {
|
|
92
90
|
if (error.code === 'ENOENT') {
|
|
93
91
|
throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
|
|
94
|
-
` in the ${
|
|
92
|
+
` in the ${appRoot} folder. Either provide one or` +
|
|
95
93
|
' disable Service Worker in the angular.json configuration file.');
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
@@ -103,20 +101,20 @@ async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswCo
|
|
|
103
101
|
// changed to a direct dynamic import.
|
|
104
102
|
const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)('@angular/service-worker/config')).Generator;
|
|
105
103
|
// Generate the manifest
|
|
106
|
-
const generator = new GeneratorConstructor(new CliFilesystem(
|
|
104
|
+
const generator = new GeneratorConstructor(new CliFilesystem(outputPath), baseHref);
|
|
107
105
|
const output = await generator.process(config);
|
|
108
106
|
// Write the manifest
|
|
109
107
|
const manifest = JSON.stringify(output, null, 2);
|
|
110
|
-
await fs_1.promises.writeFile(path.join(
|
|
108
|
+
await fs_1.promises.writeFile(path.join(outputPath, 'ngsw.json'), manifest);
|
|
111
109
|
// Find the service worker package
|
|
112
110
|
const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js');
|
|
113
111
|
// Write the worker code
|
|
114
|
-
await fs_1.promises.copyFile(workerPath, path.join(
|
|
112
|
+
await fs_1.promises.copyFile(workerPath, path.join(outputPath, 'ngsw-worker.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
115
113
|
// If present, write the safety worker code
|
|
116
114
|
const safetyPath = path.join(path.dirname(workerPath), 'safety-worker.js');
|
|
117
115
|
try {
|
|
118
|
-
await fs_1.promises.copyFile(safetyPath, path.join(
|
|
119
|
-
await fs_1.promises.copyFile(safetyPath, path.join(
|
|
116
|
+
await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'worker-basic.min.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
117
|
+
await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'safety-worker.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
120
118
|
}
|
|
121
119
|
catch (error) {
|
|
122
120
|
if (error.code !== 'ENOENT') {
|
|
@@ -10,7 +10,6 @@ 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;
|
|
14
13
|
if (!context.analytics) {
|
|
15
14
|
return {};
|
|
16
15
|
}
|
|
@@ -22,9 +21,7 @@ function getAnalyticsConfig(wco, context) {
|
|
|
22
21
|
}
|
|
23
22
|
// The category is the builder name if it's an angular builder.
|
|
24
23
|
return {
|
|
25
|
-
plugins: [
|
|
26
|
-
new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category, (_a = wco.buildOptions.aot) !== null && _a !== void 0 ? _a : false),
|
|
27
|
-
],
|
|
24
|
+
plugins: [new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category)],
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
exports.getAnalyticsConfig = getAnalyticsConfig;
|
|
@@ -84,15 +84,6 @@ async function getCommonConfig(wco) {
|
|
|
84
84
|
entryPoints['polyfills'] = [projectPolyfills];
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
if (!buildOptions.aot) {
|
|
88
|
-
const jitPolyfills = require.resolve('core-js/proposals/reflect-metadata');
|
|
89
|
-
if (entryPoints['polyfills']) {
|
|
90
|
-
entryPoints['polyfills'].push(jitPolyfills);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
entryPoints['polyfills'] = [jitPolyfills];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
87
|
}
|
|
97
88
|
if (allowedCommonJsDependencies) {
|
|
98
89
|
// When this is not defined it means the builder doesn't support showing common js usages.
|
|
@@ -183,7 +174,9 @@ async function getCommonConfig(wco) {
|
|
|
183
174
|
test: tsConfig.options.allowJs ? /\.[cm]?[tj]sx?$/ : /\.[cm]?tsx?$/,
|
|
184
175
|
loader: webpack_1.AngularWebpackLoaderPath,
|
|
185
176
|
// The below are known paths that are not part of the TypeScript compilation even when allowJs is enabled.
|
|
186
|
-
exclude: [
|
|
177
|
+
exclude: [
|
|
178
|
+
/[\\/]node_modules[/\\](?:css-loader|mini-css-extract-plugin|webpack-dev-server|webpack)[/\\]/,
|
|
179
|
+
],
|
|
187
180
|
});
|
|
188
181
|
extraPlugins.push((0, typescript_2.createIvyPlugin)(wco, aot, tsConfigPath));
|
|
189
182
|
}
|
|
@@ -297,7 +290,7 @@ async function getCommonConfig(wco) {
|
|
|
297
290
|
// The below is needed due to a bug in `@babel/runtime`. See: https://github.com/babel/babel/issues/12824
|
|
298
291
|
resolve: { fullySpecified: false },
|
|
299
292
|
exclude: [
|
|
300
|
-
/[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill|whatwg-url)[/\\]/,
|
|
293
|
+
/[\\/]node_modules[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill|whatwg-url)[/\\]/,
|
|
301
294
|
],
|
|
302
295
|
use: [
|
|
303
296
|
{
|
|
@@ -326,6 +319,7 @@ async function getCommonConfig(wco) {
|
|
|
326
319
|
asyncWebAssembly: true,
|
|
327
320
|
},
|
|
328
321
|
infrastructureLogging: {
|
|
322
|
+
debug: verbose,
|
|
329
323
|
level: verbose ? 'verbose' : 'error',
|
|
330
324
|
},
|
|
331
325
|
stats: (0, helpers_1.getStatsOptions)(verbose),
|
|
@@ -118,7 +118,7 @@ function buildServePath(options, logger) {
|
|
|
118
118
|
servePath = defaultPath || '';
|
|
119
119
|
}
|
|
120
120
|
if (servePath.endsWith('/')) {
|
|
121
|
-
servePath = servePath.
|
|
121
|
+
servePath = servePath.slice(0, -1);
|
|
122
122
|
}
|
|
123
123
|
if (!servePath.startsWith('/')) {
|
|
124
124
|
servePath = `/${servePath}`;
|
|
@@ -98,16 +98,14 @@ function getStylesConfig(wco) {
|
|
|
98
98
|
wco.logger.warn('Stylus usage is deprecated and will be removed in a future major version. ' +
|
|
99
99
|
'To opt-out of the deprecated behaviour, please migrate to another stylesheet language.');
|
|
100
100
|
}
|
|
101
|
-
const sassImplementation =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
}
|
|
101
|
+
const sassImplementation = new sass_service_1.SassWorkerImplementation();
|
|
102
|
+
extraPlugins.push({
|
|
103
|
+
apply(compiler) {
|
|
104
|
+
compiler.hooks.shutdown.tap('sass-worker', () => {
|
|
105
|
+
sassImplementation.close();
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
});
|
|
111
109
|
const assetNameTemplate = (0, helpers_1.assetNameTemplateFactory)(hashFormat);
|
|
112
110
|
const extraPostcssPlugins = [];
|
|
113
111
|
// Attempt to setup Tailwind CSS
|
|
@@ -155,7 +153,7 @@ function getStylesConfig(wco) {
|
|
|
155
153
|
: undefined,
|
|
156
154
|
plugins: [
|
|
157
155
|
postcssImports({
|
|
158
|
-
resolve: (url) => (url.startsWith('~') ? url.
|
|
156
|
+
resolve: (url) => (url.startsWith('~') ? url.slice(1) : url),
|
|
159
157
|
load: (filename) => {
|
|
160
158
|
return new Promise((resolve, reject) => {
|
|
161
159
|
loader.fs.readFile(filename, (err, data) => {
|
|
@@ -375,12 +373,3 @@ function getStylesConfig(wco) {
|
|
|
375
373
|
};
|
|
376
374
|
}
|
|
377
375
|
exports.getStylesConfig = getStylesConfig;
|
|
378
|
-
function getSassImplementation() {
|
|
379
|
-
const { webcontainer } = process.versions;
|
|
380
|
-
// When `webcontainer` is a truthy it means that we are running in a StackBlitz webcontainer.
|
|
381
|
-
// `SassWorkerImplementation` uses `receiveMessageOnPort` Node.js `worker_thread` API to ensure sync behavior which is ~2x faster.
|
|
382
|
-
// However, it is non trivial to support this in a webcontainer and while slower we choose to use `dart-sass`
|
|
383
|
-
// which in Webpack uses the slower async path.
|
|
384
|
-
// We should periodically check with StackBlitz folks (Mark Whitfeld / Dominic Elm) to determine if this workaround is still needed.
|
|
385
|
-
return webcontainer ? require('sass') : new sass_service_1.SassWorkerImplementation();
|
|
386
|
-
}
|
|
@@ -40,10 +40,9 @@ export declare class NgBuildAnalyticsPlugin {
|
|
|
40
40
|
protected _projectRoot: string;
|
|
41
41
|
protected _analytics: analytics.Analytics;
|
|
42
42
|
protected _category: string;
|
|
43
|
-
private aotEnabled;
|
|
44
43
|
protected _built: boolean;
|
|
45
44
|
protected _stats: AnalyticsBuildStats;
|
|
46
|
-
constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string
|
|
45
|
+
constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string);
|
|
47
46
|
protected _reset(): void;
|
|
48
47
|
protected _getMetrics(stats: Stats): (string | number)[];
|
|
49
48
|
protected _getDimensions(): (string | number | boolean)[];
|
|
@@ -73,11 +73,10 @@ 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) {
|
|
77
77
|
this._projectRoot = _projectRoot;
|
|
78
78
|
this._analytics = _analytics;
|
|
79
79
|
this._category = _category;
|
|
80
|
-
this.aotEnabled = aotEnabled;
|
|
81
80
|
this._built = false;
|
|
82
81
|
this._stats = new AnalyticsBuildStats();
|
|
83
82
|
}
|
|
@@ -108,7 +107,6 @@ class NgBuildAnalyticsPlugin {
|
|
|
108
107
|
// Adding commas before and after so the regex are easier to define filters.
|
|
109
108
|
dimensions[core_1.analytics.NgCliAnalyticsDimensions.BuildErrors] = `,${this._stats.errors.join()},`;
|
|
110
109
|
}
|
|
111
|
-
dimensions[core_1.analytics.NgCliAnalyticsDimensions.AotEnabled] = this.aotEnabled;
|
|
112
110
|
return dimensions;
|
|
113
111
|
}
|
|
114
112
|
_reportBuildMetrics(stats) {
|
|
@@ -52,9 +52,10 @@ class CssOptimizerPlugin {
|
|
|
52
52
|
const cachedOutput = await cacheItem.getPromise();
|
|
53
53
|
if (cachedOutput) {
|
|
54
54
|
await this.addWarnings(compilation, cachedOutput.warnings);
|
|
55
|
-
compilation.updateAsset(name, cachedOutput.source, {
|
|
55
|
+
compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
|
|
56
|
+
...assetInfo,
|
|
56
57
|
minimized: true,
|
|
57
|
-
});
|
|
58
|
+
}));
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -65,7 +66,10 @@ class CssOptimizerPlugin {
|
|
|
65
66
|
const optimizedAsset = map
|
|
66
67
|
? new SourceMapSource(code, name, map)
|
|
67
68
|
: new OriginalSource(code, name);
|
|
68
|
-
compilation.updateAsset(name, optimizedAsset,
|
|
69
|
+
compilation.updateAsset(name, optimizedAsset, (assetInfo) => ({
|
|
70
|
+
...assetInfo,
|
|
71
|
+
minimized: true,
|
|
72
|
+
}));
|
|
69
73
|
await (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.storePromise({
|
|
70
74
|
source: optimizedAsset,
|
|
71
75
|
warnings,
|
|
@@ -28,9 +28,9 @@ export declare class EsbuildExecutor implements Pick<typeof import('esbuild'), '
|
|
|
28
28
|
/**
|
|
29
29
|
* Determines whether the native variant of esbuild can be used on the current platform.
|
|
30
30
|
*
|
|
31
|
-
* @returns
|
|
31
|
+
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
|
32
32
|
*/
|
|
33
|
-
static hasNativeSupport(): boolean
|
|
33
|
+
static hasNativeSupport(): Promise<boolean>;
|
|
34
34
|
/**
|
|
35
35
|
* Initializes the esbuild transform and format messages functions.
|
|
36
36
|
*
|
|
@@ -31,8 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.EsbuildExecutor = void 0;
|
|
34
|
-
const child_process_1 = require("child_process");
|
|
35
|
-
const path = __importStar(require("path"));
|
|
36
34
|
/**
|
|
37
35
|
* Provides the ability to execute esbuild regardless of the current platform's support
|
|
38
36
|
* for using the native variant of esbuild. The native variant will be preferred (assuming
|
|
@@ -57,22 +55,14 @@ class EsbuildExecutor {
|
|
|
57
55
|
/**
|
|
58
56
|
* Determines whether the native variant of esbuild can be used on the current platform.
|
|
59
57
|
*
|
|
60
|
-
* @returns
|
|
58
|
+
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
|
61
59
|
*/
|
|
62
|
-
static hasNativeSupport() {
|
|
60
|
+
static async hasNativeSupport() {
|
|
63
61
|
// Try to use native variant to ensure it is functional for the platform.
|
|
64
|
-
// Spawning a separate esbuild check process is used to determine if the native
|
|
65
|
-
// variant is viable. If check fails, the WASM variant is initialized instead.
|
|
66
|
-
// Attempting to call one of the native esbuild functions is not a viable test
|
|
67
|
-
// currently since esbuild spawn errors are currently not propagated through the
|
|
68
|
-
// call stack for the esbuild function. If this limitation is removed in the future
|
|
69
|
-
// then the separate process spawn check can be removed in favor of a direct function
|
|
70
|
-
// call check.
|
|
71
62
|
try {
|
|
72
|
-
const {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return status === 0 && error === undefined;
|
|
63
|
+
const { formatMessages } = await Promise.resolve().then(() => __importStar(require('esbuild')));
|
|
64
|
+
await formatMessages([], { kind: 'error' });
|
|
65
|
+
return true;
|
|
76
66
|
}
|
|
77
67
|
catch {
|
|
78
68
|
return false;
|
|
@@ -88,7 +78,7 @@ class EsbuildExecutor {
|
|
|
88
78
|
return;
|
|
89
79
|
}
|
|
90
80
|
// If the WASM variant was preferred at class construction or native is not supported, use WASM
|
|
91
|
-
if (this.alwaysUseWasm || !EsbuildExecutor.hasNativeSupport()) {
|
|
81
|
+
if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {
|
|
92
82
|
await this.useWasm();
|
|
93
83
|
this.initialized = true;
|
|
94
84
|
return;
|
|
@@ -61,9 +61,10 @@ class JavaScriptOptimizerPlugin {
|
|
|
61
61
|
cacheItem = cache.getItemCache(name, eTag);
|
|
62
62
|
const cachedOutput = await cacheItem.getPromise();
|
|
63
63
|
if (cachedOutput) {
|
|
64
|
-
compilation.updateAsset(name, cachedOutput.source, {
|
|
64
|
+
compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
|
|
65
|
+
...assetInfo,
|
|
65
66
|
minimized: true,
|
|
66
|
-
});
|
|
67
|
+
}));
|
|
67
68
|
continue;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -110,7 +111,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
110
111
|
// Perform a single native esbuild support check.
|
|
111
112
|
// This removes the need for each worker to perform the check which would
|
|
112
113
|
// otherwise require spawning a separate process per worker.
|
|
113
|
-
alwaysUseWasm: !esbuild_executor_1.EsbuildExecutor.hasNativeSupport(),
|
|
114
|
+
alwaysUseWasm: !(await esbuild_executor_1.EsbuildExecutor.hasNativeSupport()),
|
|
114
115
|
};
|
|
115
116
|
// Sort scripts so larger scripts start first - worker pool uses a FIFO queue
|
|
116
117
|
scriptsToOptimize.sort((a, b) => a.code.length - b.code.length);
|
|
@@ -137,7 +138,10 @@ class JavaScriptOptimizerPlugin {
|
|
|
137
138
|
const optimizedAsset = map
|
|
138
139
|
? new SourceMapSource(code, name, map)
|
|
139
140
|
: new OriginalSource(code, name);
|
|
140
|
-
compilation.updateAsset(name, optimizedAsset,
|
|
141
|
+
compilation.updateAsset(name, optimizedAsset, (assetInfo) => ({
|
|
142
|
+
...assetInfo,
|
|
143
|
+
minimized: true,
|
|
144
|
+
}));
|
|
141
145
|
return cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.storePromise({
|
|
142
146
|
source: optimizedAsset,
|
|
143
147
|
});
|
|
@@ -70,7 +70,7 @@ function default_1(options) {
|
|
|
70
70
|
// If starts with a caret, remove and return remainder
|
|
71
71
|
// this supports bypassing asset processing
|
|
72
72
|
if (inputUrl.startsWith('^')) {
|
|
73
|
-
return inputUrl.
|
|
73
|
+
return inputUrl.slice(1);
|
|
74
74
|
}
|
|
75
75
|
const cacheKey = path.resolve(context, inputUrl);
|
|
76
76
|
const cachedUrl = resourceCache.get(cacheKey);
|
|
@@ -78,7 +78,7 @@ function default_1(options) {
|
|
|
78
78
|
return cachedUrl;
|
|
79
79
|
}
|
|
80
80
|
if (inputUrl.startsWith('~')) {
|
|
81
|
-
inputUrl = inputUrl.
|
|
81
|
+
inputUrl = inputUrl.slice(1);
|
|
82
82
|
}
|
|
83
83
|
const { pathname, hash, search } = url.parse(inputUrl.replace(/\\/g, '/'));
|
|
84
84
|
const resolver = (file, base) => new Promise((resolve, reject) => {
|
|
@@ -31,9 +31,10 @@ class TransferSizePlugin {
|
|
|
31
31
|
}
|
|
32
32
|
actions.push(brotliCompressAsync(scriptAsset.source.source())
|
|
33
33
|
.then((result) => {
|
|
34
|
-
compilation.updateAsset(assetName, (s) => s, {
|
|
34
|
+
compilation.updateAsset(assetName, (s) => s, (assetInfo) => ({
|
|
35
|
+
...assetInfo,
|
|
35
36
|
estimatedTransferSize: result.length,
|
|
36
|
-
});
|
|
37
|
+
}));
|
|
37
38
|
})
|
|
38
39
|
.catch((error) => {
|
|
39
40
|
compilation.warnings.push(new compilation.compiler.webpack.WebpackError(`Unable to calculate estimated transfer size for '${assetName}'. Reason: ${error.message}`));
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.createIvyPlugin = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const webpack_1 = require("@ngtools/webpack");
|
|
13
12
|
const typescript_1 = require("typescript");
|
|
14
13
|
function ensureIvy(wco) {
|
|
@@ -44,7 +43,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
|
|
|
44
43
|
const fileReplacements = {};
|
|
45
44
|
if (buildOptions.fileReplacements) {
|
|
46
45
|
for (const replacement of buildOptions.fileReplacements) {
|
|
47
|
-
fileReplacements[
|
|
46
|
+
fileReplacements[replacement.replace] = replacement.with;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
let inlineStyleFileExtension;
|
package/esbuild-check.js
DELETED
|
@@ -1,16 +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
|
-
|
|
9
|
-
// If the platform does not support the native variant of esbuild, this will crash.
|
|
10
|
-
// This script can then be spawned by the CLI to determine if native usage is supported.
|
|
11
|
-
require('esbuild')
|
|
12
|
-
.formatMessages([], { kind: 'error ' })
|
|
13
|
-
.then(
|
|
14
|
-
() => {},
|
|
15
|
-
() => {},
|
|
16
|
-
);
|