astro
astro copied to clipboard
Astro transform fails under specific arrangement of comments and exports
What version of astro
are you using?
1.1.5
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
WSL2
Describe the Bug
(don't know if this should go in the compiler repo)
Found while trying to comment the minimal reproduction for issue 4617, which I recently submitted.
The Astro transform fails under a certain set of conditions, where:
- one line contains a single-line comment (i.e.
//
), - the line directly following is a single-line export that does not have a semicolon ending it,
- and the next statement/expression has a multiline comment (i.e.
/* */
) beginning on the same line as it (or the next statement/expression is a multiline comment) - and the multiline comment ends on a different line from that which it started on
As a minimal example, the following code errors:
//
export const foo = 0
/*
*/
or a more complex example, but still following the heuristics described above:
const bar =
0 /// lorem ipsum
export const foo = 0 // dolor sit amet
const baz = 0 + /*
*/0
Numerous other tests / examples of what does and doesn't fail are in the minimal reproduction.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-64wjzh?file=src/pages/index.astro
Participation
- [ ] I am willing to submit a pull request for this issue.