@angular-devkit/build-angular 17.0.6 → 17.0.7
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 +5 -5
- package/src/builders/application/build-action.js +14 -10
- package/src/builders/browser-esbuild/builder-status-warnings.js +1 -3
- package/src/builders/dev-server/builder.js +5 -0
- package/src/builders/dev-server/vite-server.js +10 -3
- package/src/tools/esbuild/angular/compiler-plugin.js +1 -1
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +2 -1
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +15 -15
- package/src/tools/esbuild/angular/source-file-cache.js +0 -1
- 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/inline-fonts.js +10 -1
- 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/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.7",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.2.1",
|
|
10
|
-
"@angular-devkit/architect": "0.1700.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1700.
|
|
12
|
-
"@angular-devkit/core": "17.0.
|
|
10
|
+
"@angular-devkit/architect": "0.1700.7",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1700.7",
|
|
12
|
+
"@angular-devkit/core": "17.0.7",
|
|
13
13
|
"@babel/core": "7.23.2",
|
|
14
14
|
"@babel/generator": "7.23.0",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.22.5",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/preset-env": "7.23.2",
|
|
21
21
|
"@babel/runtime": "7.23.2",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "17.0.
|
|
23
|
+
"@ngtools/webpack": "17.0.7",
|
|
24
24
|
"@vitejs/plugin-basic-ssl": "1.0.1",
|
|
25
25
|
"ansi-colors": "4.1.3",
|
|
26
26
|
"autoprefixer": "10.4.16",
|
|
@@ -42,7 +42,7 @@ const environment_options_1 = require("../../utils/environment-options");
|
|
|
42
42
|
async function* runEsBuildBuildAction(action, options) {
|
|
43
43
|
const { writeToFileSystemFilter, writeToFileSystem = true, watch, poll, logger, deleteOutputPath, cacheOptions, outputPath, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, } = options;
|
|
44
44
|
if (deleteOutputPath && writeToFileSystem) {
|
|
45
|
-
await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputPath);
|
|
45
|
+
await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputPath, ['browser', 'server']);
|
|
46
46
|
}
|
|
47
47
|
const withProgress = progress ? utils_1.withSpinner : utils_1.withNoProgress;
|
|
48
48
|
// Initial build
|
|
@@ -62,21 +62,25 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
62
62
|
if (progress) {
|
|
63
63
|
logger.info('Watch mode enabled. Watching for file changes...');
|
|
64
64
|
}
|
|
65
|
+
const ignored = [
|
|
66
|
+
// Ignore the output and cache paths to avoid infinite rebuild cycles
|
|
67
|
+
outputPath,
|
|
68
|
+
cacheOptions.basePath,
|
|
69
|
+
`${workspaceRoot.replace(/\\/g, '/')}/**/.*/**`,
|
|
70
|
+
];
|
|
71
|
+
if (!preserveSymlinks) {
|
|
72
|
+
// Ignore all node modules directories to avoid excessive file watchers.
|
|
73
|
+
// Package changes are handled below by watching manifest and lock files.
|
|
74
|
+
// NOTE: this is not enable when preserveSymlinks is true as this would break `npm link` usages.
|
|
75
|
+
ignored.push('**/node_modules/**');
|
|
76
|
+
}
|
|
65
77
|
// Setup a watcher
|
|
66
78
|
const { createWatcher } = await Promise.resolve().then(() => __importStar(require('../../tools/esbuild/watcher')));
|
|
67
79
|
watcher = createWatcher({
|
|
68
80
|
polling: typeof poll === 'number',
|
|
69
81
|
interval: poll,
|
|
70
82
|
followSymlinks: preserveSymlinks,
|
|
71
|
-
ignored
|
|
72
|
-
// Ignore the output and cache paths to avoid infinite rebuild cycles
|
|
73
|
-
outputPath,
|
|
74
|
-
cacheOptions.basePath,
|
|
75
|
-
// Ignore all node modules directories to avoid excessive file watchers.
|
|
76
|
-
// Package changes are handled below by watching manifest and lock files.
|
|
77
|
-
'**/node_modules/**',
|
|
78
|
-
`${workspaceRoot.replace(/\\/g, '/')}/**/.*/**`,
|
|
79
|
-
],
|
|
83
|
+
ignored,
|
|
80
84
|
});
|
|
81
85
|
// Setup abort support
|
|
82
86
|
options.signal?.addEventListener('abort', () => void watcher?.close());
|
|
@@ -30,9 +30,7 @@ function logBuilderStatusWarnings(options, { logger }) {
|
|
|
30
30
|
if (typeof value === 'object' && Object.keys(value).length === 0) {
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
|
-
if (unsupportedOption === 'vendorChunk' ||
|
|
34
|
-
unsupportedOption === 'resourcesOutputPath' ||
|
|
35
|
-
unsupportedOption === 'deployUrl') {
|
|
33
|
+
if (unsupportedOption === 'vendorChunk' || unsupportedOption === 'resourcesOutputPath') {
|
|
36
34
|
logger.warn(`The '${unsupportedOption}' option is not used by this builder and will be ignored.`);
|
|
37
35
|
continue;
|
|
38
36
|
}
|
|
@@ -65,6 +65,11 @@ function execute(options, context, transforms = {}, extensions) {
|
|
|
65
65
|
if (transforms?.logging || transforms?.webpackConfiguration) {
|
|
66
66
|
throw new Error('The `application` and `browser-esbuild` builders do not support Webpack transforms.');
|
|
67
67
|
}
|
|
68
|
+
if (normalizedOptions.forceEsbuild &&
|
|
69
|
+
builderName === '@angular-devkit/build-angular:browser') {
|
|
70
|
+
// The compatibility builder should be used if esbuild is force enabled with the official Webpack-based builder.
|
|
71
|
+
builderName = '@angular-devkit/build-angular:browser-esbuild';
|
|
72
|
+
}
|
|
68
73
|
return (0, rxjs_1.defer)(() => Promise.resolve().then(() => __importStar(require('./vite-server')))).pipe((0, rxjs_1.switchMap)(({ serveWithVite }) => serveWithVite(normalizedOptions, builderName, context, transforms, extensions)));
|
|
69
74
|
}
|
|
70
75
|
if (extensions?.buildPlugins?.length) {
|
|
@@ -73,8 +73,11 @@ async function* serveWithVite(serverOptions, builderName, context, transformers,
|
|
|
73
73
|
}
|
|
74
74
|
// Set all packages as external to support Vite's prebundle caching
|
|
75
75
|
browserOptions.externalPackages = serverOptions.cacheOptions.enabled;
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const baseHref = browserOptions.baseHref;
|
|
77
|
+
if (serverOptions.servePath === undefined && baseHref !== undefined) {
|
|
78
|
+
// Remove trailing slash
|
|
79
|
+
serverOptions.servePath =
|
|
80
|
+
baseHref[baseHref.length - 1] === '/' ? baseHref.slice(0, -1) : baseHref;
|
|
78
81
|
}
|
|
79
82
|
// The development server currently only supports a single locale when localizing.
|
|
80
83
|
// This matches the behavior of the Webpack-based development server but could be expanded in the future.
|
|
@@ -329,7 +332,7 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
329
332
|
css: {
|
|
330
333
|
devSourcemap: true,
|
|
331
334
|
},
|
|
332
|
-
// Vite will normalize the `base` option by adding a leading
|
|
335
|
+
// Vite will normalize the `base` option by adding a leading slash.
|
|
333
336
|
base: serverOptions.servePath,
|
|
334
337
|
resolve: {
|
|
335
338
|
mainFields: ['es2020', 'browser', 'module', 'main'],
|
|
@@ -449,6 +452,10 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
449
452
|
// Rewrite all build assets to a vite raw fs URL
|
|
450
453
|
const assetSourcePath = assets.get(pathname);
|
|
451
454
|
if (assetSourcePath !== undefined) {
|
|
455
|
+
// Workaround to disable Vite transformer middleware.
|
|
456
|
+
// See: https://github.com/vitejs/vite/blob/746a1daab0395f98f0afbdee8f364cb6cf2f3b3f/packages/vite/src/node/server/middlewares/transform.ts#L201 and
|
|
457
|
+
// https://github.com/vitejs/vite/blob/746a1daab0395f98f0afbdee8f364cb6cf2f3b3f/packages/vite/src/node/server/transformRequest.ts#L204-L206
|
|
458
|
+
req.headers.accept = 'text/html';
|
|
452
459
|
// The encoding needs to match what happens in the vite static middleware.
|
|
453
460
|
// ref: https://github.com/vitejs/vite/blob/d4f13bd81468961c8c926438e815ab6b1c82735e/packages/vite/src/node/server/middlewares/static.ts#L163
|
|
454
461
|
req.url = `${server.config.base}@fs/${encodeURI(assetSourcePath)}`;
|
|
@@ -308,7 +308,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
308
308
|
}));
|
|
309
309
|
// Setup bundling of component templates and stylesheets when in JIT mode
|
|
310
310
|
if (pluginOptions.jit) {
|
|
311
|
-
(0, jit_plugin_callbacks_1.setupJitPluginCallbacks)(build, stylesheetBundler, additionalResults, styleOptions.inlineStyleLanguage);
|
|
311
|
+
(0, jit_plugin_callbacks_1.setupJitPluginCallbacks)(build, stylesheetBundler, additionalResults, styleOptions.inlineStyleLanguage, pluginOptions.loadResultCache);
|
|
312
312
|
}
|
|
313
313
|
build.onEnd((result) => {
|
|
314
314
|
// Ensure other compilations are unblocked if the main compilation throws during start
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import type { Metafile, OutputFile, PluginBuild } from 'esbuild';
|
|
9
|
+
import { LoadResultCache } from '../load-result-cache';
|
|
9
10
|
import { ComponentStylesheetBundler } from './component-stylesheets';
|
|
10
11
|
/**
|
|
11
12
|
* Sets up esbuild resolve and load callbacks to support Angular JIT mode processing
|
|
@@ -19,4 +20,4 @@ import { ComponentStylesheetBundler } from './component-stylesheets';
|
|
|
19
20
|
export declare function setupJitPluginCallbacks(build: PluginBuild, stylesheetBundler: ComponentStylesheetBundler, additionalResultFiles: Map<string, {
|
|
20
21
|
outputFiles?: OutputFile[];
|
|
21
22
|
metafile?: Metafile;
|
|
22
|
-
}>, inlineStyleLanguage: string): void;
|
|
23
|
+
}>, inlineStyleLanguage: string, loadCache?: LoadResultCache): void;
|
|
@@ -6,13 +6,11 @@
|
|
|
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
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.setupJitPluginCallbacks = void 0;
|
|
14
11
|
const promises_1 = require("node:fs/promises");
|
|
15
|
-
const node_path_1 =
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
const load_result_cache_1 = require("../load-result-cache");
|
|
16
14
|
const uri_1 = require("./uri");
|
|
17
15
|
/**
|
|
18
16
|
* Loads/extracts the contents from a load callback Angular JIT entry.
|
|
@@ -27,7 +25,7 @@ const uri_1 = require("./uri");
|
|
|
27
25
|
*/
|
|
28
26
|
async function loadEntry(entry, root, skipRead) {
|
|
29
27
|
if (entry.startsWith('file:')) {
|
|
30
|
-
const specifier = node_path_1.
|
|
28
|
+
const specifier = (0, node_path_1.join)(root, entry.slice(5));
|
|
31
29
|
return {
|
|
32
30
|
path: specifier,
|
|
33
31
|
contents: skipRead ? undefined : await (0, promises_1.readFile)(specifier, 'utf-8'),
|
|
@@ -36,7 +34,7 @@ async function loadEntry(entry, root, skipRead) {
|
|
|
36
34
|
else if (entry.startsWith('inline:')) {
|
|
37
35
|
const [importer, data] = entry.slice(7).split(';', 2);
|
|
38
36
|
return {
|
|
39
|
-
path: node_path_1.
|
|
37
|
+
path: (0, node_path_1.join)(root, importer),
|
|
40
38
|
contents: Buffer.from(data, 'base64').toString(),
|
|
41
39
|
};
|
|
42
40
|
}
|
|
@@ -53,7 +51,7 @@ async function loadEntry(entry, root, skipRead) {
|
|
|
53
51
|
* @param styleOptions The options to use when bundling stylesheets.
|
|
54
52
|
* @param additionalResultFiles A Map where stylesheet resources will be added.
|
|
55
53
|
*/
|
|
56
|
-
function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles, inlineStyleLanguage) {
|
|
54
|
+
function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles, inlineStyleLanguage, loadCache) {
|
|
57
55
|
const root = build.initialOptions.absWorkingDir ?? '';
|
|
58
56
|
// Add a resolve callback to capture and parse any JIT URIs that were added by the
|
|
59
57
|
// JIT resource TypeScript transformer.
|
|
@@ -68,13 +66,13 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
|
|
|
68
66
|
return {
|
|
69
67
|
// Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
|
|
70
68
|
// This is only necessary for custom namespaces. esbuild will handle the file namespace.
|
|
71
|
-
path: 'file:' + node_path_1.
|
|
69
|
+
path: 'file:' + (0, node_path_1.relative)(root, (0, node_path_1.join)((0, node_path_1.dirname)(args.importer), specifier)),
|
|
72
70
|
namespace,
|
|
73
71
|
};
|
|
74
72
|
}
|
|
75
73
|
else {
|
|
76
74
|
// Inline data may need the importer to resolve imports/references within the content
|
|
77
|
-
const importer = node_path_1.
|
|
75
|
+
const importer = (0, node_path_1.relative)(root, args.importer);
|
|
78
76
|
return {
|
|
79
77
|
path: `inline:${importer};${specifier}`,
|
|
80
78
|
namespace,
|
|
@@ -82,7 +80,7 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
|
|
|
82
80
|
}
|
|
83
81
|
});
|
|
84
82
|
// Add a load callback to handle Component stylesheets (both inline and external)
|
|
85
|
-
build.onLoad({ filter: /./, namespace: uri_1.JIT_STYLE_NAMESPACE }, async (args) => {
|
|
83
|
+
build.onLoad({ filter: /./, namespace: uri_1.JIT_STYLE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
|
|
86
84
|
// skipRead is used here because the stylesheet bundling will read a file stylesheet
|
|
87
85
|
// directly either via a preprocessor or esbuild itself.
|
|
88
86
|
const entry = await loadEntry(args.path, root, true /* skipRead */);
|
|
@@ -94,24 +92,26 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
|
|
|
94
92
|
else {
|
|
95
93
|
stylesheetResult = await stylesheetBundler.bundleInline(entry.contents, entry.path, inlineStyleLanguage);
|
|
96
94
|
}
|
|
97
|
-
const { contents, resourceFiles, errors, warnings, metafile } = stylesheetResult;
|
|
95
|
+
const { contents, resourceFiles, errors, warnings, metafile, referencedFiles } = stylesheetResult;
|
|
98
96
|
additionalResultFiles.set(entry.path, { outputFiles: resourceFiles, metafile });
|
|
99
97
|
return {
|
|
100
98
|
errors,
|
|
101
99
|
warnings,
|
|
102
100
|
contents,
|
|
103
101
|
loader: 'text',
|
|
102
|
+
watchFiles: referencedFiles && [...referencedFiles],
|
|
104
103
|
};
|
|
105
|
-
});
|
|
104
|
+
}));
|
|
106
105
|
// Add a load callback to handle Component templates
|
|
107
106
|
// NOTE: While this callback supports both inline and external templates, the transformer
|
|
108
107
|
// currently only supports generating URIs for external templates.
|
|
109
|
-
build.onLoad({ filter: /./, namespace: uri_1.JIT_TEMPLATE_NAMESPACE }, async (args) => {
|
|
110
|
-
const { contents } = await loadEntry(args.path, root);
|
|
108
|
+
build.onLoad({ filter: /./, namespace: uri_1.JIT_TEMPLATE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
|
|
109
|
+
const { contents, path } = await loadEntry(args.path, root);
|
|
111
110
|
return {
|
|
112
111
|
contents,
|
|
113
112
|
loader: 'text',
|
|
113
|
+
watchFiles: [path],
|
|
114
114
|
};
|
|
115
|
-
});
|
|
115
|
+
}));
|
|
116
116
|
}
|
|
117
117
|
exports.setupJitPluginCallbacks = setupJitPluginCallbacks;
|
|
@@ -52,7 +52,6 @@ class SourceFileCache extends Map {
|
|
|
52
52
|
}
|
|
53
53
|
for (let file of files) {
|
|
54
54
|
file = path.normalize(file);
|
|
55
|
-
this.typeScriptFileCache.delete(file);
|
|
56
55
|
this.loadResultCache.invalidate(file);
|
|
57
56
|
// Normalize separators to allow matching TypeScript Host paths
|
|
58
57
|
if (USING_WINDOWS) {
|
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;
|
|
@@ -195,7 +195,16 @@ class InlineFontsProcessor {
|
|
|
195
195
|
.get(url, {
|
|
196
196
|
agent,
|
|
197
197
|
headers: {
|
|
198
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Always use a Windows UA. This is because Google fonts will including hinting in fonts for Windows.
|
|
200
|
+
* Hinting is a technique used with Windows files to improve appearance however
|
|
201
|
+
* results in 20-50% larger file sizes.
|
|
202
|
+
*
|
|
203
|
+
* @see http://google3/java/com/google/fonts/css/OpenSansWebFontsCssBuilder.java?l=22
|
|
204
|
+
* @see https://fonts.google.com/knowledge/glossary/hinting (short)
|
|
205
|
+
* @see https://glyphsapp.com/learn/hinting-manual-truetype-hinting (deep dive)
|
|
206
|
+
*/
|
|
207
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
199
208
|
},
|
|
200
209
|
}, (res) => {
|
|
201
210
|
if (res.statusCode !== 200) {
|
|
@@ -11,19 +11,20 @@ exports.getESMLoaderArgs = exports.callInitializeIfNeeded = void 0;
|
|
|
11
11
|
const node_path_1 = require("node:path");
|
|
12
12
|
const node_url_1 = require("node:url");
|
|
13
13
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const semver_1 = require("semver");
|
|
15
|
+
let SUPPORTS_IMPORT_FLAG;
|
|
16
|
+
function supportsImportFlag() {
|
|
17
|
+
return (SUPPORTS_IMPORT_FLAG ??= (0, semver_1.satisfies)(process.versions.node, '>= 18.19'));
|
|
17
18
|
}
|
|
18
19
|
/** Call the initialize hook when running on Node.js 18 */
|
|
19
20
|
function callInitializeIfNeeded(initialize) {
|
|
20
|
-
if (
|
|
21
|
+
if (!supportsImportFlag()) {
|
|
21
22
|
initialize(node_worker_threads_1.workerData);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.callInitializeIfNeeded = callInitializeIfNeeded;
|
|
25
26
|
function getESMLoaderArgs() {
|
|
26
|
-
if (
|
|
27
|
+
if (!supportsImportFlag()) {
|
|
27
28
|
return [
|
|
28
29
|
'--no-warnings',
|
|
29
30
|
'--loader',
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
export declare function normalizePath(path: string): string;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.normalizePath = void 0;
|
|
11
|
-
const node_os_1 = require("node:os");
|
|
12
|
-
const node_path_1 = require("node:path");
|
|
13
|
-
const USING_WINDOWS = (0, node_os_1.platform)() === 'win32';
|
|
14
|
-
function normalizePath(path) {
|
|
15
|
-
if (USING_WINDOWS) {
|
|
16
|
-
return (0, node_path_1.normalize)(path).toLowerCase();
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return (0, node_path_1.normalize)(path);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.normalizePath = normalizePath;
|