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

I need write tsx in sfc, so I installed both plugin-vue and plugin-vue-jsx. But the HMR seems not work. #3008

Closed
CaiWenlie opened this issue Apr 16, 2021 · 3 comments · Fixed by #4563

Comments

@CaiWenlie
Copy link

I need write tsx in sfc, so I installed both plugin-vue and plugin-vue-jsx. But the HMR seems not work.
when I update codes in template, the HMR works well. but not works when updating codes in tsx. i'm not sure my config is correct or not. it seems like a bug of vite.

// vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

export default defineConfig({
  plugins: [
    vue(),
    vueJsx()
  ]
})
// Home.vue
<script lang="tsx">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'Home',
  setup: () => {
    return () => {
      <h1>The Text here won't update, HMR seems not work</h1>
    }
  }
})
</script>

can anyone help! pls!

Originally posted by @CaiWenlie in #2923

@Shinigami92
Copy link
Member

Maybe related to #3002

@Sociosarbis
Copy link
Contributor

Sociosarbis commented Apr 18, 2021

I found:

  1. the content of jsx or tsx itself isn't inlined in main file of sfc, it would be imported like import _sfc_main from "/src/xxxx/xxxx/views/new/test.vue?vue&type=script&lang.tsx";
  2. script module isn't added in updated modules in handleHotUpdate hook of plugin-vue

To solve 2, I try to add script modules into the updated modules and hmr works as expected.

Here is my naive solution.

Sociosarbis@9036d7c

@agusbena
Copy link

agusbena commented Jun 13, 2021

Thanks @Sociosarbis ,
Anyways, It seems the problem in the official build still remanins.
The <style> tag in the .vue component does hot update, but not the <script> tag when tsx is used

@github-actions github-actions bot locked and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants