-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Named export is not defined when used in destructuring object #1791
Comments
Please, open an issue in Vite repository, VItest doesn't do any transformations on its own. |
🤦 |
@sheremet-va While I was opening the issue in vite repository, I realized that running it with vite works. Here's an example: |
No, this is error with Vite SSR. Vite doesn't do this transformation for browser. |
@sheremet-va I see. How can I reproduce it using just vite? I want to create an example reproducing the error to create the issue |
You can give the same reproduction. Vitest internally uses Vite's |
Here is the more generalized reproduction tho: https://stackblitz.com/edit/node-pmokln?file=index.mjs |
Describe the bug
Looks like imported named exports are not being correctly transformed when used in object desctructuring.
When running I get this error:
This is the transform result of my helper.js file:
As can be seen,
NAME
isn't not correctly referenced.Originally posted by @inakiabt in #1789
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-eg6hlk?file=test%2Fhelper1.js
There are 3 tests. All of them tests a simple function that uses an imported constant to destruct an object and return the result.
for test 1 and 2, the constant (NAME) seems to be "not defined" to vitest.
for test 3, I use a different the constant (n) that seems to be defined but it doesn't have the correct value when running the test.
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: