compiler icon indicating copy to clipboard operation
compiler copied to clipboard

🐛 BUG: Sourcemaps seem off

Open FredKSchott opened this issue 3 years ago • 2 comments

What version of @astrojs/compiler are you using?

0.31.1

What package manager are you using?

pnpm

What operating system are you using?

mac

Describe the Bug

Looks like we have some regressions in our source maps, this is what I'm seeing on main using the direct output of our cachedCompilation() method (result.code).

Link to Minimal Reproducible Example

blog-multiple-authors Demo

FredKSchott avatar Mar 26 '22 23:03 FredKSchott

@natemoo-re I think sourcemaps still seem off? View Sourcemap It seems like every char is a segment xd I'm not sure if this will affect debugging, but I'll test with vitejs/vite#11576 to check.

Generated on @astrojs/[email protected]:

import { transform } from "@astrojs/compiler";
import { readFileSync, writeFileSync } from "fs";

transform(readFileSync("RepoLink.astro", "utf-8"), {
    sourcemap: true,
}).then(result => {
    writeFileSync("RepoLink.js", result.code);
    writeFileSync("RepoLink.js.map", result.map);
});

Vap0r1ze avatar Jan 05 '23 15:01 Vap0r1ze

Thanks @Vap0r1ze!

Sourcemaps are definitely not perfect yet. I'd consider #680 a "first-pass" at better frontmatter mapping. I'll keep this issue open to continue tracking improvements.

As for mapping every character, we found that this was necessary for our language tooling since the language server can only work with high-fidelity sourcemaps. But in this scenario, it's probably overkill. It shouldn't cause problems but it might be pretty slow. I can definitely look into handling this without mapping every character.

natemoo-re avatar Jan 05 '23 15:01 natemoo-re