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

Another of parse error since 1.5.1 #177

Closed
simonbuchan opened this issue Jun 24, 2024 · 4 comments · Fixed by #178
Closed

Another of parse error since 1.5.1 #177

simonbuchan opened this issue Jun 24, 2024 · 4 comments · Fixed by #178

Comments

@simonbuchan
Copy link

simonbuchan commented Jun 24, 2024

Similar, but not the same issue as #173

Minimal source code:

if (of / 2) {}

Error stack:

Error: Parse error @:1:18
    at parse (file:///D:/scratch/parse-error/node_modules/.pnpm/es-module-lexer@1.5.3/node_modules/es-module-lexer/dist/lexer.js:2:594)
    at file:///D:/scratch/parse-error/node_modules/.pnpm/es-module-lexer@1.5.3/node_modules/es-module-lexer/dist/lexer.js:2:355 {
  idx: 17
}

Requires:

  • of
  • following /
  • surrounding statement (e.g. just (of / 2) is fine, but switching if to while is not)

So probably the context/backtracking getting confused by the not-quite keyword.

Reproduces in 1.5.1 to 1.5.3, but not in 1.5.0 or 1.4.2

We had the poor luck to have this be spit out into our vite output chunks, which made this very confusing to debug!

@simonbuchan simonbuchan changed the title Parse error since 1.5.1 Another of parse error since 1.5.1 Jun 24, 2024
@guybedford
Copy link
Owner

Well isolated! I can imagine it must have been a hard one to find. Fix in #178 will post the release out now.

@simonbuchan
Copy link
Author

👍 Wow, nice work! Really saving my butt here!

I was banging my head against trying to work around this one, forcing v1.5.0 simply hit the other issue, so I was down to trying to see if I could inject a plugin that would replace of in the minified chunk without just colliding with something else... skin-crawling stuff 😅

@simonbuchan
Copy link
Author

Argh. Of course, we're going through vite, which bundles you in with their distribution. I'll have to open an issue over there too, though at least I can try a vendored / patched build for now.

simonbuchan added a commit to simonbuchan/vite that referenced this issue Jun 24, 2024
@simonbuchan
Copy link
Author

To close the loop: vitejs/vite#17555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants