@angular/build 18.1.0 → 18.1.2
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 +2 -2
- package/src/builders/dev-server/vite-server.js +2 -0
- package/src/tools/esbuild/budget-stats.js +4 -1
- package/src/tools/esbuild/wasm-plugin.js +3 -3
- package/src/tools/sass/lexer.js +1 -1
- package/src/tools/vite/id-prefix-plugin.d.ts +9 -0
- package/src/tools/vite/id-prefix-plugin.js +44 -0
- package/src/tools/vite/middlewares/assets-middleware.js +2 -1
- package/src/tools/vite/middlewares/index-html-middleware.js +4 -2
- 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.1.
|
|
3
|
+
"version": "18.1.2",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.1801.
|
|
26
|
+
"@angular-devkit/architect": "0.1801.2",
|
|
27
27
|
"@babel/core": "7.24.7",
|
|
28
28
|
"@babel/helper-annotate-as-pure": "7.24.7",
|
|
29
29
|
"@babel/helper-split-export-declaration": "7.24.7",
|
|
@@ -42,6 +42,7 @@ const node_module_1 = require("node:module");
|
|
|
42
42
|
const node_path_1 = require("node:path");
|
|
43
43
|
const angular_memory_plugin_1 = require("../../tools/vite/angular-memory-plugin");
|
|
44
44
|
const i18n_locale_plugin_1 = require("../../tools/vite/i18n-locale-plugin");
|
|
45
|
+
const id_prefix_plugin_1 = require("../../tools/vite/id-prefix-plugin");
|
|
45
46
|
const utils_1 = require("../../utils");
|
|
46
47
|
const load_esm_1 = require("../../utils/load-esm");
|
|
47
48
|
const internal_1 = require("./internal");
|
|
@@ -441,6 +442,7 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
441
442
|
extensionMiddleware,
|
|
442
443
|
normalizePath,
|
|
443
444
|
}),
|
|
445
|
+
(0, id_prefix_plugin_1.createRemoveIdPrefixPlugin)(externalMetadata.explicit),
|
|
444
446
|
],
|
|
445
447
|
// Browser only optimizeDeps. (This does not run for SSR dependencies).
|
|
446
448
|
optimizeDeps: getDepOptimizationConfig({
|
|
@@ -45,7 +45,10 @@ function generateBudgetStats(metafile, outputFiles, initialFiles) {
|
|
|
45
45
|
}
|
|
46
46
|
// Add component styles from metafile
|
|
47
47
|
// TODO: Provide this information directly from the AOT compiler
|
|
48
|
-
for (const entry of Object.
|
|
48
|
+
for (const [file, entry] of Object.entries(metafile.outputs)) {
|
|
49
|
+
if (!file.endsWith('.css')) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
49
52
|
// 'ng-component' is set by the angular plugin's component stylesheet bundler
|
|
50
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
54
|
const componentStyle = entry['ng-component'];
|
|
@@ -35,7 +35,7 @@ function createWasmPlugin(options) {
|
|
|
35
35
|
return {
|
|
36
36
|
name: 'angular-wasm',
|
|
37
37
|
setup(build) {
|
|
38
|
-
build.onResolve({ filter:
|
|
38
|
+
build.onResolve({ filter: /\.wasm$/ }, async (args) => {
|
|
39
39
|
// Skip if already resolving the WASM file to avoid infinite resolution
|
|
40
40
|
if (args.pluginData?.[WASM_RESOLVE_SYMBOL]) {
|
|
41
41
|
return;
|
|
@@ -75,7 +75,7 @@ function createWasmPlugin(options) {
|
|
|
75
75
|
namespace: WASM_INIT_NAMESPACE,
|
|
76
76
|
};
|
|
77
77
|
});
|
|
78
|
-
build.onLoad({ filter:
|
|
78
|
+
build.onLoad({ filter: /\.wasm$/, namespace: WASM_INIT_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
|
|
79
79
|
// Ensure async mode is supported
|
|
80
80
|
if (!allowAsync) {
|
|
81
81
|
return {
|
|
@@ -155,7 +155,7 @@ function createWasmPlugin(options) {
|
|
|
155
155
|
watchFiles: [args.path],
|
|
156
156
|
};
|
|
157
157
|
}));
|
|
158
|
-
build.onLoad({ filter:
|
|
158
|
+
build.onLoad({ filter: /\.wasm$/, namespace: WASM_CONTENTS_NAMESPACE }, async (args) => {
|
|
159
159
|
const contents = args.pluginData.wasmContents ?? (await (0, promises_1.readFile)(args.path));
|
|
160
160
|
let loader = 'file';
|
|
161
161
|
if (args.with.loader) {
|
package/src/tools/sass/lexer.js
CHANGED
|
@@ -50,7 +50,7 @@ function* findUrls(contents) {
|
|
|
50
50
|
if (pos > 0) {
|
|
51
51
|
pos -= 2;
|
|
52
52
|
next();
|
|
53
|
-
if (!isWhitespace(current) && current !==
|
|
53
|
+
if (!isWhitespace(current) && current !== 0x002c && current !== 0x003a) {
|
|
54
54
|
// Skip - not a url token
|
|
55
55
|
pos += 3;
|
|
56
56
|
continue;
|
|
@@ -0,0 +1,9 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Plugin } from 'vite';
|
|
9
|
+
export declare const createRemoveIdPrefixPlugin: (externals: string[]) => Plugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createRemoveIdPrefixPlugin = void 0;
|
|
11
|
+
// NOTE: the implementation for this Vite plugin is roughly based on:
|
|
12
|
+
// https://github.com/MilanKovacic/vite-plugin-externalize-dependencies
|
|
13
|
+
const VITE_ID_PREFIX = '@id/';
|
|
14
|
+
const escapeRegexSpecialChars = (inputString) => {
|
|
15
|
+
return inputString.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
16
|
+
};
|
|
17
|
+
const createRemoveIdPrefixPlugin = (externals) => ({
|
|
18
|
+
name: 'vite-plugin-remove-id-prefix',
|
|
19
|
+
apply: 'serve',
|
|
20
|
+
configResolved: (resolvedConfig) => {
|
|
21
|
+
// don't do anything when the list of externals is empty
|
|
22
|
+
if (externals.length === 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const escapedExternals = externals.map(escapeRegexSpecialChars);
|
|
26
|
+
const prefixedExternalRegex = new RegExp(`${resolvedConfig.base}${VITE_ID_PREFIX}(${escapedExternals.join('|')})`, 'g');
|
|
27
|
+
// @ts-expect-error: Property 'push' does not exist on type 'readonly Plugin<any>[]'
|
|
28
|
+
// Reasoning:
|
|
29
|
+
// since the /@id/ prefix is added by Vite's import-analysis plugin,
|
|
30
|
+
// we must add our actual plugin dynamically, to ensure that it will run
|
|
31
|
+
// AFTER the import-analysis.
|
|
32
|
+
resolvedConfig.plugins.push({
|
|
33
|
+
name: 'vite-plugin-remove-id-prefix-transform',
|
|
34
|
+
transform: (code) => {
|
|
35
|
+
// don't do anything when code does not contain the Vite prefix
|
|
36
|
+
if (!code.includes(VITE_ID_PREFIX)) {
|
|
37
|
+
return code;
|
|
38
|
+
}
|
|
39
|
+
return code.replace(prefixedExternalRegex, (_, externalName) => externalName);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
exports.createRemoveIdPrefixPlugin = createRemoveIdPrefixPlugin;
|
|
@@ -69,7 +69,8 @@ function createAngularAssetsMiddleware(server, assets, outputFiles) {
|
|
|
69
69
|
if (!pathnameHasTrailingSlash) {
|
|
70
70
|
for (const assetPath of assets.keys()) {
|
|
71
71
|
if (pathname === assetPath.substring(0, assetPath.lastIndexOf('/'))) {
|
|
72
|
-
const
|
|
72
|
+
const { pathname, search, hash } = new URL(req.url, 'http://localhost');
|
|
73
|
+
const location = [pathname, '/', search, hash].join('');
|
|
73
74
|
res.statusCode = 301;
|
|
74
75
|
res.setHeader('Content-Type', 'text/html');
|
|
75
76
|
res.setHeader('Location', location);
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.createAngularIndexHtmlMiddleware = createAngularIndexHtmlMiddleware;
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
11
12
|
const utils_1 = require("../utils");
|
|
12
13
|
function createAngularIndexHtmlMiddleware(server, outputFiles, indexHtmlTransformer) {
|
|
13
14
|
return function (req, res, next) {
|
|
@@ -18,11 +19,12 @@ function createAngularIndexHtmlMiddleware(server, outputFiles, indexHtmlTransfor
|
|
|
18
19
|
// Parse the incoming request.
|
|
19
20
|
// The base of the URL is unused but required to parse the URL.
|
|
20
21
|
const pathname = (0, utils_1.pathnameWithoutBasePath)(req.url, server.config.base);
|
|
21
|
-
|
|
22
|
+
const extension = (0, node_path_1.extname)(pathname);
|
|
23
|
+
if (extension !== '.html') {
|
|
22
24
|
next();
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
|
-
const rawHtml = outputFiles.get(
|
|
27
|
+
const rawHtml = outputFiles.get(pathname)?.contents;
|
|
26
28
|
if (!rawHtml) {
|
|
27
29
|
next();
|
|
28
30
|
return;
|
|
@@ -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.1.
|
|
13
|
+
const VERSION = '18.1.2';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|