Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antfu/vite-node
Vite as Node.js runtime
https://github.com/antfu/vite-node
node runtime vite
Last synced: 4 days ago
JSON representation
Vite as Node.js runtime
- Host: GitHub
- URL: https://github.com/antfu/vite-node
- Owner: antfu
- License: mit
- Archived: true
- Created: 2021-10-08T17:45:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-13T05:53:40.000Z (almost 3 years ago)
- Last Synced: 2024-08-01T17:35:43.657Z (3 months ago)
- Topics: node, runtime, vite
- Language: JavaScript
- Homepage:
- Size: 228 KB
- Stars: 424
- Watchers: 14
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Project Moved to [Vitest Monorepo](https://github.com/vitest-dev/vitest/tree/main/packages/vite-node)
# vite-node
[![NPM version](https://img.shields.io/npm/v/vite-node?color=a1b858&label=)](https://www.npmjs.com/package/vite-node)
Vite as Node runtime.
> **EXPERIMENTAL**
## Usage
```bash
npx vite-node index.ts
```Options:
```bash
npx vite-node -h
```## Features
- Out-of-box ESM & TypeScript support (possible for more with plugins)
- Top-level await
- Vite plugins, resolve, aliasing
- Respect `vite.config.ts`
- Shims for `__dirname` and `__filename` in ESM
- Access to native node modules like `fs`, `path`, etc.
- Watch mode (like `nodemon`)## 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 need to start a Vite server upon each execution, which inevitably introduces some overhead. Only use it when you want the same behavior as Vite or the powerful plugins system (for example, testing components with a Vite-specific setup).## Why?
It runs Vite's id resolving, module transforming, and most importantly, the powerful plugins system!
## How?
It fires up a Vite dev server, transforms the requests, and runs them in Node.
## Credits
Based on [@pi0](https://github.com/pi0)'s brilliant idea of having a Vite server as the on-demand transforming service for [Nuxt's Vite SSR](https://github.com/nuxt/vite/pull/201).
Thanks [@brillout](https://github.com/brillout) for kindly sharing this package name.
## Sponsors
## License
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)