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

There is a compilation error #2203

Closed
dongj0316 opened this issue Apr 22, 2022 · 4 comments
Closed

There is a compilation error #2203

dongj0316 opened this issue Apr 22, 2022 · 4 comments

Comments

@dongj0316
Copy link

There is a compilation error, which seems to be the problem of esbuild. Is there any solution?

image

@dongj0316
Copy link
Author

System info:

 System:
    OS: macOS 12.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 317.63 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v12.13.1/bin/yarn
    npm: 8.7.0 - ~/.nvm/versions/node/v14.19.0/bin/npm
  npmPackages:
    @vitejs/plugin-legacy: ^1.2.2 => 1.7.1 
    vite: ^2.4.2 => 2.9.1 

@hyrious
Copy link

hyrious commented Apr 22, 2022

It seems the () of a function iife expression will always be stripped when there's leading /* @__PURE__ */ and being used as value, idk. The code will be invalid when it is after export default.

const a = /* @__PURE__ */ function(){}()      // valid
export default /* @__PURE__ */ function(){}() // invalid

See it online.

This problem only happens in transform mode, since in build mode the default export will be transformed to export { default_export as default }.

@dongj0316
Copy link
Author

@hyrious Yes, this is a syntax error 'uncaught syntax error: unexpected token ')'

image

@evanw
Copy link
Owner

evanw commented Apr 22, 2022

Thanks for the report. This is a bug in esbuild. I will fix this in the next release. In the meantime, you should be able to work around this by changing export default ... into let someVar = ... followed by export { someVar as default }.

@evanw evanw closed this as completed in e876856 Apr 22, 2022
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

3 participants