Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Using Deno as a server with vite #6553

Closed
4 tasks done
mathe42 opened this issue Jan 18, 2022 · 5 comments
Closed
4 tasks done

Feature Request: Using Deno as a server with vite #6553

mathe42 opened this issue Jan 18, 2022 · 5 comments

Comments

@mathe42
Copy link
Contributor

mathe42 commented Jan 18, 2022

Clear and concise description of the problem

Disclaimer: To avoid confusion: This is NOT a proposal to run vite inside deno!

I thought that it should be quite easy to modify vite so I can use it together with deno:

The following example my Deno entrypoint is src/server.ts than I could start vite and start deno with

deno run -r http://localhost:3000/src/server.ts

(The -r flag is so deno don't use cached files)

I run into some errors as HTMLElement and CustomElements and location is not defined in deno but I could modify the dist/client/client.mjs file so Deno runs and I also got a simple HMR working.

(Note that I want to use the SAME vite instance to develop my vue application)

Suggested solution

I'm quite shure that this is nothing a plugin can handle (maybe by modify the @vite/client import but that seems like a hack and I'm not shure how easy this can be done).

Is this something to add to 'core' vite? - If yes I'm happy to work on it and create a PR.

Changes would include

  1. files in src/client (content AND maybe structure)
  2. Maybe other files wher code uses CLIENT_PUBLIC_PATH or @vite/client
  3. Propably build config for files in src/client

Alternative

No response

Additional context

No response

Validations

@Niputi
Copy link
Contributor

Niputi commented Jan 18, 2022

you can follow Deno compatability here denoland/deno#12577

@Niputi Niputi closed this as completed Jan 18, 2022
@mathe42
Copy link
Contributor Author

mathe42 commented Jan 18, 2022

That is not what I meant I dont want to run the vite code on Deno but create a Deno Server with vite.

@Niputi
Copy link
Contributor

Niputi commented Jan 18, 2022

then please include error message and preferably a reproduction

@Niputi Niputi reopened this Jan 18, 2022
@mathe42
Copy link
Contributor Author

mathe42 commented Jan 18, 2022

The main question is if this is something a plugin can not fix / handle is that something that is wanted in vite or not. And I'm happy to work on a PR!

reproduction see https://github.com/mathe42/vite-deno-repro

The modified client.mjs is the same I only removed some usage of location.PROPERTY and the ErrorOverlay. As location.reload() doesn't exist in Deno it currently exit the process if that function is called (as it not exists).

@mathe42
Copy link
Contributor Author

mathe42 commented Jan 18, 2022

Got it working with a plugin... Also for NodeJS development!

For all interested https://github.com/mathe42/vite-plugin-server

@mathe42 mathe42 closed this as completed Jan 18, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants