Skip to content

There is a compilation error #2203

Closed
Closed
@dongj0316

Description

@dongj0316

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

image

Activity

dongj0316

dongj0316 commented on Apr 22, 2022

@dongj0316
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

hyrious commented on Apr 22, 2022

@hyrious

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

dongj0316 commented on Apr 22, 2022

@dongj0316
Author

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

image

evanw

evanw commented on Apr 22, 2022

@evanw
Owner

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 }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @evanw@hyrious@dongj0316

        Issue actions

          There is a compilation error · Issue #2203 · evanw/esbuild