antfu / vite-node

Vite as Node.js runtime
MIT License
423 stars 9 forks source link

As a plugin (+ eventually merge into `vite`) #3

Open brillout opened 2 years ago

brillout commented 2 years ago

In addition to the current CLI mode, how about also offering a plugin mode:

import { server } from 'vite-node/plugin'

export default {
  plugins: [server({
    entry: './path/to/server.js'
  })]
}

So that when calling

$ vite

it would apply vite-node to ./path/to/server.js.

I'd argue to eventually merge vite-node into vite. With our progress https://github.com/vitejs/vite/discussions/4921 Vite will have first-class support for Node.js and then it would be super neat to merge vite-node into vite; it will make Vite the standard way of using TypeScript for Node.js.