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

Uncaught ReferenceError: _<variable_name> is not defined #77

Closed
7 tasks done
NazmusSayad opened this issue Mar 29, 2023 · 8 comments
Closed
7 tasks done

Uncaught ReferenceError: _<variable_name> is not defined #77

NazmusSayad opened this issue Mar 29, 2023 · 8 comments

Comments

@NazmusSayad
Copy link

NazmusSayad commented Mar 29, 2023

Describe the bug

I am using "@vitejs/plugin-react-swc".
I used the useRef hook and saved its value inside a variable named "imageContainer".

Then this happens:
Uncaught ReferenceError: _imageContainer is not defined

There isn't a single variable named "_imageContainer" in my whole project.
Then I tried the "@vitejs/plugin-react" and it's perfectly working.
I have also tried my versions of "@vitejs/plugin-react-swc" and "vite" all of them have the same issue.

But I have an old version where swc was working.
Working repo: https://github.com/NazmusSayad/messagen-client/tree/swc-working
Not working repo: https://github.com/NazmusSayad/messagen-client/tree/swc-error

Reproduction

https://github.com/NazmusSayad/messagen-client/tree/swc-error

Steps to reproduce

  1. yarn

  2. yarn dev

  3. http://localhost:3000/login

  4. You need an account now, username: "NazmusSayad", password: "hello world!"

  5. http://localhost:3000/chat/6416e099b4652ab4149e9e42

System Info

System:
    OS: Linux 5.4 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (2) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
    Memory: 1.54 GB / 3.84 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 18.15.0 - /usr/local/share/nvm/versions/node/v18.15.0/bin/node
    Yarn: 1.22.19 - /usr/local/share/nvm/versions/node/v18.15.0/bin/yarn
    npm: 9.6.2 - /usr/local/share/nvm/versions/node/v18.15.0/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^3.0.0 => 3.0.0 
    vite: ^4.2.0 => 4.2.0

Used Package Manager

yarn

Logs

No response

Validations

@ArnaudBarre
Copy link
Member

hello,

This will take time to identify the root cause.
I see that you're bumping a lot of dependencies together, can you reproduce when changing one the react-swc plugin?

@NazmusSayad
Copy link
Author

Yeah, I tried.
In the working version just after changing the swc package I am facing this error

@NazmusSayad
Copy link
Author

Clone the working branch then run "y add -D @vitejs/plugin-react-swc". You will face the same error

@ArnaudBarre ArnaudBarre transferred this issue from vitejs/vite-plugin-react Mar 29, 2023
@ArnaudBarre
Copy link
Member

Just tried the repro, switch to swc, restart and I'm able to load the home page.
What's your node version & os?

@NazmusSayad
Copy link
Author

The homepage is working. Follow the "Steps to reproduce". You can find the issue here: "http://localhost:3000/chat/6416e099b4652ab4149e9e42"

@ArnaudBarre ArnaudBarre added dependencies Pull requests that update a dependency file and removed need reproduction dependencies Pull requests that update a dependency file labels Mar 31, 2023
@ArnaudBarre
Copy link
Member

Sorry didn't forgot to look at the steps.
This is broken since swc v1.3.40.

You can avoid this by pinning the version:

  "resolutions": {
    "@swc/core": "1.3.39"
  },

@ArnaudBarre
Copy link
Member

Oh actually this is also working with 1.3.44.
Found the PR: swc-project/swc#7171

@NazmusSayad
Copy link
Author

I see... Ok thanks

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

No branches or pull requests

2 participants