Vite has an internal check that limits CommonJS detection to only bare specifier. This doesn't work well together with us resolving npm modules to absolute file paths. https://github.com/vitejs/vite/blob/main/packages/vite/src/node/ssr/fetchModule.ts#L46 I've tried re-using our own instance of `@rollup/plugin-commonjs` or `esbuild` but couldn't get these to work in that setup. The easiest way seems to be to just write our own CJS -> ESM translation layer. With a little luck since the Deno ecosystem is heavy into ESM we might get away with this. In either way this removes one of the two blockers to using the vite plugin.
EXPERIMENTAL: vite plugin for Fresh
Warning
This package is experimental. Please report bugs to https://github.com/denoland/fresh/issues
Usage
- Run
deno install jsr:@fresh/plugin-vite npm:vite - Ensure that your
deno.jsonhas thefreshimport mapping:
{
"imports": {
"fresh": "jsr:@fresh/core"
}
}
- Update your
vite.config.tsfile:
import { defineConfig } from "vite";
+ import { fresh } from "@fresh/plugin-vite";
export default defineConfig({
plugins: [
+ fresh(),
],
});
- Update your deno tasks respectively:
- Dev:
vite - Build:
vite build