yuanqing / create-figma-plugin

:battery: The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
https://yuanqing.github.io/create-figma-plugin/
MIT License
902 stars 85 forks source link

Using a `build-figma-plugin.main.js` file throws an `Unexpected token 'export'` error when building #197

Closed fwextensions closed 9 months ago

fwextensions commented 9 months ago

I followed the instructions for adding an esbuild config file and used the code described there, but running a build with a build-figma-plugin.main.js file logs this error:

error esbuild error
    Unexpected token 'export'

I believe that this line is using importFresh() to import the config file. But that seems to assume it's requiring a CJS module, so I don't see how that could import an exported ES module. If it's assuming CJS, then the build error makes sense.

yuanqing commented 9 months ago

Thanks for this. Can confirm that this is a bug / change in behavior caused by the latest version of esbuild. (The @create-figma-plugin/build package has tests to verify that both export default and module.exports syntax both work out-of-the-box.)

Am considering pinning certain dependencies to exact versions… 🤔