Skip to content

Commit 4e4fb8a

Browse files
committed
refactor(@angular/build): remove file: prefix from JIT component resource URLs in sourcemaps
Previously, JIT component resource URLs in sourcemaps included a `file:` prefix (e.g., `file:src/app/app.component.html`). This change removes the `file:` prefix to ensure cleaner source mappings. (cherry picked from commit 337bc3c)
1 parent 4c35b57 commit 4e4fb8a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

packages/angular/build/src/tools/esbuild/angular/jit-plugin-callbacks.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,21 @@ async function loadEntry(
3434
root: string,
3535
skipRead?: boolean,
3636
): Promise<{ path: string; contents?: string }> {
37-
if (entry.startsWith('file:')) {
38-
const specifier = join(root, entry.slice(5));
39-
40-
return {
41-
path: specifier,
42-
contents: skipRead ? undefined : await readFile(specifier, 'utf-8'),
43-
};
44-
} else if (entry.startsWith('inline:')) {
37+
if (entry.startsWith('inline:')) {
4538
const [importer, data] = entry.slice(7).split(';', 2);
4639

4740
return {
4841
path: join(root, importer),
4942
contents: Buffer.from(data, 'base64').toString(),
5043
};
51-
} else {
52-
throw new Error('Invalid data for Angular JIT entry.');
5344
}
45+
46+
const path = join(root, entry);
47+
48+
return {
49+
path,
50+
contents: skipRead ? undefined : await readFile(path, 'utf-8'),
51+
};
5452
}
5553

5654
/**
@@ -85,7 +83,7 @@ export function setupJitPluginCallbacks(
8583
return {
8684
// Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
8785
// This is only necessary for custom namespaces. esbuild will handle the file namespace.
88-
path: 'file:' + relative(root, join(dirname(args.importer), specifier)),
86+
path: relative(root, join(dirname(args.importer), specifier)),
8987
namespace,
9088
};
9189
} else {

0 commit comments

Comments
 (0)