@angular/build 18.1.0-rc.1 → 18.1.1
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 +6 -6
- package/src/builders/dev-server/vite-server.js +2 -0
- package/src/tools/angular/compilation/aot-compilation.js +3 -1
- package/src/tools/angular/compilation/parallel-worker.d.ts +1 -0
- package/src/tools/angular/compilation/parallel-worker.js +2 -1
- package/src/tools/esbuild/angular/compiler-plugin.js +3 -1
- package/src/tools/esbuild/budget-stats.js +4 -1
- package/src/tools/esbuild/wasm-plugin.js +5 -4
- package/src/tools/vite/id-prefix-plugin.d.ts +9 -0
- package/src/tools/vite/id-prefix-plugin.js +44 -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.1.
|
|
3
|
+
"version": "18.1.1",
|
|
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.1",
|
|
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",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"watchpack": "2.4.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@angular/compiler-cli": "^18.0.0
|
|
55
|
-
"@angular/localize": "^18.0.0
|
|
56
|
-
"@angular/platform-server": "^18.0.0
|
|
57
|
-
"@angular/service-worker": "^18.0.0
|
|
54
|
+
"@angular/compiler-cli": "^18.0.0",
|
|
55
|
+
"@angular/localize": "^18.0.0",
|
|
56
|
+
"@angular/platform-server": "^18.0.0",
|
|
57
|
+
"@angular/service-worker": "^18.0.0",
|
|
58
58
|
"less": "^4.2.0",
|
|
59
59
|
"postcss": "^8.4.0",
|
|
60
60
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
@@ -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({
|
|
@@ -136,7 +136,9 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
136
136
|
const { affectedFiles, angularCompiler, compilerHost, typeScriptProgram, webWorkerTransform } = this.#state;
|
|
137
137
|
const compilerOptions = typeScriptProgram.getCompilerOptions();
|
|
138
138
|
const buildInfoFilename = compilerOptions.tsBuildInfoFile ?? '.tsbuildinfo';
|
|
139
|
-
const useTypeScriptTranspilation = !compilerOptions.isolatedModules ||
|
|
139
|
+
const useTypeScriptTranspilation = !compilerOptions.isolatedModules ||
|
|
140
|
+
!!compilerOptions.sourceMap ||
|
|
141
|
+
!!compilerOptions.inlineSourceMap;
|
|
140
142
|
const emittedFiles = new Map();
|
|
141
143
|
const writeFileCallback = (filename, contents, _a, _b, sourceFiles) => {
|
|
142
144
|
if (!sourceFiles?.length && filename.endsWith(buildInfoFilename)) {
|
|
@@ -24,6 +24,7 @@ export declare function initialize(request: InitRequest): Promise<{
|
|
|
24
24
|
allowJs: boolean | undefined;
|
|
25
25
|
isolatedModules: boolean | undefined;
|
|
26
26
|
sourceMap: boolean | undefined;
|
|
27
|
+
inlineSourceMap: boolean | undefined;
|
|
27
28
|
};
|
|
28
29
|
}>;
|
|
29
30
|
export declare function diagnose(modes: DiagnosticModes): Promise<{
|
|
@@ -70,11 +70,12 @@ async function initialize(request) {
|
|
|
70
70
|
});
|
|
71
71
|
return {
|
|
72
72
|
referencedFiles,
|
|
73
|
-
// TODO: Expand? `allowJs`, `isolatedModules`, `sourceMap` are the only fields needed currently.
|
|
73
|
+
// TODO: Expand? `allowJs`, `isolatedModules`, `sourceMap`, `inlineSourceMap` are the only fields needed currently.
|
|
74
74
|
compilerOptions: {
|
|
75
75
|
allowJs: compilerOptions.allowJs,
|
|
76
76
|
isolatedModules: compilerOptions.isolatedModules,
|
|
77
77
|
sourceMap: compilerOptions.sourceMap,
|
|
78
|
+
inlineSourceMap: compilerOptions.inlineSourceMap,
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
81
|
}
|
|
@@ -206,7 +206,8 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
206
206
|
// Typescript printing support for sourcemaps is not yet integrated.
|
|
207
207
|
useTypeScriptTranspilation =
|
|
208
208
|
!initializationResult.compilerOptions.isolatedModules ||
|
|
209
|
-
!!initializationResult.compilerOptions.sourceMap
|
|
209
|
+
!!initializationResult.compilerOptions.sourceMap ||
|
|
210
|
+
!!initializationResult.compilerOptions.inlineSourceMap;
|
|
210
211
|
referencedFiles = initializationResult.referencedFiles;
|
|
211
212
|
}
|
|
212
213
|
catch (error) {
|
|
@@ -425,6 +426,7 @@ function createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserve
|
|
|
425
426
|
noEmitOnError: false,
|
|
426
427
|
inlineSources: !!pluginOptions.sourcemap,
|
|
427
428
|
inlineSourceMap: !!pluginOptions.sourcemap,
|
|
429
|
+
sourceMap: undefined,
|
|
428
430
|
mapRoot: undefined,
|
|
429
431
|
sourceRoot: undefined,
|
|
430
432
|
preserveSymlinks,
|
|
@@ -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 {
|
|
@@ -100,7 +100,8 @@ function createWasmPlugin(options) {
|
|
|
100
100
|
// Read from the file system when on Node.js (SSR) and not inline
|
|
101
101
|
if (!inlineWasm && build.initialOptions.platform === 'node') {
|
|
102
102
|
initContents += 'import { readFile } from "node:fs/promises";\n';
|
|
103
|
-
initContents +=
|
|
103
|
+
initContents +=
|
|
104
|
+
'const wasmData = await readFile(new URL(wasmPath, import.meta.url));\n';
|
|
104
105
|
}
|
|
105
106
|
// Create initialization function
|
|
106
107
|
initContents += generateInitHelper(!inlineWasm && build.initialOptions.platform !== 'node', wasmContents);
|
|
@@ -154,7 +155,7 @@ function createWasmPlugin(options) {
|
|
|
154
155
|
watchFiles: [args.path],
|
|
155
156
|
};
|
|
156
157
|
}));
|
|
157
|
-
build.onLoad({ filter:
|
|
158
|
+
build.onLoad({ filter: /\.wasm$/, namespace: WASM_CONTENTS_NAMESPACE }, async (args) => {
|
|
158
159
|
const contents = args.pluginData.wasmContents ?? (await (0, promises_1.readFile)(args.path));
|
|
159
160
|
let loader = 'file';
|
|
160
161
|
if (args.with.loader) {
|
|
@@ -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(`${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;
|
|
@@ -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.1';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|