-
-
Notifications
You must be signed in to change notification settings - Fork 201
Vue and JSX #551
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
Comments
Hi @Kocal,
Wouldn't it be better to add that directly to Encore.enableVueLoader(() => {}, {
useJsx: true,
}); |
Ah yep, even better! :) |
Oh also, I've just seen that the dev-server with HMR does not really work anymore when using JSX (or the There is an issue vuejs/jsx-vue2#13 which suggests to use vue-jsx-hot-loader. I will try it and put a feedback here. EDIT: The HMR with JSX works fine, unless you modify a props that is used in the EDIT 2: Ok, so I wasn't able to reproduce the HRM issue on a custom repo. I did the same thing on my project (still without Weird 🤔 EDIT 3: ok so the issue comes back on my project. In fact it works for the first update, but it does not work anymore unless I reboot Webpack Encore dev-server. EDIT 4: I was able to reproduce the reload issue on another repo, I think the problem happens because of render/slots usage. |
@Kocal That HMR issue is really weird, I couldn't reproduce it at all with your last repo. But yeah, not related to Encore, so we should be fine without any additional loader :) |
Can I work on this or you already planned to? :) EDIT: I'm working on it |
Actually that's not an issue, but just an help if some people want to write JSX code with their Vue components. I'm planning to open a PR on symfony/symfony-docs aswell.
The Vue team created a repo (vuejs/jsx) that explains how to use JSX with Vue.
We should start to install dependencies:
$ npm install --save-dev @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props # with yarn $ yarn add -D @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props
And then configure Babel to use the preset
@vue/babel-preset-jsx
, this is how we do that with Encore:And that's all. 😄
By the way, like it has been done for React (
.enableReactPreset()
) maybe we should consider adding a new method to Encore, like.enableVueJSX()
that will mutate Babel config?The text was updated successfully, but these errors were encountered: