{"_id":"@abundantui/ripgrep","name":"@abundantui/ripgrep","dist-tags":{"latest":"0.1.1-webcontainer.0"},"versions":{"0.1.1-webcontainer.0":{"name":"@abundantui/ripgrep","version":"0.1.1-webcontainer.0","repository":{"type":"git","url":"git+https://github.com/jonathanpv/ripgrep.git"},"license":"MIT","sideEffects":false,"type":"module","scripts":{"build":"zig build wasi && node build.ts","rg":"./lib/rg.mjs"},"exports":{".":"./lib/index.mjs"},"types":"./lib/index.d.mts","bin":{"rg":"lib/rg.mjs","ripgrep":"lib/rg.mjs"},"devDependencies":{"prettier":"^3.8.1"},"_id":"@abundantui/ripgrep@0.1.1-webcontainer.0","gitHead":"3f75c80b395adf18549ffc94e77ac927531bf6eb","description":"[ripgrep](https://github.com/BurntSushi/ripgrep) in a compact and cross-platform npm package. Works with Node.js, Bun, and Deno without native binaries. Bundler-friendly, with the WASM embedded as z85+brotli.","bugs":{"url":"https://github.com/jonathanpv/ripgrep/issues"},"homepage":"https://github.com/jonathanpv/ripgrep#readme","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-5mmEd6cm89BTeuJT2zHBhtI5akV7RolmwXzu2GVTNhd1950U+kIlYkcRSNHEb20+T8AA+KKxX9A7SryaY6Ib5g==","shasum":"51740fe18bab5b294263455f3271cc4b016f57f4","tarball":"https://registry.npmjs.org/@abundantui/ripgrep/-/ripgrep-0.1.1-webcontainer.0.tgz","fileCount":8,"unpackedSize":763266,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBPH6WNRqT537ltmmvsPjYjzr34U7EdS6rHi1RfxVRrmAiEAzRR7LPGOYbkKpKGrXndexj4GO4sFhvXEsKlFhSAERhA="}]},"_npmUser":{"name":"abundantui","email":"jonathanpadillaagency@gmail.com"},"directories":{},"maintainers":[{"name":"abundantui","email":"jonathanpadillaagency@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ripgrep_0.1.1-webcontainer.0_1775437785439_0.3415892148462911"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-06T01:09:45.334Z","0.1.1-webcontainer.0":"2026-04-06T01:09:45.643Z","modified":"2026-04-06T01:09:45.869Z"},"maintainers":[{"name":"abundantui","email":"jonathanpadillaagency@gmail.com"}],"description":"[ripgrep](https://github.com/BurntSushi/ripgrep) in a compact and cross-platform npm package. Works with Node.js, Bun, and Deno without native binaries. Bundler-friendly, with the WASM embedded as z85+brotli.","homepage":"https://github.com/jonathanpv/ripgrep#readme","repository":{"type":"git","url":"git+https://github.com/jonathanpv/ripgrep.git"},"bugs":{"url":"https://github.com/jonathanpv/ripgrep/issues"},"license":"MIT","readme":"# ripgrep-node\n\n[ripgrep](https://github.com/BurntSushi/ripgrep) in a compact and cross-platform npm package. Works with Node.js, Bun, and Deno without native binaries. Bundler-friendly, with the WASM embedded as z85+brotli.\n\n## CLI\n\n```sh\nnpx ripgrep TODO src/\n\n# or install globally\nnpm i -g ripgrep\nrg TODO src/\n```\n\n## Programmatic API\n\n```js\nimport { ripgrep, rgPath } from \"ripgrep\";\n\n// Run ripgrep programmatically\nconst { code } = await ripgrep([\"--json\", \"TODO\", \"src\"]);\n// 0 = matches found, 1 = no matches, 2 = error\n\n// Or spawn as a child process (drop-in for vscode-ripgrep)\nimport { spawn } from \"node:child_process\";\nspawn(rgPath, [\"TODO\", \"src\"], { stdio: \"inherit\" });\n```\n\n### `ripgrep(args, options)`\n\nRuns ripgrep with the given CLI arguments and returns a `{ code }` result object. Output is written to the host's `process.stdout` / `process.stderr`.\n\nOptions:\n\n- `env` — environment variables passed to the WASI instance (default: `process.env`).\n- `preopens` — WASI preopened directories mapping guest paths to host paths (default: `{ \".\": process.cwd() }`). Required for ripgrep to see any files on disk.\n- `returnOnExit` — when `true`, `proc_exit` returns the exit code instead of terminating the process (default: `true`).\n- `nodeWasi` — use Node's built-in `node:wasi` instead of the bundled WASI shim. Enabled by default on Node.js for best performance; automatically disabled on Bun and Deno where `node:wasi` is not available, falling back to the bundled shim. Can also be forced on via `ZIGREP_NODE_WASI=1`.\n\n### `rgPath`\n\nAbsolute filesystem path to a JS shim that runs ripgrep via `ripgrep`. Drop-in replacement for `rgPath` from `vscode-ripgrep` / `@vscode/ripgrep`-style consumers that spawn the binary directly.\n\n## How it works\n\n- ripgrep is cross-compiled to `wasm32-wasip1` via [`cargo zigbuild`](https://github.com/rust-cross/cargo-zigbuild), using Zig as the C compiler/linker.\n- The resulting `.wasm` is brotli-compressed and z85-encoded into `lib/_rg.wasm.mjs`, so it ships as a plain ESM module — no `.wasm` asset resolution or postinstall needed.\n- On first use, the z85 blob is decoded and decompressed, then cached to the OS temp directory (`$TMPDIR/ripgrep-wasm-<hash>.wasm`). Subsequent calls (even across processes) skip decoding entirely. The z85 string itself is wrapped in a function so V8 lazy-parses it only when needed.\n- The compiled `WebAssembly.Module` is memoized in-process — repeated `ripgrep()` calls only pay the compilation cost once. Fresh instances are still created per-call since WASI state (memory, file descriptors) is per-instance.\n- A minimal WASI preview1 shim (`lib/_wasi.mjs`, ~20 syscalls, backed by `node:fs`) instantiates the module. Works uniformly on Node, Bun, and Deno.\n- ripgrep's TTY color detection doesn't survive the WASI boundary, so `ripgrep()` auto-injects `--color=ansi` when the host stdout is a TTY and the caller hasn't picked a color mode.\n\n## Building from source\n\nRequirements:\n\n- `zig` (tested with 0.15.2)\n- `rustc` + `cargo` (tested with 1.90.0)\n- [`cargo-zigbuild`](https://github.com/rust-cross/cargo-zigbuild): `cargo install cargo-zigbuild`\n- `rustup target add wasm32-wasip1`\n\nThen:\n\n```sh\ngit submodule update --init --recursive\nzig build           # → dist/rg-wasm32-wasip1.wasm\nnode build.ts       # inline wasm into lib/_rg.wasm.mjs\n```\n\nNative cross-compiled binaries (macOS / Linux / Windows) are also available via `zig build native`, but they are not part of the published npm package — WASI is the only shipped flavor.\n\n## License\n\nMIT. ripgrep itself is licensed under MIT / Unlicense by its authors — see [vendor/ripgrep](vendor/ripgrep).\n","readmeFilename":"README.md","_rev":"1-cd3e0bfd198dc411bb5332a5fc52da2f"}