Skip to content

Commit ddae37f

Browse files
committed
refactor(@angular/build): normalize source path for windows compatibility
This update resolves an issue that prevents SSR from functioning correctly on Windows when using the latest Vite.
1 parent aa6bf07 commit ddae37f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,28 @@ export async function createAngularMemoryPlugin(
4747
}
4848

4949
if (importer) {
50-
if (source[0] === '.' && normalizePath(importer).startsWith(virtualProjectRoot)) {
50+
const normalizedImporter = normalizePath(importer);
51+
if (source[0] === '.' && normalizedImporter.startsWith(virtualProjectRoot)) {
5152
// Remove query if present
52-
const [importerFile] = importer.split('?', 1);
53+
const [importerFile] = normalizedImporter.split('?', 1);
5354
source = '/' + join(dirname(relative(virtualProjectRoot, importerFile)), source);
5455
} else if (
5556
!ssr &&
5657
source[0] === '/' &&
5758
importer.endsWith('index.html') &&
58-
normalizePath(importer).startsWith(virtualProjectRoot)
59+
normalizedImporter.startsWith(virtualProjectRoot)
5960
) {
6061
// This is only needed when using SSR and `angularSsrMiddleware` (old style) to correctly resolve
6162
// .js files when using lazy-loading.
6263
// Remove query if present
63-
const [importerFile] = importer.split('?', 1);
64+
const [importerFile] = normalizedImporter.split('?', 1);
6465
source =
6566
'/' + join(dirname(relative(virtualProjectRoot, importerFile)), basename(source));
6667
}
6768
}
6869

6970
const [file] = source.split('?', 1);
70-
if (outputFiles.has(file)) {
71+
if (outputFiles.has(normalizePath(file))) {
7172
return join(virtualProjectRoot, source);
7273
}
7374
},

0 commit comments

Comments
 (0)