File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed
packages/vue-jsx-vapor/src Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { transformSync } from '@babel/core'
33import babelTypescript from '@babel/plugin-transform-typescript'
44import jsx from '@vue-jsx-vapor/babel'
55import type { Options } from '../options'
6- import { registerHMR } from './hmr'
76
87export type { Options }
98
@@ -12,7 +11,7 @@ export function transformVueJsxVapor(
1211 id : string ,
1312 options ?: Options ,
1413) {
15- const result = transformSync ( code , {
14+ return transformSync ( code , {
1615 plugins : [
1716 [ jsx , { compile : options ?. compile , interop : options ?. interop } ] ,
1817 id . endsWith ( '.tsx' )
@@ -26,12 +25,4 @@ export function transformVueJsxVapor(
2625 configFile : false ,
2726 ast : true ,
2827 } )
29-
30- if ( result ) registerHMR ( result , id )
31-
32- if ( result ?. code )
33- return {
34- code : result . code ,
35- map : result . map ,
36- }
3728}
Original file line number Diff line number Diff line change 11import Macros from '@vue-jsx-vapor/macros/raw'
22import { createFilter , normalizePath } from 'unplugin-utils'
33import { transformVueJsxVapor } from './core'
4+ import { registerHMR } from './core/hmr'
45import runtimeCode from './core/runtime?raw'
56import type { Options } from './options'
67import type { UnpluginOptions } from 'unplugin'
@@ -10,6 +11,7 @@ const plugin = (options: Options = {}): UnpluginOptions[] => {
1011 options ?. include || / \. [ c m ] ? [ j t ] s x ? $ / ,
1112 options ?. exclude ,
1213 )
14+ let needHMR = false
1315 return [
1416 {
1517 name : 'vue-jsx-vapor' ,
@@ -30,6 +32,9 @@ const plugin = (options: Options = {}): UnpluginOptions[] => {
3032 } ,
3133 }
3234 } ,
35+ configResolved ( config ) {
36+ needHMR = config . command === 'serve'
37+ } ,
3338 } ,
3439 resolveId ( id ) {
3540 if ( normalizePath ( id ) === 'vue-jsx-vapor/runtime' ) return id
@@ -42,7 +47,14 @@ const plugin = (options: Options = {}): UnpluginOptions[] => {
4247 } ,
4348 transformInclude,
4449 transform ( code , id ) {
45- return transformVueJsxVapor ( code , id , options )
50+ const result = transformVueJsxVapor ( code , id , options )
51+ if ( result ?. code ) {
52+ needHMR && registerHMR ( result , id )
53+ return {
54+ code : result . code ,
55+ map : result . map ,
56+ }
57+ }
4658 } ,
4759 } ,
4860 ...( options . macros === false
You can’t perform that action at this time.
0 commit comments