@angular/build 18.2.0-next.2 → 18.2.0-rc.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 +10 -10
- package/src/builders/application/build-action.d.ts +0 -4
- package/src/builders/application/build-action.js +33 -48
- package/src/builders/application/index.d.ts +0 -2
- package/src/builders/application/index.js +74 -17
- package/src/builders/application/options.d.ts +5 -3
- package/src/builders/application/options.js +22 -19
- package/src/builders/dev-server/builder.js +1 -1
- package/src/builders/dev-server/vite-server.js +3 -3
- package/src/builders/extract-i18n/application-extraction.js +1 -1
- package/src/builders/extract-i18n/builder.js +6 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +6 -5
- package/src/tools/esbuild/stylesheets/bundle-options.js +1 -1
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +1 -1
- package/src/tools/esbuild/utils.d.ts +1 -2
- package/src/tools/esbuild/utils.js +0 -48
- package/src/utils/index-file/index-html-generator.js +1 -0
- package/src/utils/normalize-cache.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "18.2.0-
|
|
3
|
+
"version": "18.2.0-rc.0",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.1802.0-
|
|
27
|
-
"@babel/core": "7.
|
|
26
|
+
"@angular-devkit/architect": "0.1802.0-rc.0",
|
|
27
|
+
"@babel/core": "7.25.2",
|
|
28
28
|
"@babel/helper-annotate-as-pure": "7.24.7",
|
|
29
29
|
"@babel/helper-split-export-declaration": "7.24.7",
|
|
30
30
|
"@babel/plugin-syntax-import-attributes": "7.24.7",
|
|
31
|
-
"@inquirer/confirm": "3.1.
|
|
31
|
+
"@inquirer/confirm": "3.1.22",
|
|
32
32
|
"@vitejs/plugin-basic-ssl": "1.1.0",
|
|
33
33
|
"browserslist": "^4.23.0",
|
|
34
34
|
"critters": "0.0.24",
|
|
35
35
|
"esbuild": "0.23.0",
|
|
36
36
|
"fast-glob": "3.3.2",
|
|
37
37
|
"https-proxy-agent": "7.0.5",
|
|
38
|
-
"listr2": "8.2.
|
|
39
|
-
"lmdb": "3.0.
|
|
40
|
-
"magic-string": "0.30.
|
|
38
|
+
"listr2": "8.2.4",
|
|
39
|
+
"lmdb": "3.0.13",
|
|
40
|
+
"magic-string": "0.30.11",
|
|
41
41
|
"mrmime": "2.0.0",
|
|
42
42
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
44
44
|
"piscina": "4.6.1",
|
|
45
|
-
"rollup": "4.
|
|
45
|
+
"rollup": "4.20.0",
|
|
46
46
|
"sass": "1.77.8",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
|
-
"vite": "5.3.
|
|
48
|
+
"vite": "5.3.5",
|
|
49
49
|
"watchpack": "2.4.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"optional": true
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
|
-
"packageManager": "yarn@4.
|
|
81
|
+
"packageManager": "yarn@4.4.0",
|
|
82
82
|
"repository": {
|
|
83
83
|
"type": "git",
|
|
84
84
|
"url": "https://github.com/angular/angular-cli.git"
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
-
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
10
9
|
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
|
11
10
|
import { NormalizedCachedOptions } from '../../utils/normalize-cache';
|
|
12
11
|
import { NormalizedOutputOptions } from './options';
|
|
@@ -17,12 +16,9 @@ export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildSta
|
|
|
17
16
|
outputOptions: NormalizedOutputOptions;
|
|
18
17
|
logger: BuilderContext['logger'];
|
|
19
18
|
cacheOptions: NormalizedCachedOptions;
|
|
20
|
-
writeToFileSystem: boolean;
|
|
21
|
-
writeToFileSystemFilter: ((file: BuildOutputFile) => boolean) | undefined;
|
|
22
19
|
watch?: boolean;
|
|
23
20
|
verbose?: boolean;
|
|
24
21
|
progress?: boolean;
|
|
25
|
-
deleteOutputPath?: boolean;
|
|
26
22
|
poll?: number;
|
|
27
23
|
signal?: AbortSignal;
|
|
28
24
|
preserveSymlinks?: boolean;
|
|
@@ -39,7 +39,6 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
39
39
|
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
40
40
|
const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
|
|
41
41
|
const utils_1 = require("../../tools/esbuild/utils");
|
|
42
|
-
const delete_output_dir_1 = require("../../utils/delete-output-dir");
|
|
43
42
|
const environment_options_1 = require("../../utils/environment-options");
|
|
44
43
|
const results_1 = require("./results");
|
|
45
44
|
// Watch workspace for package manager changes
|
|
@@ -56,13 +55,7 @@ const packageWatchFiles = [
|
|
|
56
55
|
'.pnp.data.json',
|
|
57
56
|
];
|
|
58
57
|
async function* runEsBuildBuildAction(action, options) {
|
|
59
|
-
const {
|
|
60
|
-
if (deleteOutputPath && writeToFileSystem) {
|
|
61
|
-
await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputOptions.base, [
|
|
62
|
-
outputOptions.browser,
|
|
63
|
-
outputOptions.server,
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
58
|
+
const { watch, poll, clearScreen, logger, cacheOptions, outputOptions, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, colors, jsonLogs, } = options;
|
|
66
59
|
const withProgress = progress ? utils_1.withSpinner : utils_1.withNoProgress;
|
|
67
60
|
// Initial build
|
|
68
61
|
let result;
|
|
@@ -119,7 +112,7 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
119
112
|
// Output the first build results after setting up the watcher to ensure that any code executed
|
|
120
113
|
// higher in the iterator call stack will trigger the watcher. This is particularly relevant for
|
|
121
114
|
// unit tests which execute the builder and modify the file system programmatically.
|
|
122
|
-
yield await
|
|
115
|
+
yield await emitOutputResult(result, outputOptions);
|
|
123
116
|
// Finish if watch mode is not enabled
|
|
124
117
|
if (!watcher) {
|
|
125
118
|
return;
|
|
@@ -160,7 +153,7 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
160
153
|
if (staleWatchFiles?.size) {
|
|
161
154
|
watcher.remove([...staleWatchFiles]);
|
|
162
155
|
}
|
|
163
|
-
yield await
|
|
156
|
+
yield await emitOutputResult(result, outputOptions);
|
|
164
157
|
}
|
|
165
158
|
}
|
|
166
159
|
finally {
|
|
@@ -169,50 +162,42 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
169
162
|
(0, sass_language_1.shutdownSassWorkerPool)();
|
|
170
163
|
}
|
|
171
164
|
}
|
|
172
|
-
async function
|
|
173
|
-
if (
|
|
165
|
+
async function emitOutputResult({ outputFiles, assetFiles, errors, warnings, externalMetadata, htmlIndexPath, htmlBaseHref, }, outputOptions) {
|
|
166
|
+
if (errors.length > 0) {
|
|
174
167
|
return {
|
|
175
168
|
kind: results_1.ResultKind.Failure,
|
|
176
|
-
errors:
|
|
169
|
+
errors: errors,
|
|
170
|
+
warnings: warnings,
|
|
171
|
+
detail: {
|
|
172
|
+
outputOptions,
|
|
173
|
+
},
|
|
177
174
|
};
|
|
178
175
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
const result = {
|
|
177
|
+
kind: results_1.ResultKind.Full,
|
|
178
|
+
warnings: warnings,
|
|
179
|
+
files: {},
|
|
180
|
+
detail: {
|
|
181
|
+
externalMetadata,
|
|
182
|
+
htmlIndexPath,
|
|
183
|
+
htmlBaseHref,
|
|
184
|
+
outputOptions,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
for (const file of assetFiles) {
|
|
188
|
+
result.files[file.destination] = {
|
|
189
|
+
type: bundler_context_1.BuildOutputFileType.Browser,
|
|
190
|
+
inputPath: file.source,
|
|
191
|
+
origin: 'disk',
|
|
189
192
|
};
|
|
190
193
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
htmlIndexPath,
|
|
198
|
-
htmlBaseHref,
|
|
199
|
-
},
|
|
194
|
+
for (const file of outputFiles) {
|
|
195
|
+
result.files[file.path] = {
|
|
196
|
+
type: file.type,
|
|
197
|
+
contents: file.contents,
|
|
198
|
+
origin: 'memory',
|
|
199
|
+
hash: file.hash,
|
|
200
200
|
};
|
|
201
|
-
for (const file of outputWithFiles.assetFiles) {
|
|
202
|
-
result.files[file.destination] = {
|
|
203
|
-
type: bundler_context_1.BuildOutputFileType.Browser,
|
|
204
|
-
inputPath: file.source,
|
|
205
|
-
origin: 'disk',
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
for (const file of outputWithFiles.outputFiles) {
|
|
209
|
-
result.files[file.path] = {
|
|
210
|
-
type: file.type,
|
|
211
|
-
contents: file.contents,
|
|
212
|
-
origin: 'memory',
|
|
213
|
-
hash: file.hash,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
return result;
|
|
217
201
|
}
|
|
202
|
+
return result;
|
|
218
203
|
}
|
|
@@ -14,8 +14,6 @@ import { Schema as ApplicationBuilderOptions } from './schema';
|
|
|
14
14
|
export type { ApplicationBuilderOptions };
|
|
15
15
|
export declare function buildApplicationInternal(options: ApplicationBuilderInternalOptions, context: BuilderContext & {
|
|
16
16
|
signal?: AbortSignal;
|
|
17
|
-
}, infrastructureSettings?: {
|
|
18
|
-
write?: boolean;
|
|
19
17
|
}, extensions?: ApplicationBuilderExtensions): AsyncIterable<Result>;
|
|
20
18
|
export interface ApplicationBuilderOutput extends BuilderOutput {
|
|
21
19
|
outputFiles?: BuildOutputFile[];
|
|
@@ -6,13 +6,21 @@
|
|
|
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.dev/license
|
|
8
8
|
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
13
|
exports.buildApplicationInternal = buildApplicationInternal;
|
|
11
14
|
exports.buildApplication = buildApplication;
|
|
12
15
|
const architect_1 = require("@angular-devkit/architect");
|
|
16
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
17
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
19
|
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
14
20
|
const utils_1 = require("../../tools/esbuild/utils");
|
|
15
21
|
const color_1 = require("../../utils/color");
|
|
22
|
+
const delete_output_dir_1 = require("../../utils/delete-output-dir");
|
|
23
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
16
24
|
const purge_cache_1 = require("../../utils/purge-cache");
|
|
17
25
|
const version_1 = require("../../utils/version");
|
|
18
26
|
const build_action_1 = require("./build-action");
|
|
@@ -21,7 +29,7 @@ const options_1 = require("./options");
|
|
|
21
29
|
const results_1 = require("./results");
|
|
22
30
|
async function* buildApplicationInternal(options,
|
|
23
31
|
// TODO: Integrate abort signal support into builder system
|
|
24
|
-
context,
|
|
32
|
+
context, extensions) {
|
|
25
33
|
const { workspaceRoot, logger, target } = context;
|
|
26
34
|
// Check Angular version.
|
|
27
35
|
(0, version_1.assertCompatibleAngularVersion)(workspaceRoot);
|
|
@@ -36,9 +44,7 @@ context, infrastructureSettings, extensions) {
|
|
|
36
44
|
return;
|
|
37
45
|
}
|
|
38
46
|
const normalizedOptions = await (0, options_1.normalizeOptions)(context, projectName, options, extensions);
|
|
39
|
-
|
|
40
|
-
const writeServerBundles = writeToFileSystem && !!(normalizedOptions.ssrOptions && normalizedOptions.serverEntryPoint);
|
|
41
|
-
if (writeServerBundles) {
|
|
47
|
+
if (!normalizedOptions.outputOptions.ignoreServer) {
|
|
42
48
|
const { browser, server } = normalizedOptions.outputOptions;
|
|
43
49
|
if (browser === '') {
|
|
44
50
|
context.logger.error(`'outputPath.browser' cannot be configured to an empty string when SSR is enabled.`);
|
|
@@ -59,7 +65,7 @@ context, infrastructureSettings, extensions) {
|
|
|
59
65
|
context.addTeardown(() => controller.abort('builder-teardown'));
|
|
60
66
|
}
|
|
61
67
|
yield* (0, build_action_1.runEsBuildBuildAction)(async (rebuildState) => {
|
|
62
|
-
const { prerenderOptions,
|
|
68
|
+
const { prerenderOptions, jsonLogs } = normalizedOptions;
|
|
63
69
|
const startTime = process.hrtime.bigint();
|
|
64
70
|
const result = await (0, execute_build_1.executeBuild)(normalizedOptions, context, rebuildState);
|
|
65
71
|
if (jsonLogs) {
|
|
@@ -74,9 +80,6 @@ context, infrastructureSettings, extensions) {
|
|
|
74
80
|
}
|
|
75
81
|
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
|
|
76
82
|
const hasError = result.errors.length > 0;
|
|
77
|
-
if (writeToFileSystem && !hasError) {
|
|
78
|
-
result.addLog(`Output location: ${outputOptions.base}\n`);
|
|
79
|
-
}
|
|
80
83
|
result.addLog(`Application bundle generation ${hasError ? 'failed' : 'complete'}. [${buildTime.toFixed(3)} seconds]\n`);
|
|
81
84
|
}
|
|
82
85
|
return result;
|
|
@@ -84,7 +87,6 @@ context, infrastructureSettings, extensions) {
|
|
|
84
87
|
watch: normalizedOptions.watch,
|
|
85
88
|
preserveSymlinks: normalizedOptions.preserveSymlinks,
|
|
86
89
|
poll: normalizedOptions.poll,
|
|
87
|
-
deleteOutputPath: normalizedOptions.deleteOutputPath,
|
|
88
90
|
cacheOptions: normalizedOptions.cacheOptions,
|
|
89
91
|
outputOptions: normalizedOptions.outputOptions,
|
|
90
92
|
verbose: normalizedOptions.verbose,
|
|
@@ -94,12 +96,6 @@ context, infrastructureSettings, extensions) {
|
|
|
94
96
|
clearScreen: normalizedOptions.clearScreen,
|
|
95
97
|
colors: normalizedOptions.colors,
|
|
96
98
|
jsonLogs: normalizedOptions.jsonLogs,
|
|
97
|
-
writeToFileSystem,
|
|
98
|
-
// For app-shell and SSG server files are not required by users.
|
|
99
|
-
// Omit these when SSR is not enabled.
|
|
100
|
-
writeToFileSystemFilter: writeServerBundles
|
|
101
|
-
? undefined
|
|
102
|
-
: (file) => file.type !== bundler_context_1.BuildOutputFileType.Server,
|
|
103
99
|
logger,
|
|
104
100
|
signal,
|
|
105
101
|
});
|
|
@@ -114,8 +110,69 @@ async function* buildApplication(options, context, pluginsOrExtensions) {
|
|
|
114
110
|
else {
|
|
115
111
|
extensions = pluginsOrExtensions;
|
|
116
112
|
}
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
let initial = true;
|
|
114
|
+
for await (const result of buildApplicationInternal(options, context, extensions)) {
|
|
115
|
+
const outputOptions = result.detail?.['outputOptions'];
|
|
116
|
+
if (initial) {
|
|
117
|
+
initial = false;
|
|
118
|
+
// Clean the output location if requested.
|
|
119
|
+
// Output options may not be present if the build failed.
|
|
120
|
+
if (outputOptions?.clean) {
|
|
121
|
+
await (0, delete_output_dir_1.deleteOutputDir)(context.workspaceRoot, outputOptions.base, [
|
|
122
|
+
outputOptions.browser,
|
|
123
|
+
outputOptions.server,
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (result.kind === results_1.ResultKind.Failure) {
|
|
128
|
+
yield { success: false };
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
(0, node_assert_1.default)(outputOptions, 'Application output options are required for builder usage.');
|
|
132
|
+
(0, node_assert_1.default)(result.kind === results_1.ResultKind.Full, 'Application build did not provide a full output.');
|
|
133
|
+
// TODO: Restructure output logging to better handle stdout JSON piping
|
|
134
|
+
if (!environment_options_1.useJSONBuildLogs) {
|
|
135
|
+
context.logger.info(`Output location: ${outputOptions.base}\n`);
|
|
136
|
+
}
|
|
137
|
+
// Writes the output files to disk and ensures the containing directories are present
|
|
138
|
+
const directoryExists = new Set();
|
|
139
|
+
await (0, utils_1.emitFilesToDisk)(Object.entries(result.files), async ([filePath, file]) => {
|
|
140
|
+
if (outputOptions.ignoreServer && file.type === bundler_context_1.BuildOutputFileType.Server) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
let typeDirectory;
|
|
144
|
+
switch (file.type) {
|
|
145
|
+
case bundler_context_1.BuildOutputFileType.Browser:
|
|
146
|
+
case bundler_context_1.BuildOutputFileType.Media:
|
|
147
|
+
typeDirectory = outputOptions.browser;
|
|
148
|
+
break;
|
|
149
|
+
case bundler_context_1.BuildOutputFileType.Server:
|
|
150
|
+
typeDirectory = outputOptions.server;
|
|
151
|
+
break;
|
|
152
|
+
case bundler_context_1.BuildOutputFileType.Root:
|
|
153
|
+
typeDirectory = '';
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
throw new Error(`Unhandled write for file "${filePath}" with type "${bundler_context_1.BuildOutputFileType[file.type]}".`);
|
|
157
|
+
}
|
|
158
|
+
// NOTE: 'base' is a fully resolved path at this point
|
|
159
|
+
const fullFilePath = node_path_1.default.join(outputOptions.base, typeDirectory, filePath);
|
|
160
|
+
// Ensure output subdirectories exist
|
|
161
|
+
const fileBasePath = node_path_1.default.dirname(fullFilePath);
|
|
162
|
+
if (fileBasePath && !directoryExists.has(fileBasePath)) {
|
|
163
|
+
await promises_1.default.mkdir(fileBasePath, { recursive: true });
|
|
164
|
+
directoryExists.add(fileBasePath);
|
|
165
|
+
}
|
|
166
|
+
if (file.origin === 'memory') {
|
|
167
|
+
// Write file contents
|
|
168
|
+
await promises_1.default.writeFile(fullFilePath, file.contents);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// Copy file contents
|
|
172
|
+
await promises_1.default.copyFile(file.inputPath, fullFilePath, promises_1.default.constants.COPYFILE_FICLONE);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
yield { success: true };
|
|
119
176
|
}
|
|
120
177
|
}
|
|
121
178
|
exports.default = (0, architect_1.createBuilder)(buildApplication);
|
|
@@ -10,7 +10,10 @@ import type { Plugin } from 'esbuild';
|
|
|
10
10
|
import { I18nOptions } from '../../utils/i18n-options';
|
|
11
11
|
import { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
|
|
12
12
|
import { Schema as ApplicationBuilderOptions, I18NTranslation, OutputPathClass } from './schema';
|
|
13
|
-
export type NormalizedOutputOptions = Required<OutputPathClass
|
|
13
|
+
export type NormalizedOutputOptions = Required<OutputPathClass> & {
|
|
14
|
+
clean: boolean;
|
|
15
|
+
ignoreServer: boolean;
|
|
16
|
+
};
|
|
14
17
|
export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normalizeOptions>>;
|
|
15
18
|
export interface ApplicationBuilderExtensions {
|
|
16
19
|
codePlugins?: Plugin[];
|
|
@@ -61,7 +64,6 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
61
64
|
baseHref: string | undefined;
|
|
62
65
|
cacheOptions: import("../../utils/normalize-cache").NormalizedCachedOptions;
|
|
63
66
|
crossOrigin: import("./schema").CrossOrigin | undefined;
|
|
64
|
-
deleteOutputPath: boolean | undefined;
|
|
65
67
|
externalDependencies: string[] | undefined;
|
|
66
68
|
extractLicenses: boolean | undefined;
|
|
67
69
|
inlineStyleLanguage: string;
|
|
@@ -94,7 +96,7 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
94
96
|
workspaceRoot: string;
|
|
95
97
|
entryPoints: Record<string, string>;
|
|
96
98
|
optimizationOptions: import("../../utils").NormalizedOptimizationOptions;
|
|
97
|
-
outputOptions:
|
|
99
|
+
outputOptions: NormalizedOutputOptions;
|
|
98
100
|
outExtension: "js" | "mjs" | undefined;
|
|
99
101
|
sourcemapOptions: import("./schema").SourceMapClass;
|
|
100
102
|
tsconfig: string;
|
|
@@ -63,23 +63,6 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
63
63
|
const assets = options.assets?.length
|
|
64
64
|
? (0, utils_1.normalizeAssetPatterns)(options.assets, workspaceRoot, projectRoot, projectSourceRoot)
|
|
65
65
|
: undefined;
|
|
66
|
-
const outputPath = options.outputPath;
|
|
67
|
-
const outputOptions = {
|
|
68
|
-
browser: 'browser',
|
|
69
|
-
server: 'server',
|
|
70
|
-
media: 'media',
|
|
71
|
-
...(typeof outputPath === 'string' ? undefined : outputPath),
|
|
72
|
-
base: normalizeDirectoryPath(node_path_1.default.resolve(workspaceRoot, typeof outputPath === 'string' ? outputPath : outputPath.base)),
|
|
73
|
-
};
|
|
74
|
-
const outputNames = {
|
|
75
|
-
bundles: options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Bundles
|
|
76
|
-
? '[name]-[hash]'
|
|
77
|
-
: '[name]',
|
|
78
|
-
media: outputOptions.media +
|
|
79
|
-
(options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Media
|
|
80
|
-
? '/[name]-[hash]'
|
|
81
|
-
: '/[name]'),
|
|
82
|
-
};
|
|
83
66
|
let fileReplacements;
|
|
84
67
|
if (options.fileReplacements) {
|
|
85
68
|
for (const replacement of options.fileReplacements) {
|
|
@@ -145,6 +128,27 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
145
128
|
route: 'shell',
|
|
146
129
|
};
|
|
147
130
|
}
|
|
131
|
+
const outputPath = options.outputPath;
|
|
132
|
+
const outputOptions = {
|
|
133
|
+
browser: 'browser',
|
|
134
|
+
server: 'server',
|
|
135
|
+
media: 'media',
|
|
136
|
+
...(typeof outputPath === 'string' ? undefined : outputPath),
|
|
137
|
+
base: normalizeDirectoryPath(node_path_1.default.resolve(workspaceRoot, typeof outputPath === 'string' ? outputPath : outputPath.base)),
|
|
138
|
+
clean: options.deleteOutputPath ?? true,
|
|
139
|
+
// For app-shell and SSG server files are not required by users.
|
|
140
|
+
// Omit these when SSR is not enabled.
|
|
141
|
+
ignoreServer: ssrOptions === undefined || serverEntryPoint === undefined,
|
|
142
|
+
};
|
|
143
|
+
const outputNames = {
|
|
144
|
+
bundles: options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Bundles
|
|
145
|
+
? '[name]-[hash]'
|
|
146
|
+
: '[name]',
|
|
147
|
+
media: outputOptions.media +
|
|
148
|
+
(options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Media
|
|
149
|
+
? '/[name]-[hash]'
|
|
150
|
+
: '/[name]'),
|
|
151
|
+
};
|
|
148
152
|
const globalStyles = normalizeGlobalEntries(options.styles, 'styles');
|
|
149
153
|
const globalScripts = normalizeGlobalEntries(options.scripts, 'scripts');
|
|
150
154
|
let indexHtmlOptions;
|
|
@@ -189,7 +193,7 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
// Initial options to keep
|
|
192
|
-
const { allowedCommonJsDependencies, aot, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages,
|
|
196
|
+
const { allowedCommonJsDependencies, aot, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, namedChunks, budgets, deployUrl, clearScreen, define, } = options;
|
|
193
197
|
// Return all the normalized options
|
|
194
198
|
return {
|
|
195
199
|
advancedOptimizations: !!aot && optimizationOptions.scripts,
|
|
@@ -197,7 +201,6 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
197
201
|
baseHref,
|
|
198
202
|
cacheOptions,
|
|
199
203
|
crossOrigin,
|
|
200
|
-
deleteOutputPath,
|
|
201
204
|
externalDependencies,
|
|
202
205
|
extractLicenses,
|
|
203
206
|
inlineStyleLanguage,
|
|
@@ -37,7 +37,7 @@ async function* execute(options, context, extensions) {
|
|
|
37
37
|
if (options.prebundle && !normalizedOptions.cacheOptions.enabled) {
|
|
38
38
|
context.logger.warn(`Prebundling has been configured but will not be used because caching has been disabled.`);
|
|
39
39
|
}
|
|
40
|
-
yield* (0, vite_server_1.serveWithVite)(normalizedOptions, builderName, (options, context, plugins) => (0, internal_1.buildApplicationInternal)(options, context, {
|
|
40
|
+
yield* (0, vite_server_1.serveWithVite)(normalizedOptions, builderName, (options, context, plugins) => (0, internal_1.buildApplicationInternal)(options, context, { codePlugins: plugins }), context, { indexHtml: extensions?.indexHtmlTransformer }, extensions);
|
|
41
41
|
}
|
|
42
42
|
async function initialize(initialOptions, projectName, context) {
|
|
43
43
|
// Purge old build disk cache.
|
|
@@ -37,7 +37,6 @@ exports.serveWithVite = serveWithVite;
|
|
|
37
37
|
exports.setupServer = setupServer;
|
|
38
38
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
39
39
|
const promises_1 = require("node:fs/promises");
|
|
40
|
-
const node_inspector_1 = __importDefault(require("node:inspector"));
|
|
41
40
|
const node_module_1 = require("node:module");
|
|
42
41
|
const node_path_1 = require("node:path");
|
|
43
42
|
const angular_memory_plugin_1 = require("../../tools/vite/angular-memory-plugin");
|
|
@@ -220,8 +219,9 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
220
219
|
context.logger.info('NOTE: Raw file sizes do not reflect development server per-request transformations.');
|
|
221
220
|
if (browserOptions.ssr && serverOptions.inspect) {
|
|
222
221
|
const { host, port } = serverOptions.inspect;
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
const { default: inspector } = await Promise.resolve().then(() => __importStar(require('node:inspector')));
|
|
223
|
+
inspector.open(port, host, true);
|
|
224
|
+
context.addTeardown(() => inspector.close());
|
|
225
225
|
}
|
|
226
226
|
const { root = '' } = await context.getProjectMetadata(projectName);
|
|
227
227
|
const projectRoot = (0, node_path_1.join)(context.workspaceRoot, root);
|
|
@@ -28,7 +28,7 @@ async function extractMessages(options, builderName, context, extractorConstruct
|
|
|
28
28
|
buildOptions.appShell = false;
|
|
29
29
|
buildOptions.prerender = false;
|
|
30
30
|
// Build the application with the build options
|
|
31
|
-
const builderResult = await first((0, application_1.buildApplicationInternal)(buildOptions, context,
|
|
31
|
+
const builderResult = await first((0, application_1.buildApplicationInternal)(buildOptions, context, extensions));
|
|
32
32
|
let success = false;
|
|
33
33
|
if (!builderResult || builderResult.kind === results_1.ResultKind.Failure) {
|
|
34
34
|
context.logger.error('Application build failed.');
|
|
@@ -50,6 +50,12 @@ async function execute(options, context, extensions) {
|
|
|
50
50
|
context.logger.error(`The 'extract-i18n' builder requires a target to be specified.`);
|
|
51
51
|
return { success: false };
|
|
52
52
|
}
|
|
53
|
+
const { projectType } = (await context.getProjectMetadata(projectName));
|
|
54
|
+
if (projectType !== 'application') {
|
|
55
|
+
context.logger.error(`Tried to extract from ${projectName} with 'projectType' ${projectType}, which is not supported.` +
|
|
56
|
+
` The 'extract-i18n' builder can only extract from applications.`);
|
|
57
|
+
return { success: false };
|
|
58
|
+
}
|
|
53
59
|
// Check Angular version.
|
|
54
60
|
(0, version_1.assertCompatibleAngularVersion)(context.workspaceRoot);
|
|
55
61
|
// Load the Angular localize package.
|
|
@@ -216,7 +216,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
216
216
|
location: null,
|
|
217
217
|
notes: [
|
|
218
218
|
{
|
|
219
|
-
text: error instanceof Error ? error.stack ?? error.message : `${error}`,
|
|
219
|
+
text: error instanceof Error ? (error.stack ?? error.message) : `${error}`,
|
|
220
220
|
location: null,
|
|
221
221
|
},
|
|
222
222
|
],
|
|
@@ -243,7 +243,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
243
243
|
location: null,
|
|
244
244
|
notes: [
|
|
245
245
|
{
|
|
246
|
-
text: error instanceof Error ? error.stack ?? error.message : `${error}`,
|
|
246
|
+
text: error instanceof Error ? (error.stack ?? error.message) : `${error}`,
|
|
247
247
|
location: null,
|
|
248
248
|
},
|
|
249
249
|
],
|
|
@@ -404,9 +404,10 @@ function createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserve
|
|
|
404
404
|
});
|
|
405
405
|
compilerOptions.compilationMode = 'full';
|
|
406
406
|
}
|
|
407
|
-
// Enable incremental compilation by default if caching is enabled
|
|
408
|
-
if (
|
|
409
|
-
|
|
407
|
+
// Enable incremental compilation by default if caching is enabled and incremental is not explicitly disabled
|
|
408
|
+
if (compilerOptions.incremental !== false &&
|
|
409
|
+
pluginOptions.sourceFileCache?.persistentCachePath) {
|
|
410
|
+
compilerOptions.incremental = true;
|
|
410
411
|
// Set the build info file location to the configured cache directory
|
|
411
412
|
compilerOptions.tsBuildInfoFile = path.join(pluginOptions.sourceFileCache?.persistentCachePath, '.tsbuildinfo');
|
|
412
413
|
}
|
|
@@ -35,7 +35,7 @@ function createStylesheetBundleOptions(options, cache, inlineComponentData) {
|
|
|
35
35
|
(0, css_resource_plugin_1.createCssResourcePlugin)(cache),
|
|
36
36
|
];
|
|
37
37
|
if (options.inlineFonts) {
|
|
38
|
-
plugins.
|
|
38
|
+
plugins.unshift((0, css_inline_fonts_plugin_1.createCssInlineFontsPlugin)({ cache, cacheOptions: options.cacheOptions }));
|
|
39
39
|
}
|
|
40
40
|
return {
|
|
41
41
|
absWorkingDir: options.workspaceRoot,
|
|
@@ -112,7 +112,7 @@ class StylesheetPluginFactory {
|
|
|
112
112
|
return processStylesheet(language, data, filename, format, options, build, postcssProcessor);
|
|
113
113
|
}));
|
|
114
114
|
// Add a load callback to support files from disk
|
|
115
|
-
build.onLoad({ filter: language.fileFilter }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
|
|
115
|
+
build.onLoad({ filter: language.fileFilter, namespace: 'file' }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
|
|
116
116
|
const data = await (0, promises_1.readFile)(args.path, 'utf-8');
|
|
117
117
|
return processStylesheet(language, data, args.path, (0, node_path_1.extname)(args.path).toLowerCase().slice(1), options, build, postcssProcessor);
|
|
118
118
|
}));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
9
|
import { BuildOptions, Metafile, OutputFile } from 'esbuild';
|
|
10
|
-
import { NormalizedApplicationBuildOptions
|
|
10
|
+
import { NormalizedApplicationBuildOptions } from '../../builders/application/options';
|
|
11
11
|
import { BudgetCalculatorResult } from '../../utils/bundle-calculator';
|
|
12
12
|
import { BuildOutputFile, BuildOutputFileType, InitialFileRecord } from './bundler-context';
|
|
13
13
|
import { BuildOutputAsset, ExecutionResult } from './bundler-execution-result';
|
|
@@ -24,7 +24,6 @@ export declare function withNoProgress<T>(text: string, action: () => T | Promis
|
|
|
24
24
|
* @returns An object that can be used with the esbuild build `supported` option.
|
|
25
25
|
*/
|
|
26
26
|
export declare function getFeatureSupport(target: string[], nativeAsyncAwait: boolean): BuildOptions['supported'];
|
|
27
|
-
export declare function writeResultFiles(outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[] | undefined, { base, browser, server }: NormalizedOutputOptions): Promise<void>;
|
|
28
27
|
export declare function emitFilesToDisk<T = BuildOutputAsset | BuildOutputFile>(files: T[], writeFileCallback: (file: T) => Promise<void>): Promise<void>;
|
|
29
28
|
export declare function createOutputFile(path: string, data: string | Uint8Array, type: BuildOutputFileType): BuildOutputFile;
|
|
30
29
|
export declare function convertOutputFile(file: OutputFile, type: BuildOutputFileType): BuildOutputFile;
|
|
@@ -6,9 +6,6 @@
|
|
|
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.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.logBuildStats = logBuildStats;
|
|
14
11
|
exports.getChunkNameFromMetafile = getChunkNameFromMetafile;
|
|
@@ -16,7 +13,6 @@ exports.calculateEstimatedTransferSizes = calculateEstimatedTransferSizes;
|
|
|
16
13
|
exports.withSpinner = withSpinner;
|
|
17
14
|
exports.withNoProgress = withNoProgress;
|
|
18
15
|
exports.getFeatureSupport = getFeatureSupport;
|
|
19
|
-
exports.writeResultFiles = writeResultFiles;
|
|
20
16
|
exports.emitFilesToDisk = emitFilesToDisk;
|
|
21
17
|
exports.createOutputFile = createOutputFile;
|
|
22
18
|
exports.convertOutputFile = convertOutputFile;
|
|
@@ -29,8 +25,6 @@ exports.getEntryPointName = getEntryPointName;
|
|
|
29
25
|
const esbuild_1 = require("esbuild");
|
|
30
26
|
const listr2_1 = require("listr2");
|
|
31
27
|
const node_crypto_1 = require("node:crypto");
|
|
32
|
-
const node_fs_1 = require("node:fs");
|
|
33
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
34
28
|
const node_path_1 = require("node:path");
|
|
35
29
|
const node_url_1 = require("node:url");
|
|
36
30
|
const node_zlib_1 = require("node:zlib");
|
|
@@ -187,48 +181,6 @@ function getFeatureSupport(target, nativeAsyncAwait) {
|
|
|
187
181
|
}
|
|
188
182
|
return supported;
|
|
189
183
|
}
|
|
190
|
-
async function writeResultFiles(outputFiles, assetFiles, { base, browser, server }) {
|
|
191
|
-
const directoryExists = new Set();
|
|
192
|
-
const ensureDirectoryExists = async (destPath) => {
|
|
193
|
-
const basePath = (0, node_path_1.dirname)(destPath);
|
|
194
|
-
if (!directoryExists.has(basePath)) {
|
|
195
|
-
await promises_1.default.mkdir((0, node_path_1.join)(base, basePath), { recursive: true });
|
|
196
|
-
directoryExists.add(basePath);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
// Writes the output file to disk and ensures the containing directories are present
|
|
200
|
-
await emitFilesToDisk(outputFiles, async (file) => {
|
|
201
|
-
let outputDir;
|
|
202
|
-
switch (file.type) {
|
|
203
|
-
case bundler_context_1.BuildOutputFileType.Browser:
|
|
204
|
-
case bundler_context_1.BuildOutputFileType.Media:
|
|
205
|
-
outputDir = browser;
|
|
206
|
-
break;
|
|
207
|
-
case bundler_context_1.BuildOutputFileType.Server:
|
|
208
|
-
outputDir = server;
|
|
209
|
-
break;
|
|
210
|
-
case bundler_context_1.BuildOutputFileType.Root:
|
|
211
|
-
outputDir = '';
|
|
212
|
-
break;
|
|
213
|
-
default:
|
|
214
|
-
throw new Error(`Unhandled write for file "${file.path}" with type "${bundler_context_1.BuildOutputFileType[file.type]}".`);
|
|
215
|
-
}
|
|
216
|
-
const destPath = (0, node_path_1.join)(outputDir, file.path);
|
|
217
|
-
// Ensure output subdirectories exist
|
|
218
|
-
await ensureDirectoryExists(destPath);
|
|
219
|
-
// Write file contents
|
|
220
|
-
await promises_1.default.writeFile((0, node_path_1.join)(base, destPath), file.contents);
|
|
221
|
-
});
|
|
222
|
-
if (assetFiles?.length) {
|
|
223
|
-
await emitFilesToDisk(assetFiles, async ({ source, destination }) => {
|
|
224
|
-
const destPath = (0, node_path_1.join)(browser, destination);
|
|
225
|
-
// Ensure output subdirectories exist
|
|
226
|
-
await ensureDirectoryExists(destPath);
|
|
227
|
-
// Copy file contents
|
|
228
|
-
await promises_1.default.copyFile(source, (0, node_path_1.join)(base, destPath), node_fs_1.constants.COPYFILE_FICLONE);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
184
|
const MAX_CONCURRENT_WRITES = 64;
|
|
233
185
|
async function emitFilesToDisk(files, writeFileCallback) {
|
|
234
186
|
// Write files in groups of MAX_CONCURRENT_WRITES to avoid too many open files
|
|
@@ -32,6 +32,7 @@ class IndexHtmlGenerator {
|
|
|
32
32
|
if (options?.optimization?.styles?.inlineCritical) {
|
|
33
33
|
this.csrPlugins.push(inlineCriticalCssPlugin(this));
|
|
34
34
|
}
|
|
35
|
+
this.csrPlugins.push(addNoncePlugin());
|
|
35
36
|
// SSR plugins
|
|
36
37
|
if (options.generateDedicatedSSRContent) {
|
|
37
38
|
this.ssrPlugins.push(addEventDispatchContractPlugin(), addNoncePlugin());
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.normalizeCacheOptions = normalizeCacheOptions;
|
|
11
11
|
const node_path_1 = require("node:path");
|
|
12
12
|
/** Version placeholder is replaced during the build process with actual package version */
|
|
13
|
-
const VERSION = '18.2.0-
|
|
13
|
+
const VERSION = '18.2.0-rc.0';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|