withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
503 stars 59 forks source link

fix: move declare const at the bottom of the file to make mapping easier downstream #803

Closed Princesseuh closed 1 year ago

Princesseuh commented 1 year ago

Changes

By not shifting the start of the file, it allows consumer downstream to always assume that the frontmatter is the beginning of the file, this is especially useful for mapping code actions and completions that are supposed to add code to the frontmatter since we can know where the frontmatter starts and end in the virtual file by using the positions of it in the real file

Ultimately, it'd be better to solve this in another way (maybe provide the location of the frontmatter in the virtual file), but this changes makes things easier in the meantime

Testing

Updated tests

Docs

N/A

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 522d54c42a6b942b4c6c72da4d16d994fc68eda4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------- | ----- | | @astrojs/compiler | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR