From 1f4518b69b6d6d4afdb485570ed795fe4f557a77 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 23 May 2020 23:08:31 -0400 Subject: [PATCH] fix: fix build resolve for vue jsx shim --- src/node/build/buildPluginEsbuild.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/node/build/buildPluginEsbuild.ts b/src/node/build/buildPluginEsbuild.ts index 9671a79c3693f0..7b435428368dbd 100644 --- a/src/node/build/buildPluginEsbuild.ts +++ b/src/node/build/buildPluginEsbuild.ts @@ -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 ( @@ -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) {