Skip to content

Commit 6211b60

Browse files
sapphi-redInterpause
authored andcommitted
fix: support vite v3 (preactjs#50)
1 parent 91c3d84 commit 6211b60

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";
@@ -89,24 +88,6 @@ export default function preactPlugin({
8988
configResolved(resolvedConfig) {
9089
config = resolvedConfig;
9190
},
92-
resolveId(id: string) {
93-
return id === "preact/jsx-runtime" ? id : null;
94-
},
95-
load(id: string) {
96-
if (id === "preact/jsx-runtime") {
97-
const runtimePath = resolve.sync("preact/jsx-runtime", {
98-
basedir: config.root,
99-
});
100-
const exports = ["jsx", "jsxs", "Fragment"];
101-
return [
102-
`import * as jsxRuntime from ${JSON.stringify(runtimePath)}`,
103-
// We can't use `export * from` or else any callsite that uses
104-
// this module will be compiled to `jsxRuntime.exports.jsx`
105-
// instead of the more concise `jsx` alias.
106-
...exports.map(name => `export const ${name} = jsxRuntime.${name}`),
107-
].join("\n");
108-
}
109-
},
11091
async transform(code, url) {
11192
// Ignore query parameters, as in Vue SFC virtual modules.
11293
const { id } = parseId(url);

0 commit comments

Comments
 (0)