Skip to content

Commit

Permalink
refactor(@angular/build): handle relative @ng/components
Browse files Browse the repository at this point in the history
This update serves as a preparatory step to address angular#29248. The change involves modifying the line 'urlPartial'  in [r3_hmr_compiler.ts](https://github.com/angular/angular/blob/4e6017a9f5cda389c5fbf4f2c1519ce1bba23e11/packages/compiler/src/render3/r3_hmr_compiler.ts#L57) to start with `./` instead of `/`.
  • Loading branch information
alan-agius4 committed Jan 17, 2025
1 parent 612da79 commit d844c33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createAngularComponentMiddleware(
return;
}

if (!req.url.startsWith(ANGULAR_COMPONENT_PREFIX)) {
if (!req.url.includes(ANGULAR_COMPONENT_PREFIX)) {
next();

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export async function createAngularMemoryPlugin(
// Vite will resolve these these files example:
// `file:///@ng/component?c=src%2Fapp%2Fapp.component.ts%40AppComponent&t=1737017253850`
const sourcePath = fileURLToPath(source);
const { root } = parse(sourcePath);
const sourceWithoutRoot = normalizePath('/' + sourcePath.slice(root.length));
const sourceWithoutRoot = sourcePath.startsWith(virtualProjectRoot)
? normalizePath('/' + relative(virtualProjectRoot, sourcePath))
: // TODO: remove once https://github.com/angular/angular/blob/4e6017a9f5cda389c5fbf4f2c1519ce1bba23e11/packages/compiler/src/render3/r3_hmr_compiler.ts#L57
// is changed from `/@ng` to `./@ng/`
normalizePath('/' + sourcePath.slice(parse(sourcePath).root.length));

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

0 comments on commit d844c33

Please sign in to comment.