fix(vite): remove Deno global check (#3401)

Ultimately, it causes more problems than it solves.
This commit is contained in:
Marvin Hagemeister
2025-09-12 10:01:37 +02:00
committed by GitHub
parent c22c20e21f
commit 9581d7e6d4
3 changed files with 0 additions and 65 deletions
@@ -1,36 +0,0 @@
import type { PluginObj, types } from "@babel/core";
export function denoGlobal({ types: t }: { types: typeof types }): PluginObj {
return {
name: "fresh-deno-global",
visitor: {
Identifier(path) {
if (path.node.name === "Deno") {
// Ignore `Deno.env.get()` calls. Those will be inlined.
if (
t.isMemberExpression(path.parent) &&
path.parent.object === path.node &&
t.isIdentifier(path.parent.property) &&
path.parent.property.name === "env" &&
t.isMemberExpression(path.parentPath?.parent) &&
t.isIdentifier(path.parentPath?.parent.property) &&
path.parentPath?.parent.property.name === "get"
) {
return;
}
// Ignore `Deno?.thing` expression. Those will result in undefined, and that might be used for shims.
if (
t.isOptionalMemberExpression(path.parent) &&
path.parent.object === path.node
) {
return;
}
throw path.buildCodeFrameError(
`The Deno.* global cannot be used in the browser.`,
);
}
},
},
};
}