buffer, stream, or crypto, you see a resolution error at build time. Below you can learn when to add polyfills and when to choose a browser-native alternative.
When Node polyfills are a good fit
- A required dependency needs Node core modules in browser runtime.
- You are incrementally migrating code from Node-centric packages.
- You can accept larger bundles for specific runtime capabilities.
Template examples
new-typescript

content-typescript

new-crypto

crypto polyfill usage in a new-tab extension.
Default behavior
- Build target is browser-first (
web). - Resolution prioritizes browser exports (
browser,module,main). - Extension.js disables Node core fallbacks (for example,
crypto,path, andfs) by default.
Setting up Node polyfills
Useextension.config.js (or .mjs / .cjs) to extend the Rspack configuration and define safe fallbacks.
Install optional polyfill packages
Extension APIs vs Node APIs
Settingpolyfill: true in CLI/config enables webextension-polyfill, a compatibility layer that gives Chromium browsers access to the browser.* API namespace. It does not enable Node core module polyfills.
Use Node polyfills only for libraries that cannot run with standard Web APIs.
Caveats
- Do not assume filesystem access in extension runtime; keep
fs: falseunless you have a very specific browser-safe strategy. - Prefer Web Crypto (
crypto.subtle) over large Node crypto shims when possible. - Polyfills (browser-compatible replacements for Node APIs) increase bundle size and can affect startup time in extension pages and content scripts.
- Some packages using
node:specifiers may need explicit fallback handling.
Next steps
- Learn how to customize Rspack configuration.
- Learn how to manage Extension configuration.

