feat(vite): error when using Deno global in the browser (#3305)
Related https://github.com/denoland/fresh/issues/3296
This commit is contained in:
@@ -388,3 +388,27 @@ Deno.test({
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "vite build - throw when using Deno.* global inside an island",
|
||||
fn: async () => {
|
||||
const fixture = path.join(FIXTURE_DIR, "deno_global_island");
|
||||
|
||||
await expect(buildVite(fixture)).rejects.toThrow(
|
||||
"The Deno.* global cannot be used in the browser",
|
||||
);
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "vite build - don't throw when using Deno.* global in ssr",
|
||||
fn: async () => {
|
||||
const fixture = path.join(FIXTURE_DIR, "deno_global_ssr");
|
||||
|
||||
await buildVite(fixture);
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export function Foo() {
|
||||
return <h1>{Deno.cwd()}</h1>;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { App, staticFiles } from "@fresh/core";
|
||||
|
||||
export const app = new App()
|
||||
.use(staticFiles())
|
||||
.fsRoutes();
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Foo } from "../islands/Foo.tsx";
|
||||
|
||||
export default function Hello() {
|
||||
return <Foo />;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [fresh()],
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import { App, staticFiles } from "@fresh/core";
|
||||
|
||||
export const app = new App()
|
||||
.use(staticFiles())
|
||||
.fsRoutes();
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Hello() {
|
||||
return <h1>{Deno.cwd()}</h1>;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [fresh()],
|
||||
});
|
||||
Reference in New Issue
Block a user