vite: Error `Unexpected token '{'` after upgrade vite@4.3.9 to vite@4.4.0
Describe the bug
I tried to upgrade vite@4.3.9 to vite@4.4.0 but Cypress could not longer run tests because of the error Unexpected token '{' (see logs section for more detailed stack trace).
Reproduction
sorry none at this time
Steps to reproduce
I will write more detailed steps to reproduce if this upgrade becomes more important.
I suspect the following would work:
- Create a react app using TypeScript
yarn add cypress@8.5.0(note, I’m stuck on this old Cypress version)- Create a simple Cypress test
- Try to run the Cypress test against the react app
- Observe error in the Cypress console
System Info
"cypress": "8.5.0",
"vite-tsconfig-paths": "^4.2.0",
Used Package Manager
yarn
Logs
Vite Logs
See google doc, it was too long to paste into the message body.
Cypress Console Log
Error seen in Cypress console:
SyntaxError: Unexpected token '{'
More detail by printing the Cypress log to the console log:
cypress_runner.js:190988 SyntaxError: The following error originated from your application code, not from Cypress.
> Unexpected token '{'
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
SyntaxError: The following error originated from your application code, not from Cypress.
> Unexpected token '{'
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
From previous event:
at Object.run (http://localhost:3000/__cypress/runner/cypress_runner.js:182821:23)
at Object.run (http://localhost:3000/__cypress/runner/cypress_runner.js:168727:17)
at $Cy.cy.<computed> [as wait] (http://localhost:3000/__cypress/runner/cypress_runner.js:169897:19)
at __stackReplacementMarker (http://localhost:3000/__cypress/runner/cypress_runner.js:169205:13)
at Context.runnable.fn (http://localhost:3000/__cypress/runner/cypress_runner.js:170121:23)
at callFn (http://localhost:3000/__cypress/runner/cypress_runner.js:122959:21)
at Test.../driver/node_modules/mocha/lib/runnable.js.Runnable.run (http://localhost:3000/__cypress/runner/cypress_runner.js:122946:7)
at http://localhost:3000/__cypress/runner/cypress_runner.js:176663:30
From previous event:
at Object.onRunnableRun (http://localhost:3000/__cypress/runner/cypress_runner.js:176648:19)
at $Cypress.action (http://localhost:3000/__cypress/runner/cypress_runner.js:166202:28)
at Test.Runnable.run (http://localhost:3000/__cypress/runner/cypress_runner.js:174382:13)
at Runner.../driver/node_modules/mocha/lib/runner.js.Runner.runTest (http://localhost:3000/__cypress/runner/cypress_runner.js:123618:10)
at http://localhost:3000/__cypress/runner/cypress_runner.js:123744:12
at next (http://localhost:3000/__cypress/runner/cypress_runner.js:123527:14)
at http://localhost:3000/__cypress/runner/cypress_runner.js:123537:7
at next (http://localhost:3000/__cypress/runner/cypress_runner.js:123439:14)
at http://localhost:3000/__cypress/runner/cypress_runner.js:123505:5
at timeslice (http://localhost:3000/__cypress/runner/cypress_runner.js:117431:27)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 23 (5 by maintainers)
Changing the compiler options target on 4.3.9 is definitely changing my output JS.
Given this typescript:
And this section of tsconfig.json:
es2015
esnext
Omitting the compilerOptions:
It’s worth noting, every time I change my tsconfig.json while my server is running, I see this log line:
On Vite 4.4.7, with “es2015” the file is:
This errors. Safari does not seem to understand this part:
I tried “esnext” and the file is:
I tried a bunch of different values for compilerOptions target, and es2021 errors (same output as es2015), but es2022 works fine (same output as esnext).
This is so strange.
I’m sure it’s obvious, but by updating Vite from 4.3 to 4.4, it also updated esbuild from 0.17 to 0.18.
So far I’ve been unable to put together a reproduction from scratch. So I think I’m gonna work the other way around: take my project, make a branch, and start cutting chunks away until the problem goes away. Then I’ll have a better idea of how to create a reproduction—hopefully.
We’re getting this error as well, only in Safari 15 and earlier (in our Astro + Vue app). @mosofsky would you mind updating the title of this issue, since it’s not just about Cypress? It affects production applications.