Skip to content

Commit 9b83a1e

Browse files
fix(vite): cover more commonjs cases (#3465)
Fixes #3463 Fixes #3449
1 parent a6016fc commit 9b83a1e

File tree

9 files changed

+348
-82
lines changed

9 files changed

+348
-82
lines changed

deno.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@std/dotenv": "jsr:@std/dotenv@^0.225.5",
4848
"@std/http": "jsr:@std/http@^1.0.15",
4949
"@std/uuid": "jsr:@std/uuid@^1.0.7",
50+
"@supabase/postgrest-js": "npm:@supabase/postgrest-js@^1.21.4",
5051
"@types/node": "npm:@types/node@^24.3.0",
5152
"docsearch": "https://esm.sh/@docsearch/js@3.5.2?target=es2020",
5253
"esbuild": "npm:esbuild@0.25.7",
@@ -76,6 +77,7 @@
7677
"@std/testing": "jsr:@std/testing@^1.0.12",
7778

7879
"@tailwindcss/postcss": "npm:@tailwindcss/postcss@^4.1.10",
80+
"redis": "npm:redis@^5.8.2",
7981
"rollup": "npm:rollup@^4.50.0",
8082
"tailwindcss": "npm:tailwindcss@^4.1.10",
8183
"postcss": "npm:postcss@8.5.6",

deno.lock

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as redis from "redis";
2+
3+
export default function Page() {
4+
// deno-lint-ignore no-console
5+
console.log(redis);
6+
return <h1>redis</h1>;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as supabase from "@supabase/postgrest-js";
2+
3+
export default function Page() {
4+
// deno-lint-ignore no-console
5+
console.log(supabase);
6+
return <h1>supabase</h1>;
7+
}

packages/plugin-vite/src/plugins/deno.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export function deno(): Plugin {
5353
},
5454
async resolveId(id, importer, options) {
5555
if (BUILTINS.has(id)) {
56-
if (!id.startsWith("node:") && BUILTINS.has(`node:${id}`)) {
56+
// `node:` prefix is not included in builtins list.
57+
if (!id.startsWith("node:")) {
5758
id = `node:${id}`;
5859
}
5960
return {

packages/plugin-vite/src/plugins/patches/code_eval.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,6 @@ export function codeEvalPlugin(
3434
}
3535
},
3636
},
37-
CallExpression: {
38-
enter(path) {
39-
if (
40-
t.isMemberExpression(path.node.callee) &&
41-
t.isIdentifier(path.node.callee.object) &&
42-
t.isIdentifier(path.node.callee.property) &&
43-
path.node.callee.object.name === "Object" &&
44-
path.node.callee.property.name === "defineProperty" &&
45-
path.node.arguments.length >= 2
46-
) {
47-
const args = path.node.arguments;
48-
49-
if (
50-
t.isIdentifier(args[0]) && args[0].name === "exports" ||
51-
t.isMemberExpression(args[0]) &&
52-
t.isIdentifier(args[0].object) &&
53-
t.isIdentifier(args[0].property) &&
54-
args[0].object.name === "module" &&
55-
args[0].property.name === "exports" &&
56-
t.isStringLiteral(args[1]) && args[1].value === "native"
57-
) {
58-
path.remove();
59-
}
60-
}
61-
},
62-
},
6337
},
6438
};
6539
};

0 commit comments

Comments
 (0)