webextension-polyfill-global is a utility package designed to make Mozilla's `webextension-polyfill` readily available as a global `browser` object within web extensions, even when using bundlers like Webpack or Parcel. It addresses a known issue where the upstream `webextension-polyfill` can be challenging to import as a true global polyfill, often requiring manual `import()` calls or complex bundler configurations. This package simplifies that process by directly making the polyfill globally accessible upon import. The current stable version is 0.10.1-1. As a wrapper, its release cadence is typically tied to updates in the core `webextension-polyfill` or improvements in its global registration mechanism, though it has seen consistent maintenance. Its key differentiator is its singular focus on providing a simple, fire-and-forget global registration for the browser API, streamlining development for extension authors who prefer the `browser` global over explicit imports everywhere.
npm install webextension-polyfill-globalVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the polyfill and immediately use the global `browser` API.
Run `npm install webextension-polyfill` alongside `webextension-polyfill-global`.
Run `npm install @types/webextension-polyfill -D`.
Decide on a single strategy: either use this package for a global `browser` object and avoid explicit imports, or manage `webextension-polyfill` imports directly without `webextension-polyfill-global`.
Ensure `import 'webextension-polyfill-global';` is at the very top of your entry file (e.g., background.js, popup.js) or any script where the global `browser` object is needed.
Install the official TypeScript types: `npm install @types/webextension-polyfill -D`.