denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.44k stars 5.37k forks source link

Support Vite #15427

Closed brillout closed 1 year ago

brillout commented 2 years ago

Is supporting Vite on Deno's radar?

Although many Node.js libraries already work with Deno, Vite is a whole different beast and probably needs changes on Deno's side.

Note that it's not only about supporting Vite, but also its entire ecosystem (SvelteKit, vite-plugin-ssr, etc.).

FYI Bun is working on supporting Vite: https://github.com/oven-sh/bun/issues/250#issuecomment-1195153860.

Ciantic commented 2 weeks ago

When running deno run -A --node-modules-dir npm:vite , will vite be using Node in any way under the hood? I noticed that Bun for now has a --bun flag specifically to make sure that Vite isn't using node under the hood, but I don't know what is the case for deno.

As far as I know Vite will run fully in Deno.

I don't think it always does, I'm getting import errors, same as with bun (without --bun flag)

Like this:

[vite] Error when evaluating SSR module C:/Source/JavaScript/solid-start-test/deno-solid-test/src/routes/index.tsx?pick=default&pick=$css: failed to import "jsr:@db/sqlite@0.12"

Indicating that it is not using deno, because deno knows how to import from jsr.

Update It might be that vinxi, that is now popular way to run vite's dev server doesn't support deno 😢

fro-furnishedfinder commented 2 weeks ago

When running deno run -A --node-modules-dir npm:vite , will vite be using Node in any way under the hood?

I noticed that Bun for now has a --bun flag specifically to make sure that Vite isn't using node under the hood, but I don't know what is the case for deno.

As far as I know Vite will run fully in Deno.

I don't think it always does, I'm getting import errors, same as with bun (without --bun flag)

Like this:


[vite] Error when evaluating SSR module C:/Source/JavaScript/solid-start-test/deno-solid-test/src/routes/index.tsx?pick=default&pick=$css: failed to import "jsr:@db/sqlite@0.12"

Indicating that it is not using deno, because deno knows how to import from jsr.

Update It might be that vinxi, that is now popular way to run vite's dev server doesn't support deno 😢

Vite is a bundler, no matter if you run in with node, deno or bun, if vite doesn't understand how to resolve imports it won't work.

Here es the deno vite resolver for jsr imports https://github.com/denoland/deno-vite-plugin

wesbos commented 2 weeks ago

It does run in Deno! So I had an npm script like this:

"vite": "vite"

running deno task vite fired it up and it ... just worked? So I came here wondering if Vite was running a node child_process under the hood - it's not!

Confirmed by opening up my activity monitor - ensuring no node or deno processes were running. Upon starting - it fires up two deno processes.

Screenshot 2024-10-24 at 2 50 17 PM
Ciantic commented 2 weeks ago

Problem is that vite doesn't support JSR imports, it just appears as same kind of error as bun without --bun switch, I made a pull request: https://github.com/vitejs/vite/pull/18479

fro-profesional commented 2 weeks ago

Problem is that vite doesn't support JSR imports, it just appears as same kind of error as bun without --bun switch, I made a pull request: https://github.com/vitejs/vite/pull/18479

Does the deno resolver doesn't work for you? https://github.com/denoland/deno-vite-plugin

fro-profesional commented 2 weeks ago

Problem is that vite doesn't support JSR imports, it just appears as same kind of error as bun without --bun switch, I made a pull request: vitejs/vite#18479

Does the deno resolver doesn't work for you? https://github.com/denoland/deno-vite-plugin

I tried with the deno vite plugin with a Vinxi project shared with @Ciantic and It did not worked, there is an issue to track tho https://github.com/denoland/deno/issues/26569