@angular-devkit/build-angular 15.0.0-next.3 → 15.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -18
- package/src/builders/app-shell/index.js +39 -40
- package/src/builders/app-shell/render-worker.d.ts +36 -0
- package/src/builders/app-shell/render-worker.js +82 -0
- package/src/builders/browser/index.d.ts +2 -0
- package/src/builders/browser/index.js +38 -19
- package/src/builders/browser/schema.json +2 -2
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +10 -2
- package/src/builders/browser-esbuild/compiler-plugin.js +211 -115
- package/src/builders/browser-esbuild/esbuild.d.ts +4 -3
- package/src/builders/browser-esbuild/esbuild.js +12 -6
- package/src/builders/browser-esbuild/experimental-warnings.js +0 -3
- package/src/builders/browser-esbuild/index.d.ts +3 -3
- package/src/builders/browser-esbuild/index.js +145 -87
- package/src/builders/browser-esbuild/options.d.ts +26 -4
- package/src/builders/browser-esbuild/options.js +56 -5
- package/src/builders/browser-esbuild/profiling.d.ts +11 -0
- package/src/builders/browser-esbuild/profiling.js +64 -0
- package/src/builders/browser-esbuild/sass-plugin.js +11 -5
- package/src/builders/browser-esbuild/schema.json +2 -2
- package/src/builders/browser-esbuild/watcher.d.ts +23 -0
- package/src/builders/browser-esbuild/watcher.js +93 -0
- package/src/builders/dev-server/index.d.ts +2 -0
- package/src/builders/dev-server/index.js +10 -7
- package/src/builders/karma/find-tests-plugin.js +1 -0
- package/src/builders/karma/index.d.ts +1 -1
- package/src/builders/karma/index.js +50 -9
- package/src/builders/karma/schema.d.ts +1 -1
- package/src/builders/karma/schema.json +1 -1
- package/src/builders/server/schema.json +1 -1
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +3 -1
- package/src/utils/process-bundle.js +1 -1
- package/src/utils/service-worker.d.ts +3 -0
- package/src/utils/service-worker.js +29 -2
- package/src/webpack/configs/common.js +31 -7
- package/src/webpack/configs/index.d.ts +0 -1
- package/src/webpack/configs/index.js +0 -1
- package/src/webpack/configs/styles.d.ts +1 -7
- package/src/webpack/configs/styles.js +70 -60
- package/src/webpack/plugins/occurrences-plugin.d.ts +18 -0
- package/src/webpack/plugins/occurrences-plugin.js +79 -0
- package/src/webpack/plugins/scripts-webpack-plugin.js +24 -5
- package/src/webpack/plugins/styles-webpack-plugin.d.ts +19 -0
- package/src/webpack/plugins/styles-webpack-plugin.js +71 -0
- package/src/webpack/utils/helpers.d.ts +5 -1
- package/src/webpack/utils/helpers.js +24 -14
- package/src/webpack/utils/stats.d.ts +13 -8
- package/src/webpack/utils/stats.js +57 -6
- package/src/webpack/configs/analytics.d.ts +0 -11
- package/src/webpack/configs/analytics.js +0 -27
- package/src/webpack/plugins/analytics.d.ts +0 -66
- package/src/webpack/plugins/analytics.js +0 -236
|
@@ -141,8 +141,8 @@
|
|
|
141
141
|
},
|
|
142
142
|
"optimization": {
|
|
143
143
|
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
|
|
144
|
-
"x-user-analytics": 16,
|
|
145
144
|
"default": true,
|
|
145
|
+
"x-user-analytics": "ep.ng_optimization",
|
|
146
146
|
"oneOf": [
|
|
147
147
|
{
|
|
148
148
|
"type": "object",
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"aot": {
|
|
225
225
|
"type": "boolean",
|
|
226
226
|
"description": "Build using Ahead of Time compilation.",
|
|
227
|
-
"x-user-analytics":
|
|
227
|
+
"x-user-analytics": "ep.ng_aot",
|
|
228
228
|
"default": true
|
|
229
229
|
},
|
|
230
230
|
"sourceMap": {
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export declare class ChangedFiles {
|
|
9
|
+
readonly added: Set<string>;
|
|
10
|
+
readonly modified: Set<string>;
|
|
11
|
+
readonly removed: Set<string>;
|
|
12
|
+
toDebugString(): string;
|
|
13
|
+
}
|
|
14
|
+
export interface BuildWatcher extends AsyncIterableIterator<ChangedFiles> {
|
|
15
|
+
add(paths: string | string[]): void;
|
|
16
|
+
remove(paths: string | string[]): void;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createWatcher(options?: {
|
|
20
|
+
polling?: boolean;
|
|
21
|
+
interval?: number;
|
|
22
|
+
ignored?: string[];
|
|
23
|
+
}): BuildWatcher;
|
|
@@ -0,0 +1,93 @@
|
|
|
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.createWatcher = exports.ChangedFiles = void 0;
|
|
11
|
+
const chokidar_1 = require("chokidar");
|
|
12
|
+
class ChangedFiles {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.added = new Set();
|
|
15
|
+
this.modified = new Set();
|
|
16
|
+
this.removed = new Set();
|
|
17
|
+
}
|
|
18
|
+
toDebugString() {
|
|
19
|
+
const content = {
|
|
20
|
+
added: Array.from(this.added),
|
|
21
|
+
modified: Array.from(this.modified),
|
|
22
|
+
removed: Array.from(this.removed),
|
|
23
|
+
};
|
|
24
|
+
return JSON.stringify(content, null, 2);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ChangedFiles = ChangedFiles;
|
|
28
|
+
function createWatcher(options) {
|
|
29
|
+
const watcher = new chokidar_1.FSWatcher({
|
|
30
|
+
...options,
|
|
31
|
+
disableGlobbing: true,
|
|
32
|
+
ignoreInitial: true,
|
|
33
|
+
});
|
|
34
|
+
const nextQueue = [];
|
|
35
|
+
let currentChanges;
|
|
36
|
+
watcher.on('all', (event, path) => {
|
|
37
|
+
switch (event) {
|
|
38
|
+
case 'add':
|
|
39
|
+
currentChanges !== null && currentChanges !== void 0 ? currentChanges : (currentChanges = new ChangedFiles());
|
|
40
|
+
currentChanges.added.add(path);
|
|
41
|
+
break;
|
|
42
|
+
case 'change':
|
|
43
|
+
currentChanges !== null && currentChanges !== void 0 ? currentChanges : (currentChanges = new ChangedFiles());
|
|
44
|
+
currentChanges.modified.add(path);
|
|
45
|
+
break;
|
|
46
|
+
case 'unlink':
|
|
47
|
+
currentChanges !== null && currentChanges !== void 0 ? currentChanges : (currentChanges = new ChangedFiles());
|
|
48
|
+
currentChanges.removed.add(path);
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const next = nextQueue.shift();
|
|
54
|
+
if (next) {
|
|
55
|
+
const value = currentChanges;
|
|
56
|
+
currentChanges = undefined;
|
|
57
|
+
next(value);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
[Symbol.asyncIterator]() {
|
|
62
|
+
return this;
|
|
63
|
+
},
|
|
64
|
+
async next() {
|
|
65
|
+
if (currentChanges && nextQueue.length === 0) {
|
|
66
|
+
const result = { value: currentChanges };
|
|
67
|
+
currentChanges = undefined;
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
return new Promise((resolve) => {
|
|
71
|
+
nextQueue.push((value) => resolve(value ? { value } : { done: true, value }));
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
add(paths) {
|
|
75
|
+
watcher.add(paths);
|
|
76
|
+
},
|
|
77
|
+
remove(paths) {
|
|
78
|
+
watcher.unwatch(paths);
|
|
79
|
+
},
|
|
80
|
+
async close() {
|
|
81
|
+
try {
|
|
82
|
+
await watcher.close();
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
let next;
|
|
86
|
+
while ((next = nextQueue.shift()) !== undefined) {
|
|
87
|
+
next();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.createWatcher = createWatcher;
|
|
@@ -12,6 +12,7 @@ import { Observable } from 'rxjs';
|
|
|
12
12
|
import webpack from 'webpack';
|
|
13
13
|
import { ExecutionTransformer } from '../../transforms';
|
|
14
14
|
import { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
|
|
15
|
+
import { BuildEventStats } from '../../webpack/utils/stats';
|
|
15
16
|
import { Schema } from './schema';
|
|
16
17
|
export declare type DevServerBuilderOptions = Schema;
|
|
17
18
|
/**
|
|
@@ -19,6 +20,7 @@ export declare type DevServerBuilderOptions = Schema;
|
|
|
19
20
|
*/
|
|
20
21
|
export declare type DevServerBuilderOutput = DevServerBuildOutput & {
|
|
21
22
|
baseUrl: string;
|
|
23
|
+
stats: BuildEventStats;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
26
|
* Reusable implementation of the Angular Webpack development server builder.
|
|
@@ -132,12 +132,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
132
132
|
****************************************************************************************
|
|
133
133
|
`);
|
|
134
134
|
}
|
|
135
|
-
const { config, projectRoot, i18n } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)(browserOptions, context, (wco) => [
|
|
136
|
-
(0, configs_1.getDevServerConfig)(wco),
|
|
137
|
-
(0, configs_1.getCommonConfig)(wco),
|
|
138
|
-
(0, configs_1.getStylesConfig)(wco),
|
|
139
|
-
(0, configs_1.getAnalyticsConfig)(wco, context),
|
|
140
|
-
], options);
|
|
135
|
+
const { config, projectRoot, i18n } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)(browserOptions, context, (wco) => [(0, configs_1.getDevServerConfig)(wco), (0, configs_1.getCommonConfig)(wco), (0, configs_1.getStylesConfig)(wco)], options);
|
|
141
136
|
if (!config.devServer) {
|
|
142
137
|
throw new Error('Webpack Dev Server configuration was not set.');
|
|
143
138
|
}
|
|
@@ -207,6 +202,10 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
207
202
|
webpackDevServerFactory: require('webpack-dev-server'),
|
|
208
203
|
}).pipe((0, operators_1.concatMap)(async (buildEvent, index) => {
|
|
209
204
|
var _a, _b;
|
|
205
|
+
const webpackRawStats = buildEvent.webpackStats;
|
|
206
|
+
if (!webpackRawStats) {
|
|
207
|
+
throw new Error('Webpack stats build result is required.');
|
|
208
|
+
}
|
|
210
209
|
// Resolve serve address.
|
|
211
210
|
const publicPath = (_b = (_a = webpackConfig.devServer) === null || _a === void 0 ? void 0 : _a.devMiddleware) === null || _b === void 0 ? void 0 : _b.publicPath;
|
|
212
211
|
const serverAddress = url.format({
|
|
@@ -235,7 +234,11 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
235
234
|
else {
|
|
236
235
|
logger.info(`\n${color_1.colors.redBright(color_1.colors.symbols.cross)} Failed to compile.`);
|
|
237
236
|
}
|
|
238
|
-
return {
|
|
237
|
+
return {
|
|
238
|
+
...buildEvent,
|
|
239
|
+
baseUrl: serverAddress,
|
|
240
|
+
stats: (0, stats_1.generateBuildEventStats)(webpackRawStats, browserOptions),
|
|
241
|
+
};
|
|
239
242
|
}));
|
|
240
243
|
}));
|
|
241
244
|
}
|
|
@@ -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("@angular-devkit/core").JsonObject>;
|
|
27
27
|
export default _default;
|
|
@@ -32,6 +32,9 @@ 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 core_1 = require("@angular-devkit/core");
|
|
36
|
+
const karma_1 = require("karma");
|
|
37
|
+
const module_1 = require("module");
|
|
35
38
|
const path = __importStar(require("path"));
|
|
36
39
|
const rxjs_1 = require("rxjs");
|
|
37
40
|
const operators_1 = require("rxjs/operators");
|
|
@@ -81,9 +84,15 @@ function execute(options, context, transforms = {}) {
|
|
|
81
84
|
}
|
|
82
85
|
return (0, rxjs_1.from)(initialize(options, context, transforms.webpackConfiguration)).pipe((0, operators_1.switchMap)(async ([karma, webpackConfig]) => {
|
|
83
86
|
var _a, _b, _c, _d, _e;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
// Determine project name from builder context target
|
|
88
|
+
const projectName = (_a = context.target) === null || _a === void 0 ? void 0 : _a.project;
|
|
89
|
+
if (!projectName) {
|
|
90
|
+
throw new Error(`The 'karma' builder requires a target to be specified.`);
|
|
91
|
+
}
|
|
92
|
+
const karmaOptions = options.karmaConfig
|
|
93
|
+
? {}
|
|
94
|
+
: getBuiltInKarmaConfig(context.workspaceRoot, projectName);
|
|
95
|
+
karmaOptions.singleRun = singleRun;
|
|
87
96
|
// Convert browsers from a string to an array
|
|
88
97
|
if (options.browsers) {
|
|
89
98
|
karmaOptions.browsers = options.browsers.split(',');
|
|
@@ -97,10 +106,6 @@ function execute(options, context, transforms = {}) {
|
|
|
97
106
|
karmaOptions.reporters = reporters;
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
|
-
const projectName = (_a = context.target) === null || _a === void 0 ? void 0 : _a.project;
|
|
101
|
-
if (!projectName) {
|
|
102
|
-
throw new Error('The builder requires a target.');
|
|
103
|
-
}
|
|
104
109
|
if (!options.main) {
|
|
105
110
|
(_b = webpackConfig.entry) !== null && _b !== void 0 ? _b : (webpackConfig.entry = {});
|
|
106
111
|
if (typeof webpackConfig.entry === 'object' && !Array.isArray(webpackConfig.entry)) {
|
|
@@ -125,8 +130,8 @@ function execute(options, context, transforms = {}) {
|
|
|
125
130
|
webpackConfig,
|
|
126
131
|
logger: context.logger,
|
|
127
132
|
};
|
|
128
|
-
const
|
|
129
|
-
return [karma,
|
|
133
|
+
const parsedKarmaConfig = await karma_1.config.parseConfig(options.karmaConfig && path.resolve(context.workspaceRoot, options.karmaConfig), transforms.karmaOptions ? transforms.karmaOptions(karmaOptions) : karmaOptions, { promiseConfig: true, throwErrors: true });
|
|
134
|
+
return [karma, parsedKarmaConfig];
|
|
130
135
|
}), (0, operators_1.switchMap)(([karma, karmaConfig]) => new rxjs_1.Observable((subscriber) => {
|
|
131
136
|
var _a, _b, _c;
|
|
132
137
|
var _d, _e;
|
|
@@ -149,6 +154,42 @@ function execute(options, context, transforms = {}) {
|
|
|
149
154
|
})), (0, operators_1.defaultIfEmpty)({ success: false }));
|
|
150
155
|
}
|
|
151
156
|
exports.execute = execute;
|
|
157
|
+
function getBuiltInKarmaConfig(workspaceRoot, projectName) {
|
|
158
|
+
let coverageFolderName = projectName.charAt(0) === '@' ? projectName.slice(1) : projectName;
|
|
159
|
+
if (/[A-Z]/.test(coverageFolderName)) {
|
|
160
|
+
coverageFolderName = core_1.strings.dasherize(coverageFolderName);
|
|
161
|
+
}
|
|
162
|
+
const workspaceRootRequire = (0, module_1.createRequire)(workspaceRoot + '/');
|
|
163
|
+
return {
|
|
164
|
+
basePath: '',
|
|
165
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
166
|
+
plugins: [
|
|
167
|
+
'karma-jasmine',
|
|
168
|
+
'karma-chrome-launcher',
|
|
169
|
+
'karma-jasmine-html-reporter',
|
|
170
|
+
'karma-coverage',
|
|
171
|
+
'@angular-devkit/build-angular/plugins/karma',
|
|
172
|
+
].map((p) => workspaceRootRequire(p)),
|
|
173
|
+
client: {
|
|
174
|
+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
|
|
175
|
+
},
|
|
176
|
+
jasmineHtmlReporter: {
|
|
177
|
+
suppressAll: true, // removes the duplicated traces
|
|
178
|
+
},
|
|
179
|
+
coverageReporter: {
|
|
180
|
+
dir: path.join(workspaceRoot, 'coverage', coverageFolderName),
|
|
181
|
+
subdir: '.',
|
|
182
|
+
reporters: [{ type: 'html' }, { type: 'text-summary' }],
|
|
183
|
+
},
|
|
184
|
+
reporters: ['progress', 'kjhtml'],
|
|
185
|
+
port: 9876,
|
|
186
|
+
colors: true,
|
|
187
|
+
logLevel: karma_1.constants.LOG_INFO,
|
|
188
|
+
autoWatch: true,
|
|
189
|
+
browsers: ['Chrome'],
|
|
190
|
+
restartOnFileChange: true,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
152
193
|
exports.default = (0, architect_1.createBuilder)(execute);
|
|
153
194
|
function getBuiltInMainFile() {
|
|
154
195
|
const content = Buffer.from(`
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"optimization": {
|
|
38
38
|
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking and dead-code elimination. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
|
|
39
|
-
"x-user-analytics": 16,
|
|
40
39
|
"default": true,
|
|
40
|
+
"x-user-analytics": "ep.ng_optimization",
|
|
41
41
|
"oneOf": [
|
|
42
42
|
{
|
|
43
43
|
"type": "object",
|
|
@@ -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.useLegacySass = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
10
|
+
exports.debugPerformance = exports.useLegacySass = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
11
11
|
const color_1 = require("./color");
|
|
12
12
|
function isDisabled(variable) {
|
|
13
13
|
return variable === '0' || variable.toLowerCase() === 'false';
|
|
@@ -77,3 +77,5 @@ exports.useLegacySass = (() => {
|
|
|
77
77
|
console.warn(color_1.colors.yellow(`Warning: 'NG_BUILD_LEGACY_SASS' environment variable support will be removed in version 16.`));
|
|
78
78
|
return isEnabled(legacySassVariable);
|
|
79
79
|
})();
|
|
80
|
+
const debugPerfVariable = process.env['NG_BUILD_DEBUG_PERF'];
|
|
81
|
+
exports.debugPerformance = isPresent(debugPerfVariable) && isEnabled(debugPerfVariable);
|
|
@@ -6,5 +6,8 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
+
import type { Config } from '@angular/service-worker/config';
|
|
9
10
|
import { promises as fsPromises } from 'fs';
|
|
10
11
|
export declare function augmentAppWithServiceWorker(appRoot: string, workspaceRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string, inputputFileSystem?: typeof fsPromises, outputFileSystem?: typeof fsPromises): Promise<void>;
|
|
12
|
+
export declare function augmentAppWithServiceWorkerEsbuild(workspaceRoot: string, configPath: string, outputPath: string, baseHref: string): Promise<void>;
|
|
13
|
+
export declare function augmentAppWithServiceWorkerCore(config: Config, outputPath: string, baseHref: string, inputputFileSystem?: typeof fsPromises, outputFileSystem?: typeof fsPromises): Promise<void>;
|
|
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.augmentAppWithServiceWorker = void 0;
|
|
33
|
+
exports.augmentAppWithServiceWorkerCore = exports.augmentAppWithServiceWorkerEsbuild = exports.augmentAppWithServiceWorker = void 0;
|
|
34
34
|
const crypto = __importStar(require("crypto"));
|
|
35
35
|
const fs_1 = require("fs");
|
|
36
36
|
const path = __importStar(require("path"));
|
|
@@ -100,6 +100,33 @@ async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, b
|
|
|
100
100
|
throw error;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
return augmentAppWithServiceWorkerCore(config, outputPath, baseHref, inputputFileSystem, outputFileSystem);
|
|
104
|
+
}
|
|
105
|
+
exports.augmentAppWithServiceWorker = augmentAppWithServiceWorker;
|
|
106
|
+
// This is currently used by the esbuild-based builder
|
|
107
|
+
async function augmentAppWithServiceWorkerEsbuild(workspaceRoot, configPath, outputPath, baseHref) {
|
|
108
|
+
// Read the configuration file
|
|
109
|
+
let config;
|
|
110
|
+
try {
|
|
111
|
+
const configurationData = await fs_1.promises.readFile(configPath, 'utf-8');
|
|
112
|
+
config = JSON.parse(configurationData);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
(0, error_1.assertIsError)(error);
|
|
116
|
+
if (error.code === 'ENOENT') {
|
|
117
|
+
// TODO: Generate an error object that can be consumed by the esbuild-based builder
|
|
118
|
+
const message = `Service worker configuration file "${path.relative(workspaceRoot, configPath)}" could not be found.`;
|
|
119
|
+
throw new Error(message);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// TODO: Return the output files and any errors/warnings
|
|
126
|
+
return augmentAppWithServiceWorkerCore(config, outputPath, baseHref);
|
|
127
|
+
}
|
|
128
|
+
exports.augmentAppWithServiceWorkerEsbuild = augmentAppWithServiceWorkerEsbuild;
|
|
129
|
+
async function augmentAppWithServiceWorkerCore(config, outputPath, baseHref, inputputFileSystem = fs_1.promises, outputFileSystem = fs_1.promises) {
|
|
103
130
|
// Load ESM `@angular/service-worker/config` using the TypeScript dynamic import workaround.
|
|
104
131
|
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
105
132
|
// changed to a direct dynamic import.
|
|
@@ -135,4 +162,4 @@ async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, b
|
|
|
135
162
|
}
|
|
136
163
|
}
|
|
137
164
|
}
|
|
138
|
-
exports.
|
|
165
|
+
exports.augmentAppWithServiceWorkerCore = augmentAppWithServiceWorkerCore;
|
|
@@ -44,6 +44,7 @@ const load_esm_1 = require("../../utils/load-esm");
|
|
|
44
44
|
const plugins_1 = require("../plugins");
|
|
45
45
|
const devtools_ignore_plugin_1 = require("../plugins/devtools-ignore-plugin");
|
|
46
46
|
const named_chunks_plugin_1 = require("../plugins/named-chunks-plugin");
|
|
47
|
+
const occurrences_plugin_1 = require("../plugins/occurrences-plugin");
|
|
47
48
|
const progress_plugin_1 = require("../plugins/progress-plugin");
|
|
48
49
|
const transfer_size_plugin_1 = require("../plugins/transfer-size-plugin");
|
|
49
50
|
const typescript_1 = require("../plugins/typescript");
|
|
@@ -52,7 +53,7 @@ const helpers_1 = require("../utils/helpers");
|
|
|
52
53
|
const VENDORS_TEST = /[\\/]node_modules[\\/]/;
|
|
53
54
|
// eslint-disable-next-line max-lines-per-function
|
|
54
55
|
async function getCommonConfig(wco) {
|
|
55
|
-
var _a, _b;
|
|
56
|
+
var _a, _b, _c;
|
|
56
57
|
const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot, tsConfigPath } = wco;
|
|
57
58
|
const { cache, codeCoverage, crossOrigin = 'none', platform = 'browser', aot = true, codeCoverageExclude = [], main, polyfills, sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap, hidden: hiddenSourceMap, }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, commonChunk, vendorChunk, subresourceIntegrity, verbose, poll, webWorkerTsConfig, externalDependencies = [], allowedCommonJsDependencies, } = buildOptions;
|
|
58
59
|
const isPlatformServer = buildOptions.platform === 'server';
|
|
@@ -68,13 +69,28 @@ async function getCommonConfig(wco) {
|
|
|
68
69
|
if (buildOptions.progress) {
|
|
69
70
|
extraPlugins.push(new progress_plugin_1.ProgressPlugin(platform));
|
|
70
71
|
}
|
|
72
|
+
const localizePackageInitEntryPoint = '@angular/localize/init';
|
|
73
|
+
const hasLocalizeType = (_a = tsConfig.options.types) === null || _a === void 0 ? void 0 : _a.some((t) => t === '@angular/localize' || t === localizePackageInitEntryPoint);
|
|
74
|
+
if (hasLocalizeType) {
|
|
75
|
+
entryPoints['main'] = [localizePackageInitEntryPoint];
|
|
76
|
+
}
|
|
71
77
|
if (buildOptions.main) {
|
|
72
78
|
const mainPath = path.resolve(root, buildOptions.main);
|
|
73
|
-
entryPoints['main']
|
|
79
|
+
if (Array.isArray(entryPoints['main'])) {
|
|
80
|
+
entryPoints['main'].push(mainPath);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
entryPoints['main'] = [mainPath];
|
|
84
|
+
}
|
|
74
85
|
}
|
|
75
86
|
if (isPlatformServer) {
|
|
76
87
|
// Fixes Critical dependency: the request of a dependency is an expression
|
|
77
88
|
extraPlugins.push(new webpack_2.ContextReplacementPlugin(/@?hapi|express[\\/]/));
|
|
89
|
+
if (Array.isArray(entryPoints['main'])) {
|
|
90
|
+
// This import must come before any imports (direct or transitive) that rely on DOM built-ins being
|
|
91
|
+
// available, such as `@angular/elements`.
|
|
92
|
+
entryPoints['main'].unshift('@angular/platform-server/init');
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
95
|
if (polyfills === null || polyfills === void 0 ? void 0 : polyfills.length) {
|
|
80
96
|
// `zone.js/testing` is a **special** polyfill because when not imported in the main it fails with the below errors:
|
|
@@ -114,7 +130,7 @@ async function getCommonConfig(wco) {
|
|
|
114
130
|
}
|
|
115
131
|
// process global scripts
|
|
116
132
|
// Add a new asset for each entry.
|
|
117
|
-
for (const { bundleName, inject, paths } of (0, helpers_1.globalScriptsByBundleName)(
|
|
133
|
+
for (const { bundleName, inject, paths } of (0, helpers_1.globalScriptsByBundleName)(buildOptions.scripts)) {
|
|
118
134
|
// Lazy scripts don't get a hash, otherwise they can't be loaded by name.
|
|
119
135
|
const hash = inject ? hashFormat.script : '';
|
|
120
136
|
extraPlugins.push(new plugins_1.ScriptsWebpackPlugin({
|
|
@@ -122,7 +138,7 @@ async function getCommonConfig(wco) {
|
|
|
122
138
|
sourceMap: scriptsSourceMap,
|
|
123
139
|
scripts: paths,
|
|
124
140
|
filename: `${path.basename(bundleName)}${hash}.js`,
|
|
125
|
-
basePath:
|
|
141
|
+
basePath: root,
|
|
126
142
|
}));
|
|
127
143
|
}
|
|
128
144
|
// process asset entries
|
|
@@ -253,9 +269,9 @@ async function getCommonConfig(wco) {
|
|
|
253
269
|
output: {
|
|
254
270
|
uniqueName: projectName,
|
|
255
271
|
hashFunction: 'xxhash64',
|
|
256
|
-
clean: (
|
|
272
|
+
clean: (_b = buildOptions.deleteOutputPath) !== null && _b !== void 0 ? _b : true,
|
|
257
273
|
path: path.resolve(root, buildOptions.outputPath),
|
|
258
|
-
publicPath: (
|
|
274
|
+
publicPath: (_c = buildOptions.deployUrl) !== null && _c !== void 0 ? _c : '',
|
|
259
275
|
filename: `[name]${hashFormat.chunk}.js`,
|
|
260
276
|
chunkFilename: `[name]${hashFormat.chunk}.js`,
|
|
261
277
|
libraryTarget: isPlatformServer ? 'commonjs' : undefined,
|
|
@@ -385,7 +401,15 @@ async function getCommonConfig(wco) {
|
|
|
385
401
|
},
|
|
386
402
|
},
|
|
387
403
|
},
|
|
388
|
-
plugins: [
|
|
404
|
+
plugins: [
|
|
405
|
+
new named_chunks_plugin_1.NamedChunksPlugin(),
|
|
406
|
+
new occurrences_plugin_1.OccurrencesPlugin({
|
|
407
|
+
aot,
|
|
408
|
+
scriptsOptimization,
|
|
409
|
+
}),
|
|
410
|
+
new plugins_1.DedupeModuleResolvePlugin({ verbose }),
|
|
411
|
+
...extraPlugins,
|
|
412
|
+
],
|
|
389
413
|
node: false,
|
|
390
414
|
};
|
|
391
415
|
}
|
|
@@ -21,7 +21,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
__exportStar(require("./analytics"), exports);
|
|
25
24
|
__exportStar(require("./common"), exports);
|
|
26
25
|
__exportStar(require("./dev-server"), exports);
|
|
27
26
|
__exportStar(require("./styles"), exports);
|
|
@@ -5,12 +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 { Configuration } from 'webpack';
|
|
9
|
-
import { StyleElement } from '../../builders/browser/schema';
|
|
8
|
+
import type { Configuration } from 'webpack';
|
|
10
9
|
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
11
|
-
export declare function resolveGlobalStyles(styleEntrypoints: StyleElement[], root: string, preserveSymlinks: boolean, skipResolution?: boolean): {
|
|
12
|
-
entryPoints: Record<string, string[]>;
|
|
13
|
-
noInjectNames: string[];
|
|
14
|
-
paths: string[];
|
|
15
|
-
};
|
|
16
10
|
export declare function getStylesConfig(wco: WebpackConfigOptions): Configuration;
|