Skip to content

Commit dacc9fa

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
1 parent 44d9539 commit dacc9fa

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
@@ -12,7 +12,6 @@ import type { Connect, InlineConfig, SSROptions, ServerOptions } from 'vite';
1212
import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
1313
import {
1414
ServerSsrMode,
15-
createAngularLocaleDataPlugin,
1615
createAngularMemoryPlugin,
1716
createAngularSetupMiddlewaresPlugin,
1817
createAngularSsrTransformPlugin,
@@ -221,7 +220,6 @@ export async function setupServer(
221220
define,
222221
),
223222
plugins: [
224-
createAngularLocaleDataPlugin(),
225223
createAngularSetupMiddlewaresPlugin({
226224
outputFiles,
227225
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)