@angular-devkit/build-angular 17.2.3 → 17.3.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 +27 -27
- package/src/builders/app-shell/index.js +1 -0
- package/src/builders/app-shell/render-worker.js +1 -1
- package/src/builders/application/build-action.d.ts +3 -1
- package/src/builders/application/build-action.js +5 -1
- package/src/builders/application/execute-build.js +1 -1
- package/src/builders/application/index.js +9 -6
- package/src/builders/application/options.d.ts +2 -6
- package/src/builders/application/options.js +48 -25
- package/src/builders/application/schema.d.ts +6 -0
- package/src/builders/application/schema.json +4 -0
- package/src/builders/browser/index.js +1 -1
- package/src/builders/browser/schema.d.ts +3 -3
- package/src/builders/browser/schema.json +1 -2
- package/src/builders/browser-esbuild/schema.d.ts +3 -3
- package/src/builders/browser-esbuild/schema.json +1 -2
- package/src/builders/dev-server/builder.js +13 -4
- package/src/builders/dev-server/schema.d.ts +6 -3
- package/src/builders/dev-server/schema.json +3 -3
- package/src/builders/dev-server/vite-server.js +7 -4
- package/src/builders/prerender/index.js +2 -0
- package/src/builders/server/schema.d.ts +3 -4
- package/src/builders/server/schema.json +1 -2
- package/src/builders/web-test-runner/index.js +1 -1
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +1 -0
- package/src/tools/esbuild/application-code-bundle.js +1 -2
- package/src/tools/esbuild/bundler-execution-result.d.ts +2 -0
- package/src/tools/esbuild/bundler-execution-result.js +4 -0
- package/src/tools/esbuild/global-styles.js +1 -2
- package/src/tools/esbuild/i18n-inliner.js +1 -0
- package/src/tools/esbuild/javascript-transformer.js +1 -0
- package/src/tools/esbuild/utils.d.ts +2 -1
- package/src/tools/esbuild/utils.js +26 -24
- package/src/tools/sass/sass-service.d.ts +3 -3
- package/src/tools/sass/sass-service.js +3 -3
- package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +1 -0
- package/src/tools/webpack/plugins/javascript-optimizer-worker.d.ts +1 -1
- package/src/tools/webpack/utils/stats.js +3 -2
- package/src/utils/action-executor.js +1 -0
- package/src/utils/color.d.ts +0 -1
- package/src/utils/color.js +4 -10
- package/src/utils/index-file/html-rewriting-stream.js +9 -26
- package/src/utils/index-file/index-html-generator.js +4 -5
- package/src/utils/purge-cache.js +17 -12
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
- package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
- package/src/utils/server-rendering/prerender.js +2 -0
- package/src/utils/server-rendering/render-page.js +2 -2
- package/src/utils/server-rendering/render-worker.js +0 -2
- package/src/utils/server-rendering/routes-extractor-worker.js +3 -3
- package/src/utils/version.js +15 -21
- package/src/utils/strip-bom.d.ts +0 -8
- package/src/utils/strip-bom.js +0 -17
|
@@ -12,10 +12,9 @@ export interface Schema {
|
|
|
12
12
|
*/
|
|
13
13
|
deleteOutputPath?: boolean;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* https://angular.io/guide/deployment#the-deploy-url.
|
|
15
|
+
* Customize the base path for the URLs of resources in 'index.html' and component
|
|
16
|
+
* stylesheets. This option is only necessary for specific deployment scenarios, such as
|
|
17
|
+
* with Angular Elements or when utilizing different CDN locations.
|
|
19
18
|
*/
|
|
20
19
|
deployUrl?: string;
|
|
21
20
|
/**
|
|
@@ -121,8 +121,7 @@
|
|
|
121
121
|
},
|
|
122
122
|
"deployUrl": {
|
|
123
123
|
"type": "string",
|
|
124
|
-
"description": "
|
|
125
|
-
"x-deprecated": "Use \"baseHref\" browser builder option, \"APP_BASE_HREF\" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
|
|
124
|
+
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
|
|
126
125
|
},
|
|
127
126
|
"vendorChunk": {
|
|
128
127
|
"type": "boolean",
|
|
@@ -39,6 +39,7 @@ class ParallelCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
39
39
|
// is used when the Atomics based wait loop is enable.
|
|
40
40
|
useAtomics: !process.versions.webcontainer,
|
|
41
41
|
filename: localRequire.resolve('./parallel-worker'),
|
|
42
|
+
recordTiming: false,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
|
|
@@ -111,7 +111,7 @@ exports.createBrowserPolyfillBundleOptions = createBrowserPolyfillBundleOptions;
|
|
|
111
111
|
* @returns An esbuild BuildOptions object.
|
|
112
112
|
*/
|
|
113
113
|
function createServerCodeBundleOptions(options, target, sourceFileCache) {
|
|
114
|
-
const {
|
|
114
|
+
const { serverEntryPoint, workspaceRoot, ssrOptions, watch, externalPackages, prerenderOptions } = options;
|
|
115
115
|
(0, node_assert_1.default)(serverEntryPoint, 'createServerCodeBundleOptions should not be called without a defined serverEntryPoint.');
|
|
116
116
|
const { pluginOptions, styleOptions } = (0, compiler_plugin_options_1.createCompilerPluginOptions)(options, target, sourceFileCache);
|
|
117
117
|
const mainServerNamespace = 'angular:server-render-utils';
|
|
@@ -276,7 +276,6 @@ function getEsBuildCommonOptions(options) {
|
|
|
276
276
|
},
|
|
277
277
|
loader: loaderExtensions,
|
|
278
278
|
footer,
|
|
279
|
-
publicPath: options.publicPath,
|
|
280
279
|
};
|
|
281
280
|
}
|
|
282
281
|
function getEsBuildCommonPolyfillsOptions(options, namespace, tryToResolvePolyfillsAsRelative, sourceFileCache) {
|
|
@@ -35,10 +35,12 @@ export declare class ExecutionResult {
|
|
|
35
35
|
errors: (Message | PartialMessage)[];
|
|
36
36
|
prerenderedRoutes: string[];
|
|
37
37
|
warnings: (Message | PartialMessage)[];
|
|
38
|
+
logs: string[];
|
|
38
39
|
externalMetadata?: ExternalResultMetadata;
|
|
39
40
|
constructor(rebuildContexts: BundlerContext[], codeBundleCache?: SourceFileCache | undefined);
|
|
40
41
|
addOutputFile(path: string, content: string, type: BuildOutputFileType): void;
|
|
41
42
|
addAssets(assets: BuildOutputAsset[]): void;
|
|
43
|
+
addLog(value: string): void;
|
|
42
44
|
addError(error: PartialMessage | string): void;
|
|
43
45
|
addErrors(errors: (PartialMessage | string)[]): void;
|
|
44
46
|
addPrerenderedRoutes(routes: string[]): void;
|
|
@@ -21,6 +21,7 @@ class ExecutionResult {
|
|
|
21
21
|
errors = [];
|
|
22
22
|
prerenderedRoutes = [];
|
|
23
23
|
warnings = [];
|
|
24
|
+
logs = [];
|
|
24
25
|
externalMetadata;
|
|
25
26
|
constructor(rebuildContexts, codeBundleCache) {
|
|
26
27
|
this.rebuildContexts = rebuildContexts;
|
|
@@ -32,6 +33,9 @@ class ExecutionResult {
|
|
|
32
33
|
addAssets(assets) {
|
|
33
34
|
this.assetFiles.push(...assets);
|
|
34
35
|
}
|
|
36
|
+
addLog(value) {
|
|
37
|
+
this.logs.push(value);
|
|
38
|
+
}
|
|
35
39
|
addError(error) {
|
|
36
40
|
if (typeof error === 'string') {
|
|
37
41
|
this.errors.push({ text: error, location: null });
|
|
@@ -15,7 +15,7 @@ const node_assert_1 = __importDefault(require("node:assert"));
|
|
|
15
15
|
const bundle_options_1 = require("./stylesheets/bundle-options");
|
|
16
16
|
const virtual_module_plugin_1 = require("./virtual-module-plugin");
|
|
17
17
|
function createGlobalStylesBundleOptions(options, target, initial) {
|
|
18
|
-
const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, globalStyles, preserveSymlinks, externalDependencies, stylePreprocessorOptions, tailwindConfiguration, postcssConfiguration, cacheOptions,
|
|
18
|
+
const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, globalStyles, preserveSymlinks, externalDependencies, stylePreprocessorOptions, tailwindConfiguration, postcssConfiguration, cacheOptions, } = options;
|
|
19
19
|
const namespace = 'angular:styles/global';
|
|
20
20
|
const entryPoints = {};
|
|
21
21
|
let found = false;
|
|
@@ -48,7 +48,6 @@ function createGlobalStylesBundleOptions(options, target, initial) {
|
|
|
48
48
|
tailwindConfiguration,
|
|
49
49
|
postcssConfiguration,
|
|
50
50
|
cacheOptions,
|
|
51
|
-
publicPath,
|
|
52
51
|
}, loadCache);
|
|
53
52
|
// Keep special CSS comments `/*! comment */` in place when `removeSpecialComments` is disabled.
|
|
54
53
|
// These comments are special for a number of CSS tools such as Critters and PurgeCSS.
|
|
@@ -37,4 +37,5 @@ export declare function transformSupportedBrowsersToTargets(supportedBrowsers: s
|
|
|
37
37
|
* @see https://esbuild.github.io/api/#target
|
|
38
38
|
*/
|
|
39
39
|
export declare function getSupportedNodeTargets(): string[];
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function createJsonBuildManifest(result: ExecutionResult, normalizedOptions: NormalizedApplicationBuildOptions): Promise<string>;
|
|
41
|
+
export declare function logMessages(logger: logging.LoggerApi, executionResult: ExecutionResult, color?: boolean, jsonLogs?: boolean): Promise<void>;
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.logMessages = exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.convertOutputFile = exports.createOutputFileFromData = exports.createOutputFileFromText = exports.emitFilesToDisk = exports.writeResultFiles = exports.getFeatureSupport = exports.withNoProgress = exports.withSpinner = exports.calculateEstimatedTransferSizes = exports.logBuildStats = void 0;
|
|
13
|
+
exports.logMessages = exports.createJsonBuildManifest = exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.convertOutputFile = exports.createOutputFileFromData = exports.createOutputFileFromText = exports.emitFilesToDisk = exports.writeResultFiles = exports.getFeatureSupport = exports.withNoProgress = exports.withSpinner = exports.calculateEstimatedTransferSizes = exports.logBuildStats = void 0;
|
|
14
14
|
const esbuild_1 = require("esbuild");
|
|
15
15
|
const node_crypto_1 = require("node:crypto");
|
|
16
16
|
const node_fs_1 = require("node:fs");
|
|
@@ -344,33 +344,35 @@ function getSupportedNodeTargets() {
|
|
|
344
344
|
return SUPPORTED_NODE_VERSIONS.split('||').map((v) => 'node' + (0, semver_1.coerce)(v)?.version);
|
|
345
345
|
}
|
|
346
346
|
exports.getSupportedNodeTargets = getSupportedNodeTargets;
|
|
347
|
-
async function
|
|
348
|
-
const { outputOptions: { base, server, browser }, ssrOptions,
|
|
349
|
-
const { warnings, errors, prerenderedRoutes } =
|
|
350
|
-
const
|
|
351
|
-
? await (0, esbuild_1.formatMessages)(
|
|
352
|
-
: []
|
|
353
|
-
|
|
347
|
+
async function createJsonBuildManifest(result, normalizedOptions) {
|
|
348
|
+
const { colors: color, outputOptions: { base, server, browser }, ssrOptions, } = normalizedOptions;
|
|
349
|
+
const { warnings, errors, prerenderedRoutes } = result;
|
|
350
|
+
const manifest = {
|
|
351
|
+
errors: errors.length ? await (0, esbuild_1.formatMessages)(errors, { kind: 'error', color }) : [],
|
|
352
|
+
warnings: warnings.length ? await (0, esbuild_1.formatMessages)(warnings, { kind: 'warning', color }) : [],
|
|
353
|
+
outputPaths: {
|
|
354
|
+
root: (0, node_url_1.pathToFileURL)(base),
|
|
355
|
+
browser: (0, node_url_1.pathToFileURL)((0, node_path_1.join)(base, browser)),
|
|
356
|
+
server: ssrOptions ? (0, node_url_1.pathToFileURL)((0, node_path_1.join)(base, server)) : undefined,
|
|
357
|
+
},
|
|
358
|
+
prerenderedRoutes,
|
|
359
|
+
};
|
|
360
|
+
return JSON.stringify(manifest, undefined, 2);
|
|
361
|
+
}
|
|
362
|
+
exports.createJsonBuildManifest = createJsonBuildManifest;
|
|
363
|
+
async function logMessages(logger, executionResult, color, jsonLogs) {
|
|
364
|
+
const { warnings, errors, logs } = executionResult;
|
|
365
|
+
if (logs.length) {
|
|
366
|
+
logger.info(logs.join('\n'));
|
|
367
|
+
}
|
|
354
368
|
if (jsonLogs) {
|
|
355
|
-
// JSON format output
|
|
356
|
-
const manifest = {
|
|
357
|
-
errors: errorMessages,
|
|
358
|
-
warnings: warningMessages,
|
|
359
|
-
outputPaths: {
|
|
360
|
-
root: (0, node_url_1.pathToFileURL)(base),
|
|
361
|
-
browser: (0, node_url_1.pathToFileURL)((0, node_path_1.join)(base, browser)),
|
|
362
|
-
server: ssrOptions ? (0, node_url_1.pathToFileURL)((0, node_path_1.join)(base, server)) : undefined,
|
|
363
|
-
},
|
|
364
|
-
prerenderedRoutes,
|
|
365
|
-
};
|
|
366
|
-
logger.info(JSON.stringify(manifest, undefined, 2));
|
|
367
369
|
return;
|
|
368
370
|
}
|
|
369
|
-
if (
|
|
370
|
-
logger.warn(
|
|
371
|
+
if (warnings.length) {
|
|
372
|
+
logger.warn((await (0, esbuild_1.formatMessages)(warnings, { kind: 'warning', color })).join('\n'));
|
|
371
373
|
}
|
|
372
|
-
if (
|
|
373
|
-
logger.error(
|
|
374
|
+
if (errors.length) {
|
|
375
|
+
logger.error((await (0, esbuild_1.formatMessages)(errors, { kind: 'error', color })).join('\n'));
|
|
374
376
|
}
|
|
375
377
|
}
|
|
376
378
|
exports.logMessages = logMessages;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { CompileResult,
|
|
8
|
+
import { CompileResult, StringOptions } from 'sass';
|
|
9
9
|
/**
|
|
10
10
|
* A Sass renderer implementation that provides an interface that can be used by Webpack's
|
|
11
11
|
* `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
|
|
@@ -36,7 +36,7 @@ export declare class SassWorkerImplementation {
|
|
|
36
36
|
* @param source The contents to compile.
|
|
37
37
|
* @param options The `dart-sass` options to use when rendering the stylesheet.
|
|
38
38
|
*/
|
|
39
|
-
compileStringAsync(source: string, options:
|
|
39
|
+
compileStringAsync(source: string, options: StringOptions<'async'>): Promise<CompileResult>;
|
|
40
40
|
/**
|
|
41
41
|
* Shutdown the Sass render worker.
|
|
42
42
|
* Executing this method will stop any pending render requests.
|
|
@@ -45,5 +45,5 @@ export declare class SassWorkerImplementation {
|
|
|
45
45
|
private createWorker;
|
|
46
46
|
private processImporters;
|
|
47
47
|
private createRequest;
|
|
48
|
-
private
|
|
48
|
+
private isFileImporter;
|
|
49
49
|
}
|
|
@@ -185,7 +185,7 @@ class SassWorkerImplementation {
|
|
|
185
185
|
}
|
|
186
186
|
async processImporters(importers, url, options) {
|
|
187
187
|
for (const importer of importers) {
|
|
188
|
-
if (this.
|
|
188
|
+
if (!this.isFileImporter(importer)) {
|
|
189
189
|
// Importer
|
|
190
190
|
throw new Error('Only File Importers are supported.');
|
|
191
191
|
}
|
|
@@ -206,8 +206,8 @@ class SassWorkerImplementation {
|
|
|
206
206
|
importers,
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
return '
|
|
209
|
+
isFileImporter(value) {
|
|
210
|
+
return 'findFileUrl' in value;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
exports.SassWorkerImplementation = SassWorkerImplementation;
|
|
@@ -116,6 +116,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
116
116
|
const workerPool = new piscina_1.default({
|
|
117
117
|
filename: workerPath,
|
|
118
118
|
maxThreads: MAX_OPTIMIZE_WORKERS,
|
|
119
|
+
recordTiming: false,
|
|
119
120
|
});
|
|
120
121
|
// Enqueue script optimization tasks and update compilation assets as the tasks complete
|
|
121
122
|
try {
|
|
@@ -84,7 +84,7 @@ export default function ({ asset, options }: OptimizeRequest): Promise<{
|
|
|
84
84
|
} | {
|
|
85
85
|
name: string;
|
|
86
86
|
code: string;
|
|
87
|
-
map: import("@ampproject/remapping
|
|
87
|
+
map: import("@ampproject/remapping").SourceMap | undefined;
|
|
88
88
|
errors?: undefined;
|
|
89
89
|
}>;
|
|
90
90
|
export {};
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.webpackStatsLogger = exports.generateBuildEventStats = exports.createWebpackLoggingCallback = exports.statsHasWarnings = exports.statsHasErrors = exports.statsErrorsToString = exports.statsWarningsToString = exports.generateBuildStatsTable = exports.generateEsbuildBuildStatsTable = exports.formatSize = void 0;
|
|
37
37
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
|
+
const node_util_1 = require("node:util");
|
|
39
40
|
const utils_1 = require("../../../utils");
|
|
40
41
|
const color_1 = require("../../../utils/color");
|
|
41
42
|
const async_chunks_1 = require("./async-chunks");
|
|
@@ -237,7 +238,7 @@ function generateTableText(bundleInfo, colors) {
|
|
|
237
238
|
continue;
|
|
238
239
|
}
|
|
239
240
|
const currentLongest = (longest[i] ??= 0);
|
|
240
|
-
const currentItemLength = (0,
|
|
241
|
+
const currentItemLength = (0, node_util_1.stripVTControlCharacters)(currentItem).length;
|
|
241
242
|
if (currentLongest < currentItemLength) {
|
|
242
243
|
longest[i] = currentItemLength;
|
|
243
244
|
}
|
|
@@ -254,7 +255,7 @@ function generateTableText(bundleInfo, colors) {
|
|
|
254
255
|
if (skipText(currentItem)) {
|
|
255
256
|
continue;
|
|
256
257
|
}
|
|
257
|
-
const currentItemLength = (0,
|
|
258
|
+
const currentItemLength = (0, node_util_1.stripVTControlCharacters)(currentItem).length;
|
|
258
259
|
const stringPad = ' '.repeat(longest[i] - currentItemLength);
|
|
259
260
|
// Values in columns at index 2 and 3 (Raw and Estimated sizes) are always right aligned.
|
|
260
261
|
item[i] = i >= 2 ? stringPad + currentItem : currentItem + stringPad;
|
package/src/utils/color.d.ts
CHANGED
package/src/utils/color.js
CHANGED
|
@@ -30,9 +30,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.colors =
|
|
33
|
+
exports.colors = void 0;
|
|
34
34
|
const ansiColors = __importStar(require("ansi-colors"));
|
|
35
|
-
const
|
|
35
|
+
const node_tty_1 = require("node:tty");
|
|
36
36
|
function supportColor() {
|
|
37
37
|
if (process.env.FORCE_COLOR !== undefined) {
|
|
38
38
|
// 2 colors: FORCE_COLOR = 0 (Disables colors), depth 1
|
|
@@ -52,17 +52,11 @@ function supportColor() {
|
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
if (process.stdout instanceof
|
|
56
|
-
return process.stdout.
|
|
55
|
+
if (process.stdout instanceof node_tty_1.WriteStream) {
|
|
56
|
+
return process.stdout.hasColors();
|
|
57
57
|
}
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
|
-
function removeColor(text) {
|
|
61
|
-
// This has been created because when colors.enabled is false unstyle doesn't work
|
|
62
|
-
// see: https://github.com/doowb/ansi-colors/blob/a4794363369d7b4d1872d248fc43a12761640d8e/index.js#L38
|
|
63
|
-
return text.replace(ansiColors.ansiRegex, '');
|
|
64
|
-
}
|
|
65
|
-
exports.removeColor = removeColor;
|
|
66
60
|
// Create a separate instance to prevent unintended global changes to the color configuration
|
|
67
61
|
const colors = ansiColors.create();
|
|
68
62
|
exports.colors = colors;
|
|
@@ -8,38 +8,21 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.htmlRewritingStream = void 0;
|
|
11
|
-
const
|
|
11
|
+
const node_stream_1 = require("node:stream");
|
|
12
|
+
const promises_1 = require("node:stream/promises");
|
|
12
13
|
const load_esm_1 = require("../load-esm");
|
|
13
14
|
async function htmlRewritingStream(content) {
|
|
14
15
|
const { RewritingStream } = await (0, load_esm_1.loadEsmModule)('parse5-html-rewriting-stream');
|
|
15
|
-
const chunks = [];
|
|
16
16
|
const rewriter = new RewritingStream();
|
|
17
17
|
return {
|
|
18
18
|
rewriter,
|
|
19
|
-
transformedContent: () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
.pipe(rewriter)
|
|
29
|
-
.pipe(new stream_1.Writable({
|
|
30
|
-
write(chunk, encoding, callback) {
|
|
31
|
-
chunks.push(typeof chunk === 'string'
|
|
32
|
-
? Buffer.from(chunk, encoding)
|
|
33
|
-
: chunk);
|
|
34
|
-
callback();
|
|
35
|
-
},
|
|
36
|
-
final(callback) {
|
|
37
|
-
callback();
|
|
38
|
-
resolve(Buffer.concat(chunks).toString());
|
|
39
|
-
},
|
|
40
|
-
}));
|
|
41
|
-
});
|
|
42
|
-
},
|
|
19
|
+
transformedContent: () => (0, promises_1.pipeline)(node_stream_1.Readable.from(content), rewriter, async function (source) {
|
|
20
|
+
const chunks = [];
|
|
21
|
+
for await (const chunk of source) {
|
|
22
|
+
chunks.push(Buffer.from(chunk));
|
|
23
|
+
}
|
|
24
|
+
return Buffer.concat(chunks).toString('utf-8');
|
|
25
|
+
}),
|
|
43
26
|
};
|
|
44
27
|
}
|
|
45
28
|
exports.htmlRewritingStream = htmlRewritingStream;
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.IndexHtmlGenerator = void 0;
|
|
11
11
|
const promises_1 = require("node:fs/promises");
|
|
12
12
|
const node_path_1 = require("node:path");
|
|
13
|
-
const strip_bom_1 = require("../strip-bom");
|
|
14
13
|
const augment_index_html_1 = require("./augment-index-html");
|
|
15
14
|
const inline_critical_css_1 = require("./inline-critical-css");
|
|
16
15
|
const inline_fonts_1 = require("./inline-fonts");
|
|
@@ -37,7 +36,7 @@ class IndexHtmlGenerator {
|
|
|
37
36
|
];
|
|
38
37
|
}
|
|
39
38
|
async process(options) {
|
|
40
|
-
let content =
|
|
39
|
+
let content = await this.readIndex(this.options.indexPath);
|
|
41
40
|
const warnings = [];
|
|
42
41
|
const errors = [];
|
|
43
42
|
for (const plugin of this.plugins) {
|
|
@@ -71,10 +70,10 @@ class IndexHtmlGenerator {
|
|
|
71
70
|
}
|
|
72
71
|
async readIndex(path) {
|
|
73
72
|
try {
|
|
74
|
-
return await (0, promises_1.readFile)(path
|
|
73
|
+
return new TextDecoder('utf-8').decode(await (0, promises_1.readFile)(path));
|
|
75
74
|
}
|
|
76
|
-
catch {
|
|
77
|
-
throw new Error(`Failed to read index HTML file "${path}"
|
|
75
|
+
catch (cause) {
|
|
76
|
+
throw new Error(`Failed to read index HTML file "${path}".`, { cause });
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
package/src/utils/purge-cache.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.purgeStaleBuildCache = void 0;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const promises_1 = require("node:fs/promises");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
13
|
const normalize_cache_1 = require("./normalize-cache");
|
|
14
14
|
/** Delete stale cache directories used by previous versions of build-angular. */
|
|
15
15
|
async function purgeStaleBuildCache(context) {
|
|
@@ -19,17 +19,22 @@ async function purgeStaleBuildCache(context) {
|
|
|
19
19
|
}
|
|
20
20
|
const metadata = await context.getProjectMetadata(projectName);
|
|
21
21
|
const { basePath, path, enabled } = (0, normalize_cache_1.normalizeCacheOptions)(metadata, context.workspaceRoot);
|
|
22
|
-
if (!enabled
|
|
22
|
+
if (!enabled) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
25
|
+
let baseEntries;
|
|
26
|
+
try {
|
|
27
|
+
baseEntries = await (0, promises_1.readdir)(basePath, { withFileTypes: true });
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// No purging possible if base path does not exist or cannot otherwise be accessed
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const entriesToDelete = baseEntries
|
|
34
|
+
.filter((d) => d.isDirectory())
|
|
35
|
+
.map((d) => (0, node_path_1.join)(basePath, d.name))
|
|
36
|
+
.filter((cachePath) => cachePath !== path)
|
|
37
|
+
.map((stalePath) => (0, promises_1.rm)(stalePath, { force: true, recursive: true, maxRetries: 3 }));
|
|
38
|
+
await Promise.allSettled(entriesToDelete);
|
|
34
39
|
}
|
|
35
40
|
exports.purgeStaleBuildCache = purgeStaleBuildCache;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { MainServerBundleExports, RenderUtilsServerBundleExports } from './main-bundle-exports';
|
|
9
|
+
export declare function loadEsmModuleFromMemory(path: './main.server.mjs'): Promise<MainServerBundleExports>;
|
|
10
|
+
export declare function loadEsmModuleFromMemory(path: './render-utils.server.mjs'): Promise<RenderUtilsServerBundleExports>;
|
|
@@ -0,0 +1,26 @@
|
|
|
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.loadEsmModuleFromMemory = void 0;
|
|
11
|
+
const error_1 = require("../error");
|
|
12
|
+
const load_esm_1 = require("../load-esm");
|
|
13
|
+
function loadEsmModuleFromMemory(path) {
|
|
14
|
+
return (0, load_esm_1.loadEsmModule)(new URL(path, 'memory://')).catch((e) => {
|
|
15
|
+
(0, error_1.assertIsError)(e);
|
|
16
|
+
// While the error is an 'instanceof Error', it is extended with non transferable properties
|
|
17
|
+
// and cannot be transferred from a worker when using `--import`. This results in the error object
|
|
18
|
+
// displaying as '[Object object]' when read outside of the worker. Therefore, we reconstruct the error message here.
|
|
19
|
+
const error = new Error(e.message);
|
|
20
|
+
error.stack = e.stack;
|
|
21
|
+
error.name = e.name;
|
|
22
|
+
error.code = e.code;
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.loadEsmModuleFromMemory = loadEsmModuleFromMemory;
|
|
@@ -97,6 +97,7 @@ async function renderPages(sourcemap, allRoutes, maxThreads, workspaceRoot, outp
|
|
|
97
97
|
document,
|
|
98
98
|
},
|
|
99
99
|
execArgv: workerExecArgv,
|
|
100
|
+
recordTiming: false,
|
|
100
101
|
});
|
|
101
102
|
try {
|
|
102
103
|
const renderingPromises = [];
|
|
@@ -163,6 +164,7 @@ async function getAllRoutes(workspaceRoot, outputFilesForWorker, assetFilesForWo
|
|
|
163
164
|
verbose,
|
|
164
165
|
},
|
|
165
166
|
execArgv: workerExecArgv,
|
|
167
|
+
recordTiming: false,
|
|
166
168
|
});
|
|
167
169
|
const { routes: extractedRoutes, warnings } = await renderWorker
|
|
168
170
|
.run({})
|
|
@@ -36,11 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.renderPage = void 0;
|
|
37
37
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
38
38
|
const node_path_1 = require("node:path");
|
|
39
|
-
const
|
|
39
|
+
const load_esm_from_memory_1 = require("./load-esm-from-memory");
|
|
40
40
|
/**
|
|
41
41
|
* Renders each route in routes and writes them to <outputPath>/<route>/index.html.
|
|
42
42
|
*/
|
|
43
|
-
async function renderPage({ route, serverContext, document, inlineCriticalCss, outputFiles, loadBundle =
|
|
43
|
+
async function renderPage({ route, serverContext, document, inlineCriticalCss, outputFiles, loadBundle = load_esm_from_memory_1.loadEsmModuleFromMemory, }) {
|
|
44
44
|
const { default: bootstrapAppFnOrModule } = await loadBundle('./main.server.mjs');
|
|
45
45
|
const { ɵSERVER_CONTEXT, renderModule, renderApplication, ɵresetCompiledComponents, ɵConsole } = await loadBundle('./render-utils.server.mjs');
|
|
46
46
|
// Need to clean up GENERATED_COMP_IDS map in `@angular/core`.
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
11
|
-
const load_esm_1 = require("../load-esm");
|
|
12
11
|
const fetch_patch_1 = require("./fetch-patch");
|
|
13
12
|
const render_page_1 = require("./render-page");
|
|
14
13
|
/**
|
|
@@ -22,7 +21,6 @@ function render(options) {
|
|
|
22
21
|
outputFiles,
|
|
23
22
|
document,
|
|
24
23
|
inlineCriticalCss,
|
|
25
|
-
loadBundle: async (path) => await (0, load_esm_1.loadEsmModule)(new URL(path, 'memory://')),
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
function initialize() {
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
11
|
-
const load_esm_1 = require("../load-esm");
|
|
12
11
|
const fetch_patch_1 = require("./fetch-patch");
|
|
12
|
+
const load_esm_from_memory_1 = require("./load-esm-from-memory");
|
|
13
13
|
/**
|
|
14
14
|
* This is passed as workerData when setting up the worker via the `piscina` package.
|
|
15
15
|
*/
|
|
16
16
|
const { document, verbose } = node_worker_threads_1.workerData;
|
|
17
17
|
/** Renders an application based on a provided options. */
|
|
18
18
|
async function extractRoutes() {
|
|
19
|
-
const { extractRoutes } = await (0,
|
|
20
|
-
const { default: bootstrapAppFnOrModule } = await (0,
|
|
19
|
+
const { extractRoutes } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./render-utils.server.mjs');
|
|
20
|
+
const { default: bootstrapAppFnOrModule } = await (0, load_esm_from_memory_1.loadEsmModuleFromMemory)('./main.server.mjs');
|
|
21
21
|
const skippedRedirects = [];
|
|
22
22
|
const skippedOthers = [];
|
|
23
23
|
const routes = [];
|