@angular-devkit/build-angular 17.3.0 → 18.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +31 -31
- package/src/builders/app-shell/index.js +1 -1
- package/src/builders/application/build-action.d.ts +5 -4
- package/src/builders/application/build-action.js +17 -23
- package/src/builders/dev-server/builder.d.ts +0 -2
- package/src/builders/dev-server/builder.js +1 -1
- package/src/builders/dev-server/vite-server.js +14 -7
- package/src/builders/dev-server/webpack-server.js +1 -1
- package/src/builders/prerender/index.d.ts +2 -3
- package/src/builders/ssr-dev-server/utils.d.ts +1 -2
- package/src/tools/babel/plugins/adjust-static-class-members.js +3 -6
- package/src/tools/esbuild/angular/angular-host.js +4 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -2
- package/src/tools/esbuild/angular/compiler-plugin.js +5 -2
- package/src/tools/esbuild/bundler-context.js +2 -2
- package/src/tools/esbuild/utils.d.ts +3 -3
- package/src/tools/esbuild/utils.js +2 -2
- package/src/tools/vite/angular-memory-plugin.js +8 -8
- package/src/tools/webpack/configs/dev-server.js +20 -11
- package/src/tools/webpack/configs/styles.js +22 -53
- package/src/tools/webpack/plugins/builder-watch-plugin.js +2 -2
- package/src/tools/webpack/plugins/styles-webpack-plugin.js +1 -1
- package/src/utils/environment-options.d.ts +0 -1
- package/src/utils/environment-options.js +1 -11
- package/src/utils/i18n-options.d.ts +3 -2
- package/src/utils/i18n-options.js +39 -33
- package/src/utils/index-file/inline-fonts.d.ts +0 -2
- package/src/utils/normalize-asset-patterns.d.ts +1 -2
- package/src/utils/normalize-asset-patterns.js +1 -2
- package/src/utils/normalize-cache.d.ts +1 -2
- package/src/utils/normalize-cache.js +10 -5
- package/src/utils/normalize-file-replacements.d.ts +1 -2
- package/src/utils/normalize-file-replacements.js +1 -2
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -2
- package/src/utils/server-rendering/prerender.js +11 -3
- package/src/utils/service-worker.d.ts +2 -2
- package/src/utils/supported-browsers.d.ts +3 -2
- package/src/utils/webpack-browser-config.d.ts +1 -2
- package/src/tools/sass/sass-service-legacy.d.ts +0 -51
- package/src/tools/sass/sass-service-legacy.js +0 -173
- package/src/tools/sass/worker-legacy.d.ts +0 -8
- package/src/tools/sass/worker-legacy.js +0 -43
- package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.d.ts +0 -10
- package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +0 -39
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SassLegacyWorkerImplementation = void 0;
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const worker_threads_1 = require("worker_threads");
|
|
13
|
-
const environment_options_1 = require("../../utils/environment-options");
|
|
14
|
-
/**
|
|
15
|
-
* The maximum number of Workers that will be created to execute render requests.
|
|
16
|
-
*/
|
|
17
|
-
const MAX_RENDER_WORKERS = environment_options_1.maxWorkers;
|
|
18
|
-
/**
|
|
19
|
-
* A Sass renderer implementation that provides an interface that can be used by Webpack's
|
|
20
|
-
* `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
|
|
21
|
-
* with the `dart-sass` package. The `dart-sass` synchronous render function is used within
|
|
22
|
-
* the worker which can be up to two times faster than the asynchronous variant.
|
|
23
|
-
*/
|
|
24
|
-
class SassLegacyWorkerImplementation {
|
|
25
|
-
workers = [];
|
|
26
|
-
availableWorkers = [];
|
|
27
|
-
requests = new Map();
|
|
28
|
-
workerPath = (0, path_1.join)(__dirname, './worker-legacy.js');
|
|
29
|
-
idCounter = 1;
|
|
30
|
-
nextWorkerIndex = 0;
|
|
31
|
-
/**
|
|
32
|
-
* Provides information about the Sass implementation.
|
|
33
|
-
* This mimics enough of the `dart-sass` value to be used with the `sass-loader`.
|
|
34
|
-
*/
|
|
35
|
-
get info() {
|
|
36
|
-
return 'dart-sass\tworker';
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The synchronous render function is not used by the `sass-loader`.
|
|
40
|
-
*/
|
|
41
|
-
renderSync() {
|
|
42
|
-
throw new Error('Sass renderSync is not supported.');
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Asynchronously request a Sass stylesheet to be renderered.
|
|
46
|
-
*
|
|
47
|
-
* @param options The `dart-sass` options to use when rendering the stylesheet.
|
|
48
|
-
* @param callback The function to execute when the rendering is complete.
|
|
49
|
-
*/
|
|
50
|
-
render(options, callback) {
|
|
51
|
-
// The `functions`, `logger` and `importer` options are JavaScript functions that cannot be transferred.
|
|
52
|
-
// If any additional function options are added in the future, they must be excluded as well.
|
|
53
|
-
const { functions, importer, logger, ...serializableOptions } = options;
|
|
54
|
-
// The CLI's configuration does not use or expose the ability to defined custom Sass functions
|
|
55
|
-
if (functions && Object.keys(functions).length > 0) {
|
|
56
|
-
throw new Error('Sass custom functions are not supported.');
|
|
57
|
-
}
|
|
58
|
-
let workerIndex = this.availableWorkers.pop();
|
|
59
|
-
if (workerIndex === undefined) {
|
|
60
|
-
if (this.workers.length < MAX_RENDER_WORKERS) {
|
|
61
|
-
workerIndex = this.workers.length;
|
|
62
|
-
this.workers.push(this.createWorker());
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
workerIndex = this.nextWorkerIndex++;
|
|
66
|
-
if (this.nextWorkerIndex >= this.workers.length) {
|
|
67
|
-
this.nextWorkerIndex = 0;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const request = this.createRequest(workerIndex, callback, importer);
|
|
72
|
-
this.requests.set(request.id, request);
|
|
73
|
-
this.workers[workerIndex].postMessage({
|
|
74
|
-
id: request.id,
|
|
75
|
-
hasImporter: !!importer,
|
|
76
|
-
options: serializableOptions,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Shutdown the Sass render worker.
|
|
81
|
-
* Executing this method will stop any pending render requests.
|
|
82
|
-
*/
|
|
83
|
-
close() {
|
|
84
|
-
for (const worker of this.workers) {
|
|
85
|
-
try {
|
|
86
|
-
void worker.terminate();
|
|
87
|
-
}
|
|
88
|
-
catch { }
|
|
89
|
-
}
|
|
90
|
-
this.requests.clear();
|
|
91
|
-
}
|
|
92
|
-
createWorker() {
|
|
93
|
-
const { port1: mainImporterPort, port2: workerImporterPort } = new worker_threads_1.MessageChannel();
|
|
94
|
-
const importerSignal = new Int32Array(new SharedArrayBuffer(4));
|
|
95
|
-
const worker = new worker_threads_1.Worker(this.workerPath, {
|
|
96
|
-
workerData: { workerImporterPort, importerSignal },
|
|
97
|
-
transferList: [workerImporterPort],
|
|
98
|
-
});
|
|
99
|
-
worker.on('message', (response) => {
|
|
100
|
-
const request = this.requests.get(response.id);
|
|
101
|
-
if (!request) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
this.requests.delete(response.id);
|
|
105
|
-
this.availableWorkers.push(request.workerIndex);
|
|
106
|
-
if (response.result) {
|
|
107
|
-
// The results are expected to be Node.js `Buffer` objects but will each be transferred as
|
|
108
|
-
// a Uint8Array that does not have the expected `toString` behavior of a `Buffer`.
|
|
109
|
-
const { css, map, stats } = response.result;
|
|
110
|
-
const result = {
|
|
111
|
-
// This `Buffer.from` override will use the memory directly and avoid making a copy
|
|
112
|
-
css: Buffer.from(css.buffer, css.byteOffset, css.byteLength),
|
|
113
|
-
stats,
|
|
114
|
-
};
|
|
115
|
-
if (map) {
|
|
116
|
-
// This `Buffer.from` override will use the memory directly and avoid making a copy
|
|
117
|
-
result.map = Buffer.from(map.buffer, map.byteOffset, map.byteLength);
|
|
118
|
-
}
|
|
119
|
-
request.callback(undefined, result);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
request.callback(response.error);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
mainImporterPort.on('message', ({ id, url, prev, fromImport, }) => {
|
|
126
|
-
const request = this.requests.get(id);
|
|
127
|
-
if (!request?.importers) {
|
|
128
|
-
mainImporterPort.postMessage(null);
|
|
129
|
-
Atomics.store(importerSignal, 0, 1);
|
|
130
|
-
Atomics.notify(importerSignal, 0);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
this.processImporters(request.importers, url, prev, fromImport)
|
|
134
|
-
.then((result) => {
|
|
135
|
-
mainImporterPort.postMessage(result);
|
|
136
|
-
})
|
|
137
|
-
.catch((error) => {
|
|
138
|
-
mainImporterPort.postMessage(error);
|
|
139
|
-
})
|
|
140
|
-
.finally(() => {
|
|
141
|
-
Atomics.store(importerSignal, 0, 1);
|
|
142
|
-
Atomics.notify(importerSignal, 0);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
mainImporterPort.unref();
|
|
146
|
-
return worker;
|
|
147
|
-
}
|
|
148
|
-
async processImporters(importers, url, prev, fromImport) {
|
|
149
|
-
let result = null;
|
|
150
|
-
for (const importer of importers) {
|
|
151
|
-
result = await new Promise((resolve) => {
|
|
152
|
-
// Importers can be both sync and async
|
|
153
|
-
const innerResult = importer.call({ fromImport }, url, prev, resolve);
|
|
154
|
-
if (innerResult !== undefined) {
|
|
155
|
-
resolve(innerResult);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
if (result) {
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
createRequest(workerIndex, callback, importer) {
|
|
165
|
-
return {
|
|
166
|
-
id: this.idCounter++,
|
|
167
|
-
workerIndex,
|
|
168
|
-
callback,
|
|
169
|
-
importers: !importer || Array.isArray(importer) ? importer : [importer],
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.SassLegacyWorkerImplementation = SassLegacyWorkerImplementation;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const sass_1 = require("sass");
|
|
11
|
-
const worker_threads_1 = require("worker_threads");
|
|
12
|
-
if (!worker_threads_1.parentPort || !worker_threads_1.workerData) {
|
|
13
|
-
throw new Error('Sass worker must be executed as a Worker.');
|
|
14
|
-
}
|
|
15
|
-
// The importer variables are used to proxy import requests to the main thread
|
|
16
|
-
const { workerImporterPort, importerSignal } = worker_threads_1.workerData;
|
|
17
|
-
worker_threads_1.parentPort.on('message', ({ id, hasImporter, options }) => {
|
|
18
|
-
try {
|
|
19
|
-
if (hasImporter) {
|
|
20
|
-
// When a custom importer function is present, the importer request must be proxied
|
|
21
|
-
// back to the main thread where it can be executed.
|
|
22
|
-
// This process must be synchronous from the perspective of dart-sass. The `Atomics`
|
|
23
|
-
// functions combined with the shared memory `importSignal` and the Node.js
|
|
24
|
-
// `receiveMessageOnPort` function are used to ensure synchronous behavior.
|
|
25
|
-
options.importer = function (url, prev) {
|
|
26
|
-
Atomics.store(importerSignal, 0, 0);
|
|
27
|
-
const { fromImport } = this;
|
|
28
|
-
workerImporterPort.postMessage({ id, url, prev, fromImport });
|
|
29
|
-
Atomics.wait(importerSignal, 0, 0);
|
|
30
|
-
return (0, worker_threads_1.receiveMessageOnPort)(workerImporterPort)?.message;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// The synchronous Sass render function can be up to two times faster than the async variant
|
|
34
|
-
const result = (0, sass_1.renderSync)(options);
|
|
35
|
-
worker_threads_1.parentPort?.postMessage({ id, result });
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
// Needed because V8 will only serialize the message and stack properties of an Error instance.
|
|
40
|
-
const { formatted, file, line, column, message, stack } = error;
|
|
41
|
-
worker_threads_1.parentPort?.postMessage({ id, error: { formatted, file, line, column, message, stack } });
|
|
42
|
-
}
|
|
43
|
-
});
|
|
@@ -1,10 +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
|
-
/** Call the initialize hook when running on Node.js 18 */
|
|
9
|
-
export declare function callInitializeIfNeeded(initialize: (typeof import('./loader-hooks'))['initialize']): void;
|
|
10
|
-
export declare function getESMLoaderArgs(): string[];
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.getESMLoaderArgs = exports.callInitializeIfNeeded = void 0;
|
|
11
|
-
const node_path_1 = require("node:path");
|
|
12
|
-
const node_url_1 = require("node:url");
|
|
13
|
-
const node_worker_threads_1 = require("node:worker_threads");
|
|
14
|
-
const semver_1 = require("semver");
|
|
15
|
-
let SUPPORTS_IMPORT_FLAG;
|
|
16
|
-
function supportsImportFlag() {
|
|
17
|
-
return (SUPPORTS_IMPORT_FLAG ??= (0, semver_1.satisfies)(process.versions.node, '>= 18.19'));
|
|
18
|
-
}
|
|
19
|
-
/** Call the initialize hook when running on Node.js 18 */
|
|
20
|
-
function callInitializeIfNeeded(initialize) {
|
|
21
|
-
if (!supportsImportFlag()) {
|
|
22
|
-
initialize(node_worker_threads_1.workerData);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.callInitializeIfNeeded = callInitializeIfNeeded;
|
|
26
|
-
function getESMLoaderArgs() {
|
|
27
|
-
if (!supportsImportFlag()) {
|
|
28
|
-
return [
|
|
29
|
-
'--no-warnings', // Suppress `ExperimentalWarning: Custom ESM Loaders is an experimental feature...`.
|
|
30
|
-
'--loader',
|
|
31
|
-
(0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, 'loader-hooks.js')).href, // Loader cannot be an absolute path on Windows.
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
return [
|
|
35
|
-
'--import',
|
|
36
|
-
(0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, 'register-hooks.js')).href, // Loader cannot be an absolute path on Windows.
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
exports.getESMLoaderArgs = getESMLoaderArgs;
|