Closed Lisheri closed 2 months ago
The Vue template syntax is NOT JSX. You need to use the Vue compiler to compile the code to valid JavaScript. A quick search about existing plugin: https://github.com/pipe01/esbuild-plugin-vue3
The Vue template syntax is NOT JSX. You need to use the Vue compiler to compile the code to valid JavaScript. A quick search about existing plugin: https://github.com/pipe01/esbuild-plugin-vue3
But I've added unplugin-vue to handle sfc~
This is an issue with unplugin-vue-macros
which failed to process the Vue file using unplugin-vue
, not with esbuild. For reference:
unplugin-vue
is fine in a smoking test case.VueMacros({ plugins: { vue: Vue() } })
.unplugin-vue-macros
uses createCombinePlugin()
from unplugin-combine
, which simply runs each unplugin's setup()
on one build.unplugin
hacks the build
object to provide an onTransform
hook, meaning that each plugin instance from vue macros are calling build.onLoad({ filter: /.*/ })
.onTransform()
hook returns contents, it will be returned to esbuild's onLoad()
.
If all transforms are done in a single plugin, then the logic is ok. However there're actually multiple plugin instances registering the transform hook (3). So once some plugin's transform returns code, the other plugins' transform hook will not be called.unplugin-vue-hoist-static
blocks unplugin-vue
.In summary, the transform hook mimiced by unplugin is problematic when there're multiple transform hooks from different plugin instances registered on the same file. It is still possible to fix from unplugin-combine
with a bit of tricky. @sxzz
I'm closing this issue because esbuild intentionally doesn't support Vue syntax (only JSX). If you want to support Vue syntax then you'll have to use a Vue plugin, and if you're having problems with that plugin then you'll have to work that out with the plugin author. Vue syntax is outside of esbuild's scope.
The core reason is not JSX, but that esbuild does not support transforming code again within each plugin like rollup does (of course, this is not an issue with esbuild). In unplugin, we can only hack and simulate this behavior.
We will discuss the issue in https://github.com/vue-macros/vue-macros/issues/824
Problem description
When I add the jsx configuration to the loader according to the documentation, I still get an error when building the vue component library.
My configuration
My esbuild core configuration is as follows:
demo code repository
https://github.com/Lisheri/esbuild_v3_component/tree/main