Skip to content

Commit de993cc

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.
1 parent 9bce4c4 commit de993cc

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,20 @@ 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+
return {
48+
path,
49+
contents: skipRead ? undefined : await readFile(path, 'utf-8'),
50+
};
5451
}
5552

5653
/**
@@ -85,7 +82,7 @@ export function setupJitPluginCallbacks(
8582
return {
8683
// Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
8784
// This is only necessary for custom namespaces. esbuild will handle the file namespace.
88-
path: 'file:' + relative(root, join(dirname(args.importer), specifier)),
85+
path: relative(root, join(dirname(args.importer), specifier)),
8986
namespace,
9087
};
9188
} else {

0 commit comments

Comments
 (0)