JSPM

vite-node

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16009342
  • Score
    100M100P100Q202755F
  • License MIT

Vite as Node runtime

Package Exports

  • vite-node

Readme

vite-node

NPM version

Vite as Node runtime.

EXPERIMENTAL

Why?

It runs Vite's id resolving, module transforming, and most importantly, the powerful plugins system!

Usage

npx vite-node index.ts

Features

  • Out-of-box ESM & TypeScript support (possible for more with plugins)
  • Top-level await
  • Shims for __dirname and __filename
  • Respect vite.config.ts
  • Access to node modules like fs, path etc.

When NOT to Use

  • Production, yet - in very early stage, check it later
  • Most of the time when other tools can do that job
    • We will need to start a Vite server upon each execution, which will have certain overhead. Only use it when you want the exactly same behavior as Vite or the powerful plugins system (for example, testing components that have Vite-specific setup).

How?

It fires up a Vite dev server, transforms the requests, and runs them in Node.

Credits

Based on @pi0's brilliant idea of having a Vite server as the on-demand transforming service for Nuxt's Vite SSR.

Thanks @brillout for kindly sharing this package name.

Sponsors

License

MIT License © 2021 Anthony Fu