Skip to content

masslbs/deno-vite-plugin

 
 

Repository files navigation

MassLabs fork

We forked github.com/denoland/deno-vite-plugin/ because of performance issues centered around unlimited external program invocations of deno info --json:

Care has been taken to avoid introducing changes in the final output arrived at by running this version of deno-vite-plugin compared to the upstream version. The result of this fork is that it uses a bounded amount of memory and its execution time is faster after a first run has populated the cache.

This fork:

  • uses a lock to limit external calls to deno info --json
  • improves how the in-memory cache is used by catching more cases
  • implements an on-disk cache, speeding up initial loading considerably

The on-disk cache is only written after a clean exit from vite, or when the server restarts as that is when Rollup's buildEnd phase runs.

Prevent the on-disk cache from being used by setting the environment variable NOCACHE e.g. NOCACHE="1" deno run dev. This can be helpful if debugging any build errors that may/may not have to do with caching.

Logging what the plugin is doing at any point in time can be enabled by providing DEBUG=deno-vite-plugin or DEBUG=*.


Deno vite plugin

Plugin to enable Deno resolution inside vite. It supports:

  • Alias mappings in deno.json
  • npm: specifier
  • jsr: specifier
  • http: and https: specifiers

Limitations

Deno specific resolution cannot be used in vite.config.ts because it's not possible to intercept the bundling process of the config file in vite.

Usage

Install this package:

# npm
npm install @deno/vite-plugin
# pnpm
pnpm install @deno/vite-plugin
# deno
deno install npm:@deno/vite-plugin

Add the plugin to your vite configuration file vite.config.ts:

  import { defineConfig } from "vite";
+ import deno from "@deno/vite-plugin";

  export default defineConfig({
+   plugins: [deno()],
  });

License

MIT, see the license file.

About

Vite plugin to enable Deno resolution inside vite.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%