Skip to content

Commit

Permalink
refactor(@angular/build): remove file: prefix from JIT component re…
Browse files Browse the repository at this point in the history
…source 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.
  • Loading branch information
alan-agius4 committed Mar 3, 2025
1 parent d63e31c commit 337bc3c
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,21 @@ async function loadEntry(
root: string,
skipRead?: boolean,
): Promise<{ path: string; contents?: string }> {
if (entry.startsWith('file:')) {
const specifier = join(root, entry.slice(5));

return {
path: specifier,
contents: skipRead ? undefined : await readFile(specifier, 'utf-8'),
};
} else if (entry.startsWith('inline:')) {
if (entry.startsWith('inline:')) {
const [importer, data] = entry.slice(7).split(';', 2);

return {
path: join(root, importer),
contents: Buffer.from(data, 'base64').toString(),
};
} else {
throw new Error('Invalid data for Angular JIT entry.');
}

const path = join(root, entry);

return {
path,
contents: skipRead ? undefined : await readFile(path, 'utf-8'),
};
}

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

0 comments on commit 337bc3c

Please sign in to comment.