@angular-devkit/build-angular 17.1.0-next.1 → 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 +18 -18
- package/src/builders/application/build-action.d.ts +4 -3
- package/src/builders/application/build-action.js +24 -14
- 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/builder-status-warnings.js +1 -3
- package/src/builders/browser-esbuild/index.js +8 -4
- package/src/builders/dev-server/builder.js +5 -0
- package/src/builders/dev-server/vite-server.js +16 -16
- package/src/builders/karma/index.js +4 -1
- package/src/builders/karma/schema.d.ts +6 -2
- package/src/builders/karma/schema.json +12 -2
- package/src/builders/ssr-dev-server/index.js +17 -31
- package/src/tools/esbuild/angular/angular-host.js +7 -1
- package/src/tools/esbuild/angular/compiler-plugin.js +11 -27
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +3 -6
- package/src/tools/esbuild/angular/component-stylesheets.js +42 -47
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +2 -1
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +16 -16
- package/src/tools/esbuild/angular/source-file-cache.js +0 -1
- 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 +5 -3
- package/src/tools/esbuild/global-styles.js +4 -2
- package/src/tools/esbuild/index-html-generator.js +3 -1
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +4 -1
- package/src/tools/esbuild/stylesheets/bundle-options.js +11 -6
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
- 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/tools/esbuild/watcher.js +56 -121
- package/src/utils/check-port.js +15 -29
- package/src/utils/delete-output-dir.d.ts +1 -1
- package/src/utils/delete-output-dir.js +11 -2
- package/src/utils/index-file/index-html-generator.js +15 -28
- package/src/utils/index-file/inline-fonts.d.ts +6 -1
- package/src/utils/index-file/inline-fonts.js +30 -14
- 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/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +6 -5
- package/src/tools/esbuild/normalize-path.d.ts +0 -8
- package/src/tools/esbuild/normalize-path.js +0 -22
- /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,10 +6,12 @@
|
|
|
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 __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.createWatcher = exports.ChangedFiles = void 0;
|
|
11
|
-
const
|
|
12
|
-
const node_path_1 = require("node:path");
|
|
14
|
+
const watchpack_1 = __importDefault(require("watchpack"));
|
|
13
15
|
class ChangedFiles {
|
|
14
16
|
added = new Set();
|
|
15
17
|
modified = new Set();
|
|
@@ -28,87 +30,40 @@ class ChangedFiles {
|
|
|
28
30
|
}
|
|
29
31
|
exports.ChangedFiles = ChangedFiles;
|
|
30
32
|
function createWatcher(options) {
|
|
31
|
-
const watcher = new
|
|
32
|
-
|
|
33
|
-
interval: options?.interval,
|
|
33
|
+
const watcher = new watchpack_1.default({
|
|
34
|
+
poll: options?.polling ? options?.interval ?? true : false,
|
|
34
35
|
ignored: options?.ignored,
|
|
35
36
|
followSymlinks: options?.followSymlinks,
|
|
36
|
-
|
|
37
|
-
ignoreInitial: true,
|
|
37
|
+
aggregateTimeout: 250,
|
|
38
38
|
});
|
|
39
|
+
const watchedFiles = new Set();
|
|
39
40
|
const nextQueue = [];
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Example:
|
|
46
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
47
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
48
|
-
* change | 'C:/../src/app/app.component.css'
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
let currentEvents;
|
|
52
|
-
/**
|
|
53
|
-
* Using `watcher.on('all')` does not capture some of events fired when using Visual studio and this does not happen all the time,
|
|
54
|
-
* but only after a file has been changed 3 or more times.
|
|
55
|
-
*
|
|
56
|
-
* Also, some IDEs such as Visual Studio (not VS Code) will fire a rename event instead of unlink when a file is renamed or changed.
|
|
57
|
-
*
|
|
58
|
-
* Example:
|
|
59
|
-
* ```
|
|
60
|
-
* watcher.on('raw')
|
|
61
|
-
* Change 1
|
|
62
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
63
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
64
|
-
* change | 'C:/../src/app/app.component.css'
|
|
65
|
-
*
|
|
66
|
-
* Change 2
|
|
67
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
68
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
69
|
-
* change | 'C:/../src/app/app.component.css'
|
|
70
|
-
*
|
|
71
|
-
* Change 3
|
|
72
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
73
|
-
* rename | 'C:/../src/app/app.component.css'
|
|
74
|
-
* change | 'C:/../src/app/app.component.css'
|
|
75
|
-
*
|
|
76
|
-
* watcher.on('all')
|
|
77
|
-
* Change 1
|
|
78
|
-
* change | 'C:\\..\\src\\app\\app.component.css'
|
|
79
|
-
*
|
|
80
|
-
* Change 2
|
|
81
|
-
* unlink | 'C:\\..\\src\\app\\app.component.css'
|
|
82
|
-
*
|
|
83
|
-
* Change 3
|
|
84
|
-
* ... (Nothing)
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
watcher
|
|
88
|
-
.on('raw', (event, path, { watchedPath }) => {
|
|
89
|
-
if (watchedPath && !(0, node_path_1.extname)(watchedPath)) {
|
|
90
|
-
// Ignore directories, file changes in directories will be fired seperatly.
|
|
91
|
-
return;
|
|
41
|
+
let currentChangedFiles;
|
|
42
|
+
watcher.on('aggregated', (changes, removals) => {
|
|
43
|
+
const changedFiles = currentChangedFiles ?? new ChangedFiles();
|
|
44
|
+
for (const file of changes) {
|
|
45
|
+
changedFiles.modified.add(file);
|
|
92
46
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
case 'change':
|
|
96
|
-
// When polling is enabled `watchedPath` can be undefined.
|
|
97
|
-
// `path` is always normalized unlike `watchedPath`.
|
|
98
|
-
const changedPath = watchedPath ? (0, node_path_1.normalize)(watchedPath) : path;
|
|
99
|
-
handleFileChange(event, changedPath);
|
|
100
|
-
break;
|
|
47
|
+
for (const file of removals) {
|
|
48
|
+
changedFiles.removed.add(file);
|
|
101
49
|
}
|
|
102
|
-
|
|
103
|
-
|
|
50
|
+
const next = nextQueue.shift();
|
|
51
|
+
if (next) {
|
|
52
|
+
currentChangedFiles = undefined;
|
|
53
|
+
next(changedFiles);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
currentChangedFiles = changedFiles;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
104
59
|
return {
|
|
105
60
|
[Symbol.asyncIterator]() {
|
|
106
61
|
return this;
|
|
107
62
|
},
|
|
108
63
|
async next() {
|
|
109
|
-
if (
|
|
110
|
-
const result = { value:
|
|
111
|
-
|
|
64
|
+
if (currentChangedFiles && nextQueue.length === 0) {
|
|
65
|
+
const result = { value: currentChangedFiles };
|
|
66
|
+
currentChangedFiles = undefined;
|
|
112
67
|
return result;
|
|
113
68
|
}
|
|
114
69
|
return new Promise((resolve) => {
|
|
@@ -116,17 +71,40 @@ function createWatcher(options) {
|
|
|
116
71
|
});
|
|
117
72
|
},
|
|
118
73
|
add(paths) {
|
|
119
|
-
|
|
74
|
+
const previousSize = watchedFiles.size;
|
|
75
|
+
if (typeof paths === 'string') {
|
|
76
|
+
watchedFiles.add(paths);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
for (const file of paths) {
|
|
80
|
+
watchedFiles.add(file);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (previousSize !== watchedFiles.size) {
|
|
84
|
+
watcher.watch({
|
|
85
|
+
files: watchedFiles,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
120
88
|
},
|
|
121
89
|
remove(paths) {
|
|
122
|
-
|
|
90
|
+
const previousSize = watchedFiles.size;
|
|
91
|
+
if (typeof paths === 'string') {
|
|
92
|
+
watchedFiles.delete(paths);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
for (const file of paths) {
|
|
96
|
+
watchedFiles.delete(file);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (previousSize !== watchedFiles.size) {
|
|
100
|
+
watcher.watch({
|
|
101
|
+
files: watchedFiles,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
123
104
|
},
|
|
124
105
|
async close() {
|
|
125
106
|
try {
|
|
126
|
-
|
|
127
|
-
if (nextWaitTimeout) {
|
|
128
|
-
clearTimeout(nextWaitTimeout);
|
|
129
|
-
}
|
|
107
|
+
watcher.close();
|
|
130
108
|
}
|
|
131
109
|
finally {
|
|
132
110
|
let next;
|
|
@@ -136,48 +114,5 @@ function createWatcher(options) {
|
|
|
136
114
|
}
|
|
137
115
|
},
|
|
138
116
|
};
|
|
139
|
-
function handleFileChange(event, path) {
|
|
140
|
-
switch (event) {
|
|
141
|
-
case 'add':
|
|
142
|
-
case 'change':
|
|
143
|
-
// When using Visual Studio the rename event is fired before a change event when the contents of the file changed
|
|
144
|
-
// or instead of `unlink` when the file has been renamed.
|
|
145
|
-
case 'unlink':
|
|
146
|
-
case 'rename':
|
|
147
|
-
currentEvents ??= new Map();
|
|
148
|
-
currentEvents.set(path, event);
|
|
149
|
-
break;
|
|
150
|
-
default:
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
// Wait 250ms from next change to better capture groups of file save operations.
|
|
154
|
-
if (!nextWaitTimeout) {
|
|
155
|
-
nextWaitTimeout = setTimeout(() => {
|
|
156
|
-
nextWaitTimeout = undefined;
|
|
157
|
-
const next = nextQueue.shift();
|
|
158
|
-
if (next && currentEvents) {
|
|
159
|
-
const events = currentEvents;
|
|
160
|
-
currentEvents = undefined;
|
|
161
|
-
const currentChanges = new ChangedFiles();
|
|
162
|
-
for (const [path, event] of events) {
|
|
163
|
-
switch (event) {
|
|
164
|
-
case 'add':
|
|
165
|
-
currentChanges.added.add(path);
|
|
166
|
-
break;
|
|
167
|
-
case 'change':
|
|
168
|
-
currentChanges.modified.add(path);
|
|
169
|
-
break;
|
|
170
|
-
case 'unlink':
|
|
171
|
-
case 'rename':
|
|
172
|
-
currentChanges.removed.add(path);
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
next(currentChanges);
|
|
177
|
-
}
|
|
178
|
-
}, 250);
|
|
179
|
-
nextWaitTimeout?.unref();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
117
|
}
|
|
183
118
|
exports.createWatcher = createWatcher;
|
package/src/utils/check-port.js
CHANGED
|
@@ -6,43 +6,26 @@
|
|
|
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
|
|
10
|
-
|
|
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;
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
11
|
};
|
|
32
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
13
|
exports.checkPort = void 0;
|
|
34
|
-
const
|
|
14
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
|
+
const node_net_1 = require("node:net");
|
|
35
16
|
const load_esm_1 = require("./load-esm");
|
|
36
17
|
const tty_1 = require("./tty");
|
|
37
18
|
function createInUseError(port) {
|
|
38
19
|
return new Error(`Port ${port} is already in use. Use '--port' to specify a different port.`);
|
|
39
20
|
}
|
|
40
21
|
async function checkPort(port, host) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
// Disabled due to Vite not handling port 0 and instead always using the default value (5173)
|
|
23
|
+
// TODO: Enable this again once Vite is fixed
|
|
24
|
+
// if (port === 0) {
|
|
25
|
+
// return 0;
|
|
26
|
+
// }
|
|
44
27
|
return new Promise((resolve, reject) => {
|
|
45
|
-
const server =
|
|
28
|
+
const server = (0, node_net_1.createServer)();
|
|
46
29
|
server
|
|
47
30
|
.once('error', (err) => {
|
|
48
31
|
if (err.code !== 'EADDRINUSE') {
|
|
@@ -60,11 +43,14 @@ async function checkPort(port, host) {
|
|
|
60
43
|
message: `Port ${port} is already in use.\nWould you like to use a different port?`,
|
|
61
44
|
default: true,
|
|
62
45
|
}))
|
|
63
|
-
.then((answers) =>
|
|
46
|
+
.then((answers) => answers.useDifferent ? resolve(checkPort(0, host)) : reject(createInUseError(port)), () => reject(createInUseError(port)));
|
|
64
47
|
})
|
|
65
48
|
.once('listening', () => {
|
|
49
|
+
// Get the actual address from the listening server instance
|
|
50
|
+
const address = server.address();
|
|
51
|
+
(0, node_assert_1.default)(address && typeof address !== 'string', 'Port check server address should always be an object.');
|
|
66
52
|
server.close();
|
|
67
|
-
resolve(port);
|
|
53
|
+
resolve(address.port);
|
|
68
54
|
})
|
|
69
55
|
.listen(port, host);
|
|
70
56
|
});
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Delete an output directory, but error out if it's the root of the project.
|
|
10
10
|
*/
|
|
11
|
-
export declare function deleteOutputDir(root: string, outputPath: string): Promise<void>;
|
|
11
|
+
export declare function deleteOutputDir(root: string, outputPath: string, emptyOnlyDirectories?: string[]): Promise<void>;
|
|
@@ -13,11 +13,14 @@ const node_path_1 = require("node:path");
|
|
|
13
13
|
/**
|
|
14
14
|
* Delete an output directory, but error out if it's the root of the project.
|
|
15
15
|
*/
|
|
16
|
-
async function deleteOutputDir(root, outputPath) {
|
|
16
|
+
async function deleteOutputDir(root, outputPath, emptyOnlyDirectories) {
|
|
17
17
|
const resolvedOutputPath = (0, node_path_1.resolve)(root, outputPath);
|
|
18
18
|
if (resolvedOutputPath === root) {
|
|
19
19
|
throw new Error('Output path MUST not be project root directory!');
|
|
20
20
|
}
|
|
21
|
+
const directoriesToEmpty = emptyOnlyDirectories
|
|
22
|
+
? new Set(emptyOnlyDirectories.map((directory) => (0, node_path_1.join)(resolvedOutputPath, directory)))
|
|
23
|
+
: undefined;
|
|
21
24
|
// Avoid removing the actual directory to avoid errors in cases where the output
|
|
22
25
|
// directory is mounted or symlinked. Instead the contents are removed.
|
|
23
26
|
let entries;
|
|
@@ -31,7 +34,13 @@ async function deleteOutputDir(root, outputPath) {
|
|
|
31
34
|
throw error;
|
|
32
35
|
}
|
|
33
36
|
for (const entry of entries) {
|
|
34
|
-
|
|
37
|
+
const fullEntry = (0, node_path_1.join)(resolvedOutputPath, entry);
|
|
38
|
+
// Leave requested directories. This allows symlinks to continue to function.
|
|
39
|
+
if (directoriesToEmpty?.has(fullEntry)) {
|
|
40
|
+
await deleteOutputDir(resolvedOutputPath, fullEntry);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
await (0, promises_1.rm)(fullEntry, { force: true, recursive: true, maxRetries: 3 });
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
exports.deleteOutputDir = deleteOutputDir;
|
|
@@ -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,
|
|
@@ -5,6 +5,10 @@
|
|
|
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
|
+
/// <reference types="node" />
|
|
9
|
+
/// <reference types="@types/node/url" />
|
|
10
|
+
/// <reference types="@types/node/ts4.8/url" />
|
|
11
|
+
import { URL } from 'node:url';
|
|
8
12
|
import { NormalizedCachedOptions } from '../normalize-cache';
|
|
9
13
|
export interface InlineFontsOptions {
|
|
10
14
|
minify?: boolean;
|
|
@@ -16,7 +20,8 @@ export declare class InlineFontsProcessor {
|
|
|
16
20
|
constructor(options: InlineFontsOptions);
|
|
17
21
|
process(content: string): Promise<string>;
|
|
18
22
|
private getResponse;
|
|
19
|
-
|
|
23
|
+
processURL(url: string | URL): Promise<string | undefined>;
|
|
24
|
+
canInlineRequest(url: string): boolean;
|
|
20
25
|
private getFontProviderDetails;
|
|
21
26
|
private createNormalizedUrl;
|
|
22
27
|
}
|