From 0a5a189c13a2ae952cb8bbf7bd1d24e84cbe9590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 28 Jun 2022 04:17:06 +0900 Subject: [PATCH] fix: support vite v3 (#50) --- package.json | 2 +- src/index.ts | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/package.json b/package.json index af0c4c3..d3e1e28 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "peerDependencies": { "@babel/core": "7.x", - "vite": "2.x" + "vite": "2.x || 3.x" }, "devDependencies": { "@babel/core": "^7.15.8", diff --git a/src/index.ts b/src/index.ts index ee773cf..793107f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,6 @@ import type { FilterPattern } from "@rollup/pluginutils"; import type { ParserPlugin, ParserOptions } from "@babel/parser"; import type { TransformOptions } from "@babel/core"; -import resolve from "resolve"; import prefresh from "@prefresh/vite"; import { preactDevtoolsPlugin } from "./devtools.js"; import { createFilter, parseId } from "./utils.js"; @@ -89,24 +88,6 @@ export default function preactPlugin({ configResolved(resolvedConfig) { config = resolvedConfig; }, - resolveId(id: string) { - return id === "preact/jsx-runtime" ? id : null; - }, - load(id: string) { - if (id === "preact/jsx-runtime") { - const runtimePath = resolve.sync("preact/jsx-runtime", { - basedir: config.root, - }); - const exports = ["jsx", "jsxs", "Fragment"]; - return [ - `import * as jsxRuntime from ${JSON.stringify(runtimePath)}`, - // We can't use `export * from` or else any callsite that uses - // this module will be compiled to `jsxRuntime.exports.jsx` - // instead of the more concise `jsx` alias. - ...exports.map(name => `export const ${name} = jsxRuntime.${name}`), - ].join("\n"); - } - }, async transform(code, url) { // Ignore query parameters, as in Vue SFC virtual modules. const { id } = parseId(url);