Skip to content

Commit 0d1a5c8

Browse files
committed
fix(@angular/build): resolve Angular locale data namespace in esbuild
A transient error can occur during `ng serve` when Vite's dependency pre-bundling is triggered for Angular locale data, showing an error like `[vite] (ssr) Error when evaluating SSR module...: There is a new version of the pre-bundle...`. Previously, the `angular:locale/data:` namespace was left unresolved by the build process for the dev server. This caused Vite to treat the namespace as a new dependency, triggering a pre-bundling step that led to the error. With this change, esbuild now resolves the `angular:locale/data:` namespace and replaces it with the direct module import path. While the module is still treated as an external dependency, providing the explicit path prevents Vite from unnecessarily triggering a new pre-bundling phase. This resolves the transient error. Closes #31498 (cherry picked from commit c0c05174889967ba6e623ba40337f44ed1a1a219)
1 parent 3a28fb6 commit 0d1a5c8

File tree

4 files changed

+0
-78
lines changed

4 files changed

+0
-78
lines changed

packages/angular/build/src/builders/dev-server/vite-server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type { Connect, InlineConfig, ViteDevServer } from 'vite';
1717
import type { ComponentStyleRecord } from '../../tools/vite/middlewares';
1818
import {
1919
ServerSsrMode,
20-
createAngularLocaleDataPlugin,
2120
createAngularMemoryPlugin,
2221
createAngularSetupMiddlewaresPlugin,
2322
createAngularSsrTransformPlugin,
@@ -909,7 +908,6 @@ export async function setupServer(
909908
}),
910909
},
911910
plugins: [
912-
createAngularLocaleDataPlugin(),
913911
createAngularSetupMiddlewaresPlugin({
914912
outputFiles,
915913
assets,

packages/angular/build/src/tools/esbuild/i18n-locale-plugin.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ export function createAngularLocaleDataPlugin(): Plugin {
2727
return {
2828
name: 'angular-locale-data',
2929
setup(build): void {
30-
// If packages are configured to be external then leave the original angular locale import path.
31-
// This happens when using the development server with caching enabled to allow Vite prebundling to work.
32-
// There currently is no option on the esbuild resolve function to resolve while disabling the option. To
33-
// workaround the inability to resolve the full locale location here, the Vite dev server prebundling also
34-
// contains a plugin to allow the locales to be correctly resolved when prebundling.
35-
// NOTE: If esbuild eventually allows controlling the external package options in a build.resolve call, this
36-
// workaround can be removed.
37-
if (build.initialOptions.packages === 'external') {
38-
return;
39-
}
40-
4130
build.onResolve({ filter: /^angular:locale\/data:/ }, async ({ path }) => {
4231
// Extract the locale from the path
4332
const rawLocaleTag = path.split(':', 3)[2];

packages/angular/build/src/tools/vite/plugins/i18n-locale-plugin.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

packages/angular/build/src/tools/vite/plugins/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
export { createAngularMemoryPlugin } from './angular-memory-plugin';
10-
export { createAngularLocaleDataPlugin } from './i18n-locale-plugin';
1110
export { createRemoveIdPrefixPlugin } from './id-prefix-plugin';
1211
export { createAngularSetupMiddlewaresPlugin, ServerSsrMode } from './setup-middlewares-plugin';
1312
export { createAngularSsrTransformPlugin } from './ssr-transform-plugin';

0 commit comments

Comments
 (0)