Skip to content

Commit ff8192a

Browse files
committed
fix(@angular/build): correct path for /@ng/components on Windows
The `virtualProjectRoot` is normalized, but `sourcePath` is not, leading to mismatched path slashes and related issues. Closes #29424 (cherry picked from commit abb186a)
1 parent 59c7577 commit ff8192a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import assert from 'node:assert';
1010
import { readFile } from 'node:fs/promises';
11-
import { basename, dirname, join, parse, relative } from 'node:path';
11+
import { basename, dirname, join, relative } from 'node:path';
1212
import { fileURLToPath } from 'node:url';
1313
import type { Plugin } from 'vite';
1414
import { loadEsmModule } from '../../../utils/load-esm';
@@ -46,11 +46,7 @@ export async function createAngularMemoryPlugin(
4646
// Vite will resolve these these files example:
4747
// `file:///@ng/component?c=src%2Fapp%2Fapp.component.ts%40AppComponent&t=1737017253850`
4848
const sourcePath = fileURLToPath(source);
49-
const sourceWithoutRoot = sourcePath.startsWith(virtualProjectRoot)
50-
? normalizePath('/' + relative(virtualProjectRoot, sourcePath))
51-
: // TODO: remove once https://github.com/angular/angular/blob/4e6017a9f5cda389c5fbf4f2c1519ce1bba23e11/packages/compiler/src/render3/r3_hmr_compiler.ts#L57
52-
// is changed from `/@ng` to `./@ng/`
53-
normalizePath('/' + sourcePath.slice(parse(sourcePath).root.length));
49+
const sourceWithoutRoot = normalizePath('/' + relative(virtualProjectRoot, sourcePath));
5450

5551
if (sourceWithoutRoot.startsWith(ANGULAR_PREFIX)) {
5652
const [, query] = source.split('?', 2);

0 commit comments

Comments
 (0)