npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unenv-nightly

v2.0.0-20241111-080453-894aa31

Published

<!-- automd:badges color=yellow packagephobia -->

Downloads

2,357,908

Readme

unenv

npm version npm downloads

unenv provides a collection of Node.js and Web polyfills and mocking utilities with configurable presets for converting JavaScript code and libraries to be platform and runtime agnostic, working in any environment including Browsers, Workers, Node.js, Cloudflare Workers, Deno.

Unenv is used by Nitro and Nuxt today.

[!NOTE] You are on the development (v2) branch. Check out v1 for the current release.

Install

# ✨ Auto-detect
npx nypm install -D unenv

# npm
npm install -D unenv

# yarn
yarn add -D unenv

# pnpm
pnpm install -D unenv

# bun
bun install -D unenv

# deno
deno install --dev unenv

Usage

Using env utility and built-in presets, unenv will provide an abstract configuration that can be used in bundlers (rollup.js, webpack, etc.).

import { env } from "unenv";

const { alias, inject, polyfill, external } = env({}, {}, {});

Note: You can provide as many presets as you want. unenv will merge them internally and the right-most preset has a higher priority.

Presets

node

(view source)

Suitable to convert universal libraries working in Node.js.

  • Add supports for global fetch API
  • Set Node.js built-ins as externals
import { env, node } from "unenv";

const envConfig = env(node, {});

nodeless

(view source)

Suitable to transform libraries made for Node.js to run in other JavaScript runtimes.

import { env, nodeless } from "unenv";

const envConfig = env(nodeless, {});

deno

(view source)

This preset can be used to extend nodeless to use Deno's Node.js API Compatibility (docs, docs).

[!WARNING] This preset is experimental and behavior might change!

import { env, nodeless, deno } from "unenv";

const envConfig = env(nodeless, deno, {});

cloudflare

(view source)

This preset can be used to extend nodeless to use Cloudflare Worker Node.js API Compatibility (docs).

[!WARNING] This preset is experimental and behavior might change!

[!NOTE] Make sure to enable nodejs_compat compatibility flag.

import { env, nodeless, cloudflare } from "unenv";

const envConfig = env(nodeless, cloudflare, {});

vercel

This preset can be used to extend nodeless to use Vercel Edge Node.js API Compatibility (docs).

[!WARNING] This preset is experimental and behavior might change!

import { env, nodeless, vercel } from "unenv";

const envConfig = env(nodeless, vercel, {});

Built-in Node.js modules

unenv provides a replacement for Node.js built-in modules compatible with any runtime.

(view source)

Package replacements

unenv provides a replacement for common npm packages for cross-platform compatibility.

(view source)

Manual mocking utils

// Magic proxy to replace any unknown API
import MockProxy from "unenv/runtime/mock/proxy";

// You can also create named mocks
const lib = MockProxy.__createMock__("lib", {
  /* overrides */
});

(view source)

Other polyfills

To discover other polyfills, please check ./src/runtime.

Nightly release channel

You can use the nightly release channel to try the latest changes in the main branch via unenv-nightly.

If directly using unenv in your project:

{
  "devDependencies": {
    "unenv": "npm:unenv-nightly"
  }
}

If using unenv via another tool (Nuxt or Nitro) in your project:

{
  "resolutions": {
    "unenv": "npm:unenv-nightly"
  }
}

License

Published under the MIT license. Made by @pi0 and community 💛


🤖 auto updated with automd