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

🐛 BUG: Sourcemaps seem off #341

Open
FredKSchott opened this issue Mar 26, 2022 · 2 comments · Fixed by #680
Open

🐛 BUG: Sourcemaps seem off #341

FredKSchott opened this issue Mar 26, 2022 · 2 comments · Fixed by #680
Labels
- P2: nice to have Not breaking anything but nice to have (priority)

Comments

@FredKSchott
Copy link
Member

FredKSchott commented Mar 26, 2022

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

@Vap0r1ze
Copy link

Vap0r1ze commented Jan 5, 2023

@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);
});

@natemoo-re natemoo-re reopened this Jan 5, 2023
@natemoo-re
Copy link
Member

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 natemoo-re added the - P2: nice to have Not breaking anything but nice to have (priority) label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants