@angular-devkit/build-angular 17.1.0-next.2 → 17.1.0-next.3
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 +4 -3
- package/src/builders/application/build-action.js +8 -5
- package/src/builders/application/execute-build.js +3 -3
- package/src/builders/application/index.d.ts +20 -10
- package/src/builders/application/index.js +38 -26
- package/src/builders/application/options.d.ts +11 -3
- package/src/builders/application/options.js +39 -26
- package/src/builders/application/schema.d.ts +32 -2
- package/src/builders/application/schema.json +40 -2
- package/src/builders/browser-esbuild/index.js +8 -4
- package/src/builders/dev-server/vite-server.js +5 -12
- package/src/builders/ssr-dev-server/index.js +17 -31
- package/src/tools/esbuild/angular/angular-host.js +1 -1
- package/src/tools/esbuild/angular/compiler-plugin.js +10 -26
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +3 -6
- package/src/tools/esbuild/angular/component-stylesheets.js +41 -46
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +2 -2
- package/src/tools/esbuild/bundler-context.d.ts +1 -1
- package/src/tools/esbuild/bundler-context.js +18 -2
- package/src/tools/esbuild/compiler-plugin-options.js +1 -1
- package/src/tools/esbuild/index-html-generator.js +3 -1
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +1 -1
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +9 -1
- package/src/tools/esbuild/utils.d.ts +2 -2
- package/src/tools/esbuild/utils.js +61 -74
- package/src/utils/index-file/index-html-generator.js +15 -28
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +1 -0
- package/src/{builders/dev-server → utils}/load-proxy-config.js +2 -2
- /package/src/{builders/dev-server → utils}/load-proxy-config.d.ts +0 -0
|
@@ -6,46 +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.io/license
|
|
8
8
|
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
9
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
11
|
};
|
|
35
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.
|
|
13
|
+
exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.convertOutputFile = exports.createOutputFileFromData = exports.createOutputFileFromText = exports.emitFilesToDisk = exports.writeResultFiles = exports.getFeatureSupport = exports.logMessages = exports.withNoProgress = exports.withSpinner = exports.calculateEstimatedTransferSizes = exports.logBuildStats = void 0;
|
|
37
14
|
const esbuild_1 = require("esbuild");
|
|
38
15
|
const node_crypto_1 = require("node:crypto");
|
|
39
16
|
const node_fs_1 = require("node:fs");
|
|
40
17
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
41
|
-
const node_path_1 =
|
|
42
|
-
const node_util_1 = require("node:util");
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
43
19
|
const node_zlib_1 = require("node:zlib");
|
|
44
20
|
const semver_1 = require("semver");
|
|
45
21
|
const spinner_1 = require("../../utils/spinner");
|
|
46
22
|
const stats_1 = require("../webpack/utils/stats");
|
|
47
23
|
const bundler_context_1 = require("./bundler-context");
|
|
48
|
-
const compressAsync = (0, node_util_1.promisify)(node_zlib_1.brotliCompress);
|
|
49
24
|
function logBuildStats(context, metafile, initial, budgetFailures, changedFiles, estimatedTransferSizes) {
|
|
50
25
|
const stats = [];
|
|
51
26
|
let unchangedCount = 0;
|
|
@@ -90,22 +65,41 @@ function logBuildStats(context, metafile, initial, budgetFailures, changedFiles,
|
|
|
90
65
|
exports.logBuildStats = logBuildStats;
|
|
91
66
|
async function calculateEstimatedTransferSizes(outputFiles) {
|
|
92
67
|
const sizes = new Map();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
68
|
+
if (outputFiles.length <= 0) {
|
|
69
|
+
return sizes;
|
|
70
|
+
}
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
let completeCount = 0;
|
|
73
|
+
for (const outputFile of outputFiles) {
|
|
74
|
+
// Only calculate JavaScript and CSS files
|
|
75
|
+
if (!outputFile.path.endsWith('.js') && !outputFile.path.endsWith('.css')) {
|
|
76
|
+
++completeCount;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Skip compressing small files which may end being larger once compressed and will most likely not be
|
|
80
|
+
// compressed in actual transit.
|
|
81
|
+
if (outputFile.contents.byteLength < 1024) {
|
|
82
|
+
sizes.set(outputFile.path, outputFile.contents.byteLength);
|
|
83
|
+
++completeCount;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
// Directly use the async callback function to minimize the number of Promises that need to be created.
|
|
87
|
+
(0, node_zlib_1.brotliCompress)(outputFile.contents, (error, result) => {
|
|
88
|
+
if (error) {
|
|
89
|
+
reject(error);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
sizes.set(outputFile.path, result.byteLength);
|
|
93
|
+
if (++completeCount >= outputFiles.length) {
|
|
94
|
+
resolve(sizes);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
98
97
|
}
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
sizes.set(outputFile.path, outputFile.contents.byteLength);
|
|
103
|
-
continue;
|
|
98
|
+
// Covers the case where no files need to be compressed
|
|
99
|
+
if (completeCount >= outputFiles.length) {
|
|
100
|
+
resolve(sizes);
|
|
104
101
|
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
await Promise.all(pendingCompression);
|
|
108
|
-
return sizes;
|
|
102
|
+
});
|
|
109
103
|
}
|
|
110
104
|
exports.calculateEstimatedTransferSizes = calculateEstimatedTransferSizes;
|
|
111
105
|
async function withSpinner(text, action) {
|
|
@@ -182,31 +176,45 @@ function getFeatureSupport(target) {
|
|
|
182
176
|
return supported;
|
|
183
177
|
}
|
|
184
178
|
exports.getFeatureSupport = getFeatureSupport;
|
|
185
|
-
async function writeResultFiles(outputFiles, assetFiles,
|
|
179
|
+
async function writeResultFiles(outputFiles, assetFiles, { base, browser, media, server }) {
|
|
186
180
|
const directoryExists = new Set();
|
|
187
|
-
const ensureDirectoryExists = async (
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
const ensureDirectoryExists = async (destPath) => {
|
|
182
|
+
const basePath = node_path_1.default.dirname(destPath);
|
|
183
|
+
if (!directoryExists.has(basePath)) {
|
|
184
|
+
await promises_1.default.mkdir(node_path_1.default.join(base, basePath), { recursive: true });
|
|
190
185
|
directoryExists.add(basePath);
|
|
191
186
|
}
|
|
192
187
|
};
|
|
193
188
|
// Writes the output file to disk and ensures the containing directories are present
|
|
194
189
|
await emitFilesToDisk(outputFiles, async (file) => {
|
|
195
|
-
|
|
190
|
+
let outputDir;
|
|
191
|
+
switch (file.type) {
|
|
192
|
+
case bundler_context_1.BuildOutputFileType.Browser:
|
|
193
|
+
case bundler_context_1.BuildOutputFileType.Media:
|
|
194
|
+
outputDir = browser;
|
|
195
|
+
break;
|
|
196
|
+
case bundler_context_1.BuildOutputFileType.Server:
|
|
197
|
+
outputDir = server;
|
|
198
|
+
break;
|
|
199
|
+
case bundler_context_1.BuildOutputFileType.Root:
|
|
200
|
+
outputDir = '';
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
throw new Error(`Unhandled write for file "${file.path}" with type "${bundler_context_1.BuildOutputFileType[file.type]}".`);
|
|
204
|
+
}
|
|
205
|
+
const destPath = node_path_1.default.join(outputDir, file.path);
|
|
196
206
|
// Ensure output subdirectories exist
|
|
197
|
-
|
|
198
|
-
await ensureDirectoryExists(basePath);
|
|
207
|
+
await ensureDirectoryExists(destPath);
|
|
199
208
|
// Write file contents
|
|
200
|
-
await promises_1.default.writeFile(node_path_1.default.join(
|
|
209
|
+
await promises_1.default.writeFile(node_path_1.default.join(base, destPath), file.contents);
|
|
201
210
|
});
|
|
202
211
|
if (assetFiles?.length) {
|
|
203
212
|
await emitFilesToDisk(assetFiles, async ({ source, destination }) => {
|
|
213
|
+
const destPath = node_path_1.default.join(browser, destination);
|
|
204
214
|
// Ensure output subdirectories exist
|
|
205
|
-
|
|
206
|
-
const basePath = node_path_1.default.dirname(destPath);
|
|
207
|
-
await ensureDirectoryExists(basePath);
|
|
215
|
+
await ensureDirectoryExists(destPath);
|
|
208
216
|
// Copy file contents
|
|
209
|
-
await promises_1.default.copyFile(source, node_path_1.default.join(
|
|
217
|
+
await promises_1.default.copyFile(source, node_path_1.default.join(base, destPath), node_fs_1.constants.COPYFILE_FICLONE);
|
|
210
218
|
});
|
|
211
219
|
}
|
|
212
220
|
}
|
|
@@ -235,9 +243,6 @@ function createOutputFileFromText(path, text, type) {
|
|
|
235
243
|
get contents() {
|
|
236
244
|
return Buffer.from(this.text, 'utf-8');
|
|
237
245
|
},
|
|
238
|
-
get fullOutputPath() {
|
|
239
|
-
return getFullOutputPath(this);
|
|
240
|
-
},
|
|
241
246
|
clone() {
|
|
242
247
|
return createOutputFileFromText(this.path, this.text, this.type);
|
|
243
248
|
},
|
|
@@ -257,9 +262,6 @@ function createOutputFileFromData(path, data, type) {
|
|
|
257
262
|
get contents() {
|
|
258
263
|
return data;
|
|
259
264
|
},
|
|
260
|
-
get fullOutputPath() {
|
|
261
|
-
return getFullOutputPath(this);
|
|
262
|
-
},
|
|
263
265
|
clone() {
|
|
264
266
|
return createOutputFileFromData(this.path, this.contents, this.type);
|
|
265
267
|
},
|
|
@@ -276,27 +278,12 @@ function convertOutputFile(file, type) {
|
|
|
276
278
|
get text() {
|
|
277
279
|
return Buffer.from(this.contents.buffer, this.contents.byteOffset, this.contents.byteLength).toString('utf-8');
|
|
278
280
|
},
|
|
279
|
-
get fullOutputPath() {
|
|
280
|
-
return getFullOutputPath(this);
|
|
281
|
-
},
|
|
282
281
|
clone() {
|
|
283
282
|
return convertOutputFile(this, this.type);
|
|
284
283
|
},
|
|
285
284
|
};
|
|
286
285
|
}
|
|
287
286
|
exports.convertOutputFile = convertOutputFile;
|
|
288
|
-
function getFullOutputPath(file) {
|
|
289
|
-
switch (file.type) {
|
|
290
|
-
case bundler_context_1.BuildOutputFileType.Browser:
|
|
291
|
-
case bundler_context_1.BuildOutputFileType.Media:
|
|
292
|
-
return (0, node_path_1.join)('browser', file.path);
|
|
293
|
-
case bundler_context_1.BuildOutputFileType.Server:
|
|
294
|
-
return (0, node_path_1.join)('server', file.path);
|
|
295
|
-
default:
|
|
296
|
-
return file.path;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
exports.getFullOutputPath = getFullOutputPath;
|
|
300
287
|
/**
|
|
301
288
|
* Transform browserlists result to esbuild target.
|
|
302
289
|
* @see https://esbuild.github.io/api/#target
|
|
@@ -6,33 +6,10 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
10
|
exports.IndexHtmlGenerator = void 0;
|
|
34
|
-
const
|
|
35
|
-
const
|
|
11
|
+
const promises_1 = require("node:fs/promises");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
36
13
|
const strip_bom_1 = require("../strip-bom");
|
|
37
14
|
const augment_index_html_1 = require("./augment-index-html");
|
|
38
15
|
const inline_critical_css_1 = require("./inline-critical-css");
|
|
@@ -85,10 +62,20 @@ class IndexHtmlGenerator {
|
|
|
85
62
|
};
|
|
86
63
|
}
|
|
87
64
|
async readAsset(path) {
|
|
88
|
-
|
|
65
|
+
try {
|
|
66
|
+
return await (0, promises_1.readFile)(path, 'utf-8');
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
throw new Error(`Failed to read asset "${path}".`);
|
|
70
|
+
}
|
|
89
71
|
}
|
|
90
72
|
async readIndex(path) {
|
|
91
|
-
|
|
73
|
+
try {
|
|
74
|
+
return await (0, promises_1.readFile)(path, 'utf-8');
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Error(`Failed to read index HTML file "${path}".`);
|
|
78
|
+
}
|
|
92
79
|
}
|
|
93
80
|
}
|
|
94
81
|
exports.IndexHtmlGenerator = IndexHtmlGenerator;
|
|
@@ -104,7 +91,7 @@ function augmentIndexHtmlPlugin(generator) {
|
|
|
104
91
|
sri,
|
|
105
92
|
lang,
|
|
106
93
|
entrypoints,
|
|
107
|
-
loadOutputFile: (filePath) => generator.readAsset((0,
|
|
94
|
+
loadOutputFile: (filePath) => generator.readAsset((0, node_path_1.join)(outputPath, filePath)),
|
|
108
95
|
imageDomains,
|
|
109
96
|
files,
|
|
110
97
|
hints,
|
package/src/utils/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
export * from './default-progress';
|
|
9
9
|
export * from './delete-output-dir';
|
|
10
10
|
export * from './run-module-as-observable-fork';
|
|
11
|
+
export * from './load-proxy-config';
|
|
11
12
|
export * from './normalize-file-replacements';
|
|
12
13
|
export * from './normalize-asset-patterns';
|
|
13
14
|
export * from './normalize-source-maps';
|
package/src/utils/index.js
CHANGED
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
__exportStar(require("./default-progress"), exports);
|
|
25
25
|
__exportStar(require("./delete-output-dir"), exports);
|
|
26
26
|
__exportStar(require("./run-module-as-observable-fork"), exports);
|
|
27
|
+
__exportStar(require("./load-proxy-config"), exports);
|
|
27
28
|
__exportStar(require("./normalize-file-replacements"), exports);
|
|
28
29
|
__exportStar(require("./normalize-asset-patterns"), exports);
|
|
29
30
|
__exportStar(require("./normalize-source-maps"), exports);
|
|
@@ -37,8 +37,8 @@ const promises_1 = require("node:fs/promises");
|
|
|
37
37
|
const node_path_1 = require("node:path");
|
|
38
38
|
const node_url_1 = require("node:url");
|
|
39
39
|
const picomatch_1 = require("picomatch");
|
|
40
|
-
const error_1 = require("
|
|
41
|
-
const load_esm_1 = require("
|
|
40
|
+
const error_1 = require("./error");
|
|
41
|
+
const load_esm_1 = require("./load-esm");
|
|
42
42
|
async function loadProxyConfiguration(root, proxyConfig, normalize = false) {
|
|
43
43
|
if (!proxyConfig) {
|
|
44
44
|
return undefined;
|
|
File without changes
|