🐛 BUG: Sourcemaps seem off
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
@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);
});
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.