process

Lightweight browser polyfill for Node.js's process global, used by bundlers for isomorphic code

Library
npm
v0.11.10
129 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
42 /100 Fair
Development Activity 0
Maintenance 20
Community 76
Maturity 60
Momentum 12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
66 /100 Good
Architecture 62
Code Quality 68
Innovation 45
Learning Curve 90

process is a minimal shim that lets code written against Node.js’s built-in process global run unmodified in a browser bundle. In Node, require('process') simply re-exports the real global.process; in the browser, a lean browser.js implementation supplies just enough of the API — process.nextTick, process.env, process.argv, process.browser, and safe setTimeout/clearTimeout-backed timer fallbacks — for isomorphic libraries to keep working without a full process emulation layer.

It deliberately does not attempt to be a complete polyfill: its README explicitly scopes it to nextTick and little more, pointing users toward separate community shims (browser-process-hrtime, browser-stdout) for anything beyond that. Because bundlers like Browserify and Webpack automatically substitute this package whenever they detect code referencing the process global, it ends up bundled into a huge share of the JavaScript ecosystem’s browser builds without most developers ever installing it directly — reflected in its roughly 50 million weekly downloads against a comparatively small, rarely-updated codebase.

What You Get

  • In Node: a one-line passthrough (module.exports = global.process) that re-exports the real process object
  • In browsers: a browser.js shim providing process.nextTick, process.title, process.browser, process.env, and process.argv
  • Defensive setTimeout/clearTimeout wrapping that degrades gracefully across sandboxed or non-standard JS environments
  • A browser field in package.json so Browserify/Webpack automatically substitute the shim in browser builds
  • A deliberately minimal surface, keeping bundle size small since it’s implicitly pulled into countless browser bundles

Common Use Cases

  • Running an npm package written against Node’s process global (e.g. checking process.env.NODE_ENV) inside a Browserify or Webpack bundle
  • Detecting whether isomorphic code is executing in a browser via process.browser
  • Deferring work with process.nextTick in a library that targets both Node and browser environments
  • Acting as the implicit dependency bundlers inject automatically when they detect process usage in a dependency graph

Under The Hood

Architecture - The package is intentionally two files: index.js is a single line that re-exports Node’s real global.process for Node environments, while browser.js (184 lines) is the actual polyfill logic used when bundled for browsers, selected automatically via the browser field in package.json that tools like Browserify and Webpack understand. browser.js implements nextTick via a queue drained via setTimeout, with defensive try/catch wrapping around cached setTimeout/clearTimeout references to survive being run inside sandboxed evals, stubbed test runners, or strict-mode contexts where globals may not resolve normally. Tech Stack - Zero dependencies, plain ES5 JavaScript for maximum compatibility with older bundlers and browsers; tests run via Mocha (test.js) and, per package.json, previously via zuul for cross-browser test execution. Code Quality - The codebase is deliberately tiny and has changed very little since it stabilized around 2016 (activity_status: inactive, last commit 2020), which for a shim whose entire contract is ‘don’t crash when process is referenced’ is a sign of stability rather than neglect — the API surface it needs to cover hasn’t changed. The README explicitly documents scope boundaries (only nextTick and a few fields; hrtime/stdout are separate packages), which is good practice for keeping a widely-transitively-depended-on shim minimal. API Design - There is effectively no API to learn: consumers never import this package directly by design — it exists purely so bundlers can silently substitute it when code references the ambient process global, making its ‘API’ the same as Node’s native process object for the handful of properties it implements.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers