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

[plugin:vite:esbuild] Transform failed with 1 error: Unexpected "@",when using styled-components+mobx+ts #2776

Closed
yirikanjinchanganhua opened this issue Mar 30, 2021 · 8 comments · Fixed by #2855

Comments

@yirikanjinchanganhua
Copy link

yirikanjinchanganhua commented Mar 30, 2021

Describe the bug

When I'm rendering a styled component, I get the following error:
[plugin:vite:esbuild] Transform failed with 1 error: Unexpected "@".

Reproduction

See vite-bug-with-styled-components

When I created a new TSX component that used the Styled component in this component, and used the mobx@observer component, I got an error: [Plugin :vite:esbuild] Transform failed with 1 error: Unexpected "@". When I remove the styled components in the component, it runs normally

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

System:
    OS: macOS 11.2.3
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 56.30 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.20.0 - /usr/local/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Browsers:
    Chrome: 89.0.4389.90
    Edge: 84.0.522.63
    Firefox: 72.0.2
    Safari: 14.0.3
  npmPackages:
    vite: 2.1.0 => 2.1.0 

Used package manager: npm

@yirikanjinchanganhua
Copy link
Author

Components in the src/Hello.tsx

@Xia121
Copy link

Xia121 commented Mar 31, 2021

who can help you ?

@yirikanjinchanganhua
Copy link
Author

who can help you ?

I don't know (⊙o⊙)…

@thecodejack
Copy link

did the issue got resolved? I am still facing the same issue even with the fix.

@patak-dev
Copy link
Member

@thecodejack please open a new issue with a minimal reproduction if you found a bug (or regression) against the latest version of Vite. Thanks!

@thecodejack
Copy link

thecodejack commented Apr 29, 2021

@patak-js looks like issue is when decorators are used by dep node modules? Is there anyways I can make vite considers them to be compiled instead of creating a prebuild?

I tried to add

optimizeDeps: {
    include: ['test-components'],
  },

test-components is the node modules using decorators of mobx...

@patak-dev
Copy link
Member

Let's not discuss on old closed issues. You can start a GitHub Discussion or join the chat at Vite Land to ask questions. Thanks!

@thecodejack
Copy link

Have created same in #3215

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants