@angular/build 18.1.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "18.1.0",
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.0",
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",
@@ -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.values(metafile.outputs)) {
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: /.wasm$/ }, async (args) => {
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: /.wasm$/, namespace: WASM_INIT_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
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: /.wasm$/, namespace: WASM_CONTENTS_NAMESPACE }, async (args) => {
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) {
@@ -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.0';
13
+ const VERSION = '18.1.1';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&