## Summary - **Replace Babel env var transforms with Vite's native `define`** — `process.env.FRESH_PUBLIC_*` and `import.meta.env.FRESH_PUBLIC_*` now use Vite's built-in `define` config. `Deno.env.get()` calls use a lightweight regex-based transform (~10 lines vs 78-line Babel plugin). - **Remove the 960-line CJS→ESM Babel transform** — Instead of transforming CJS to ESM via Babel, let Vite handle CJS packages natively: - **Build mode**: Rollup's `@rollup/plugin-commonjs` handles CJS (always has, but was bypassed by `deno.ts` loading through `@deno/loader`) - **Dev mode**: A ~30-line CJS shim wraps `node_modules` CJS files with `module`/`exports`/`require` so Vite's SSR module runner can evaluate them - `deno.ts` no longer attaches `meta.deno` to file:// resolved paths — Vite loads them from disk directly - **Remove `noDiscovery: true`** — Vite's dependency optimizer can now pre-bundle CJS packages for the client - **Fix React compat aliasing** — Apply `resolve.alias` (react → preact/compat) in `deno.ts` before `@deno/loader` resolution, so the alias works even when packages are non-external in SSR Net: **~2,050 lines deleted**, ~150 lines added. Fixes #3619, fixes #3653, fixes #3505, fixes #3478, fixes #3449.
27 lines
986 B
TypeScript
27 lines
986 B
TypeScript
import { expect } from "@std/expect";
|
|
import { fresh } from "../src/mod.ts";
|
|
import type { Plugin } from "vite";
|
|
|
|
Deno.test("fresh plugin - sets server.watch.ignored patterns", async () => {
|
|
const plugins = fresh() as Plugin[];
|
|
const freshPlugin = plugins.find((p) => p.name === "fresh");
|
|
expect(freshPlugin).toBeDefined();
|
|
|
|
// Call the config hook as Vite would during dev
|
|
// deno-lint-ignore no-explicit-any
|
|
const configFn = freshPlugin!.config as any;
|
|
const result = await configFn({}, { command: "serve" });
|
|
|
|
const ignored = result?.server?.watch?.ignored;
|
|
expect(ignored).toBeDefined();
|
|
expect(Array.isArray(ignored)).toBe(true);
|
|
|
|
// Should ignore temp files, editor swap files, and Vite timestamp files
|
|
expect(ignored).toContain("**/*.tmp.*");
|
|
expect(ignored).toContain("**/*.timestamp-*");
|
|
expect(ignored).toContain("**/*.swp");
|
|
expect(ignored).toContain("**/*.swo");
|
|
expect(ignored).toContain("**/*~");
|
|
expect(ignored).toContain("**/.#*");
|
|
});
|