vite-node
Advanced tools
Comparing version 0.0.5 to 0.0.140
{ | ||
"name": "vite-node", | ||
"version": "0.0.5", | ||
"description": "Vite as Node runtime", | ||
"keywords": [ | ||
"vite" | ||
], | ||
"homepage": "https://github.com/antfu/vite-node#readme", | ||
"version": "0.0.140", | ||
"description": "Vite as Node.js runtime", | ||
"homepage": "https://github.com/vitest-dev/vitest#readme", | ||
"bugs": { | ||
"url": "https://github.com/antfu/vite-node/issues" | ||
"url": "https://github.com/vitest-dev/vitest/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/antfu/vite-node.git" | ||
"url": "git+https://github.com/vitest-dev/vitest.git", | ||
"directory": "packages/vite-node" | ||
}, | ||
@@ -19,46 +17,52 @@ "funding": "https://github.com/sponsors/antfu", | ||
"author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./index.mjs" | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./client": { | ||
"import": "./dist/client.js", | ||
"types": "./dist/client.d.ts" | ||
}, | ||
"./server": { | ||
"import": "./dist/server.js", | ||
"types": "./dist/server.d.ts" | ||
}, | ||
"./utils": { | ||
"import": "./dist/utils.js", | ||
"types": "./dist/utils.d.ts" | ||
} | ||
}, | ||
"main": "index.mjs", | ||
"module": "index.mjs", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"bin": { | ||
"vite-node": "./bin/vite-node.js" | ||
"vite-node": "./vite-node.js" | ||
}, | ||
"files": [ | ||
"index.mjs", | ||
"bin" | ||
"dist", | ||
"*.d.ts", | ||
"*.mjs" | ||
], | ||
"dependencies": { | ||
"debug": "^4.3.2", | ||
"kolorist": "^1.5.0", | ||
"kolorist": "^1.5.1", | ||
"minimist": "^1.2.5", | ||
"vite": "^2.6.5" | ||
"mlly": "^0.3.17", | ||
"pathe": "^0.2.0", | ||
"vite": "^2.7.10" | ||
}, | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^0.9.0", | ||
"@antfu/ni": "^0.10.0", | ||
"@types/debug": "^4.1.7", | ||
"@types/node": "^16.10.3", | ||
"@vitejs/plugin-vue": "^1.9.3", | ||
"bumpp": "^7.1.1", | ||
"eslint": "^7.32.0", | ||
"esno": "^0.10.1", | ||
"typescript": "^4.4.3", | ||
"uvu": "^0.5.2", | ||
"vue": "^3.2.20" | ||
"@types/minimist": "^1.2.2", | ||
"rollup": "^2.63.0" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=14.14.0" | ||
}, | ||
"scripts": { | ||
"lint": "eslint \"**/*.{ts,mjs}\"", | ||
"release": "bumpp --commit --push --tag && pnpm publish", | ||
"start": "DEBUG=vite-node:* node index.mjs", | ||
"test": "node index.mjs -c test/vite.config.ts --vue test/index.test.mjs" | ||
} | ||
"build": "rimraf dist && rollup -c", | ||
"dev": "rollup -c --watch --watch.include=src/**", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"readme": "# vite-node\n\n[![NPM version](https://img.shields.io/npm/v/vite-node?color=a1b858&label=)](https://www.npmjs.com/package/vite-node)\n\nVite as Node runtime. The engine powers [Vitest](https://github.com/vitest-dev/vitest).\n\n## Features\n\n- Out-of-box ESM & TypeScript support (possible for more with plugins)\n- Top-level await\n- Vite plugins, resolve, aliasing\n- Respect `vite.config.ts`\n- Shims for `__dirname` and `__filename` in ESM\n- Access to native node modules like `fs`, `path`, etc.\n\n## CLI Usage\n\nRun JS/TS file on Node.js using Vite's resolvers and transformers.\n\n```bash\nnpx vite-node index.ts\n```\n\nOptions:\n\n```bash\nnpx vite-node -h\n```\n\n## Programmatic Usage\n\nIn Vite Node, the server and runner (client) are separated, so you can integrate them in different contexts (workers, cross-process, or remote) if needed. The demo below shows a simple example of having the server and running in the same context\n\n```ts\nimport { createServer } from 'vite'\nimport { ViteNodeServer } from 'vite-node/server'\nimport { ViteNodeRunner } from 'vite-node/client'\n\n// create vite server\nconst server = await createServer()\n// this is need to initialize the plugins\nawait server.pluginContainer.buildStart({})\n\n// create vite-node server\nconst node = new ViteNodeServer(server)\n\n// create vite-node runner\nconst runner = new ViteNodeRunner({\n root: server.config.root,\n base: server.config.base,\n // when having the server and runner in a different context,\n // you will need to handle the communication between them\n // and pass to this function\n fetchModule(id) {\n return node.fetchModule(id)\n },\n})\n\n// execute the file\nawait runner.run('./example.ts')\n\n// close the vite server\nawait server.close()\n```\n\n## Credits\n\nBased 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).\n\nThanks [@brillout](https://github.com/brillout) for kindly sharing this package name.\n\n## Sponsors\n\n<p align=\"center\">\n <a href=\"https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg\">\n <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>\n </a>\n</p>\n\n## License\n\n[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)\n" | ||
} |
@@ -5,9 +5,17 @@ # vite-node | ||
Vite as Node runtime. | ||
Vite as Node runtime. The engine powers [Vitest](https://github.com/vitest-dev/vitest). | ||
> **EXPERIMENTAL** | ||
## 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. | ||
## Usage | ||
## CLI Usage | ||
Run JS/TS file on Node.js using Vite's resolvers and transformers. | ||
```bash | ||
@@ -23,25 +31,37 @@ npx vite-node index.ts | ||
## Features | ||
## Programmatic Usage | ||
- 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`) | ||
In Vite Node, the server and runner (client) are separated, so you can integrate them in different contexts (workers, cross-process, or remote) if needed. The demo below shows a simple example of having the server and running in the same context | ||
## When NOT to Use | ||
```ts | ||
import { createServer } from 'vite' | ||
import { ViteNodeServer } from 'vite-node/server' | ||
import { ViteNodeRunner } from 'vite-node/client' | ||
- 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). | ||
// create vite server | ||
const server = await createServer() | ||
// this is need to initialize the plugins | ||
await server.pluginContainer.buildStart({}) | ||
## Why? | ||
// create vite-node server | ||
const node = new ViteNodeServer(server) | ||
It runs Vite's id resolving, module transforming, and most importantly, the powerful plugins system! | ||
// create vite-node runner | ||
const runner = new ViteNodeRunner({ | ||
root: server.config.root, | ||
base: server.config.base, | ||
// when having the server and runner in a different context, | ||
// you will need to handle the communication between them | ||
// and pass to this function | ||
fetchModule(id) { | ||
return node.fetchModule(id) | ||
}, | ||
}) | ||
## How? | ||
// execute the file | ||
await runner.run('./example.ts') | ||
It fires up a Vite dev server, transforms the requests, and runs them in Node. | ||
// close the vite server | ||
await server.close() | ||
``` | ||
@@ -48,0 +68,0 @@ ## Credits |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22910
2
14
489
83
5
6
1
+ Addedmlly@^0.3.17
+ Addedpathe@^0.2.0
+ Addedmlly@0.3.19(transitive)
+ Addedpathe@0.2.0(transitive)
+ Addedpostcss@8.4.45(transitive)
- Removeddebug@^4.3.2
- Removeddebug@4.3.7(transitive)
- Removedms@2.1.3(transitive)
- Removedpostcss@8.4.47(transitive)
Updatedkolorist@^1.5.1
Updatedvite@^2.7.10