GitHub - niksy/node-stdlib-browser: Node standard library for browser.
source link: https://github.com/niksy/node-stdlib-browser
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
node-stdlib-browser
Node standard library for browser.
Features:
- Based on
node-libs-browser
for Webpack - Maintained with newer versions and modern implementations
- Works with Webpack, Rollup, esbuild and Browserify, but should also work with other bundlers
- Exports implementation with
node:
protocol which allows for builtin modules to be referenced by valid absolute URL strings
Check example to see how modules work in browser environment.
Install
npm install node-stdlib-browser --save-dev
Usage
Webpack
Show me
Rollup
Show me
esbuild
Show me
Browserify
Show me
Package contents
Module Browser implementation Mock implementation Notes
assert
assert
buffer
buffer
buffer
buffer@5
for IE 11 support
child_process
cluster
console
console-browserify
console
constants
constants-browserify
crypto
crypto-browserify
dgram
dns
domain
domain-browser
events
events
fs
http
stream-http
https
https-browserify
module
net
path
path-browserify
punycode
punycode
punycode@1
for browser support
querystring
querystring-es3
Contains additional exports from newer Node versions
readline
repl
stream
stream-browserify
string_decoder
string_decoder
sys
util
timers
timers-browserify
timers/promises
isomorphic-timers-promises
tls
tty
tty-browserify
tty
url
node-url
Contains additional exports from newer Node versions (URL
and URLSearchParams
are not polyfilled)
util
util
zlib
browserify-zlib
_stream_duplex
readable-stream
_stream_passthrough
readable-stream
_stream_readable
readable-stream
_stream_transform
readable-stream
_stream_writable
readable-stream
packages
Returns: object
Exports absolute paths to each module directory (where package.json
is
located), keyed by module names. Modules without browser replacements return
module with default export null
.
Some modules have mocks in the mock directory. These are replacements with minimal functionality.
Mocking fs
fs
package doesn’t return anything since there are many different ways you can
implement file system functionality in browser.
Examples of implementations:
Node support
Minimum supported version should be Node 10.
If you’re using ESM in Node < 12.20, note that subpath patterns are not supported so mocks can’t be handled. In that case, it’s recommended to use CommonJS implementation.
Browser support
Minimum supported version should be Internet Explorer 11, but most modules support even Internet Explorer 9.
Types
You can use default @types/node
types.
License
MIT © Ivan Nikolić
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK