-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
Problem Description
The @ringcentral/sdk package requires numerous Node.js-specific polyfills to work in browser environments:
bufferprocesscrypto-browserifystream-browserifyvm-browserifyeventspath-browserifyurl
This creates the following issues:
- Increased bundle size — polyfills add significant code overhead
- Complex bundler configuration — requires explicit
resolve.fallbackandProvidePluginsetup - Incompatibility with modern runtimes — Edge Functions, Cloudflare Workers, Deno, and other environments do not support Node.js APIs
Current Configuration
Official recommendation from RingCentral (webpack.js):
plugins: [
// Workaround for Buffer is undefined:
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
// Workaround for process is undefined:
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify'),
process: require.resolve('process/browser'),
buffer: require.resolve('buffer'),
events: require.resolve('events'),
path: require.resolve('path-browserify'),
url: require.resolve('url'),
},
},Proposed Solution
Migrate to browser APIs that work across all modern runtimes:
| Node.js API | Browser Alternative |
|---|---|
Buffer |
Uint8Array, TextEncoder/TextDecoder |
crypto |
Web Crypto API (crypto.subtle) |
process.env |
Build-time inline substitution |
stream |
ReadableStream/WritableStream (Web Streams API) |
events |
EventTarget |
url |
URL (already available in browsers) |
path |
Simple string operations or remove dependency |
Benefits of Migration
- Universal compatibility — code will work in browsers, Deno, Cloudflare Workers, Vercel Edge, etc.
- Smaller bundle size — no heavy polyfills required
- Simplified integration — users don't need to configure their bundler
- Standards compliance — Web APIs are W3C/WHATWG standards
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels