Skip to content

Commit 02ae48d

Browse files
committed
refactor(@angular/build): handle relative @ng/components
This update serves as a preparatory step to address angular#29248. The change involves modifying the line `const urlPartial = \`/@ng/component?c=${id}&t=`;` in [r3_hmr_compiler.ts](https://github.com/angular/angular/blob/4e6017a9f5cda389c5fbf4f2c1519ce1bba23e11/packages/compiler/src/render3/r3_hmr_compiler.ts#L57) to `./@ng/component?c=${id}&t=\`;`.
1 parent 612da79 commit 02ae48d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/angular/build/src/tools/vite/middlewares/component-middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function createAngularComponentMiddleware(
1818
return;
1919
}
2020

21-
if (!req.url.startsWith(ANGULAR_COMPONENT_PREFIX)) {
21+
if (!req.url.includes(ANGULAR_COMPONENT_PREFIX)) {
2222
next();
2323

2424
return;

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ export async function createAngularMemoryPlugin(
4747
// `file:///@ng/component?c=src%2Fapp%2Fapp.component.ts%40AppComponent&t=1737017253850`
4848
const sourcePath = fileURLToPath(source);
4949
const { root } = parse(sourcePath);
50-
const sourceWithoutRoot = normalizePath('/' + sourcePath.slice(root.length));
50+
const sourceWithoutRoot = sourcePath.startsWith(virtualProjectRoot)
51+
? normalizePath('/' + relative(virtualProjectRoot, sourcePath))
52+
: // TODO: remove once https://github.com/angular/angular/blob/4e6017a9f5cda389c5fbf4f2c1519ce1bba23e11/packages/compiler/src/render3/r3_hmr_compiler.ts#L57
53+
// is changed from `/@ng` to `./@ng/`
54+
normalizePath('/' + sourcePath.slice(root.length));
5155

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

0 commit comments

Comments
 (0)