Skip to content

Commit 202fe1c

Browse files
sapphi-redInterpause
authored andcommitted
fix: support vite v3 (preactjs#50)
1 parent 90069cf commit 202fe1c

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"peerDependencies": {
4444
"@babel/core": "7.x",
45-
"vite": "2.x"
45+
"vite": "2.x || 3.x"
4646
},
4747
"devDependencies": {
4848
"@babel/core": "^7.15.8",

src/index.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { FilterPattern } from "@rollup/pluginutils";
33
import type { ParserPlugin, ParserOptions } from "@babel/parser";
44
import type { TransformOptions } from "@babel/core";
55

6-
import resolve from "resolve";
76
import prefresh from "@prefresh/vite";
87
import { preactDevtoolsPlugin } from "./devtools.js";
98
import { createFilter, parseId } from "./utils.js";
@@ -94,24 +93,6 @@ export default function preactPlugin({
9493
configResolved(resolvedConfig) {
9594
config = resolvedConfig;
9695
},
97-
resolveId(id: string) {
98-
return id === "preact/jsx-runtime" ? id : null;
99-
},
100-
load(id: string) {
101-
if (id === "preact/jsx-runtime") {
102-
const runtimePath = resolve.sync("preact/jsx-runtime", {
103-
basedir: config.root,
104-
});
105-
const exports = ["jsx", "jsxs", "Fragment"];
106-
return [
107-
`import * as jsxRuntime from ${JSON.stringify(runtimePath)}`,
108-
// We can't use `export * from` or else any callsite that uses
109-
// this module will be compiled to `jsxRuntime.exports.jsx`
110-
// instead of the more concise `jsx` alias.
111-
...exports.map(name => `export const ${name} = jsxRuntime.${name}`),
112-
].join("\n");
113-
}
114-
},
11596
async transform(code, url) {
11697
// Ignore query parameters, as in Vue SFC virtual modules.
11798
const { id } = parseId(url);

0 commit comments

Comments
 (0)