Skip to content

Commit

Permalink
fix: fix build resolve for vue jsx shim
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 24, 2020
1 parent 3f0aff9 commit 1f4518b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/node/build/buildPluginEsbuild.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import fs from 'fs-extra'
import { Plugin } from 'rollup'
import { tjsxRE, transform, resolveJsxOptions } from '../esbuildService'
import {
tjsxRE,
transform,
resolveJsxOptions,
vueJsxPublicPath,
vueJsxFilePath
} from '../esbuildService'
import { SharedConfig } from '../config'

export const createEsbuildPlugin = async (
Expand All @@ -11,6 +18,18 @@ export const createEsbuildPlugin = async (
return {
name: 'vite:esbuild',

resolveId(id) {
if (id === vueJsxPublicPath) {
return vueJsxPublicPath
}
},

load(id) {
if (id === vueJsxPublicPath) {
return fs.readFileSync(vueJsxFilePath, 'utf-8')
}
},

async transform(code, id) {
const isVueTs = /\.vue\?/.test(id) && id.endsWith('lang=ts')
if (tjsxRE.test(id) || isVueTs) {
Expand Down

0 comments on commit 1f4518b

Please sign in to comment.