Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular-devkit/build-angular): avoid double sourcemap comments with esbuild dev-server #25065

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -214,15 +214,20 @@ async function setupServer(
},
load(id) {
const [file] = id.split('?', 1);
const code = outputFiles.get(file)?.contents;
const map = outputFiles.get(file + '.map')?.contents;
const codeContents = outputFiles.get(file)?.contents;
if (codeContents === undefined) {
return;
}

return (
code && {
code: code && Buffer.from(code).toString('utf-8'),
map: map && Buffer.from(map).toString('utf-8'),
}
);
const code = Buffer.from(codeContents).toString('utf-8');
const mapContents = outputFiles.get(file + '.map')?.contents;

return {
// Remove source map URL comments from the code if a sourcemap is present.
// Vite will inline and add an additional sourcemap URL for the sourcemap.
code: mapContents ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '') : code,
map: mapContents && Buffer.from(mapContents).toString('utf-8'),
};
},
configureServer(server) {
// Assets and resources get handled first
Expand Down