Skip to content

Commit db1660e

Browse files
committed
feat(vue-jsx-vapor): use virtual code to support browser environments
1 parent 22a2e59 commit db1660e

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

Diff for: packages/babel/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default (): {
101101
})
102102
if (helpers.length) {
103103
statements.unshift(
104-
`import { ${helpers.map((i) => `${i} as _${i}`).join(', ')} } from 'vue-jsx-vapor';\n`,
104+
`import { ${helpers.map((i) => `${i} as _${i}`).join(', ')} } from 'vue-jsx-vapor/runtime';\n`,
105105
)
106106
}
107107

Diff for: packages/vue-jsx-vapor/src/core/runtime.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
type EffectScope,
1010
} from 'vue'
1111

12+
export { shallowRef as useRef } from 'vue'
13+
1214
function createFragment(
1315
nodes: Block[],
1416
anchor: Node | undefined = document.createTextNode(''),

Diff for: packages/vue-jsx-vapor/src/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export { shallowRef as useRef } from 'vue'
2-
31
export * from './core/runtime'

Diff for: packages/vue-jsx-vapor/src/raw.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Macros from '@vue-jsx-vapor/macros/raw'
2-
import { createFilter } from 'unplugin-utils'
2+
import { createFilter, normalizePath } from 'unplugin-utils'
33
import { transformVueJsxVapor } from './core'
4+
import runtimeCode from './core/runtime?raw'
45
import type { Options } from './options'
56
import type { UnpluginOptions } from 'unplugin'
67

@@ -30,6 +31,15 @@ const plugin = (options: Options = {}): UnpluginOptions[] => {
3031
}
3132
},
3233
},
34+
resolveId(id) {
35+
if (normalizePath(id) === 'vue-jsx-vapor/runtime') return id
36+
},
37+
loadInclude(id) {
38+
return normalizePath(id) === 'vue-jsx-vapor/runtime'
39+
},
40+
load(id) {
41+
if (normalizePath(id) === 'vue-jsx-vapor/runtime') return runtimeCode
42+
},
3343
transformInclude,
3444
transform(code, id) {
3545
return transformVueJsxVapor(code, id, options)

0 commit comments

Comments
 (0)