Skip to content

holepunchto/bare-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bare-node

Compatibility modules for Bare that try to behave like their Node.js counterparts. Not meant to cover 100% of all APIs but the 95% that everyone uses.

Usage

To use any of the supported Node.js builtins, such as fs, in a Bare application run the following:

npm i bare-fs fs@npm:bare-node-fs

This will add something like the following to your package.json:

{
  "dependencies": {
    "bare-fs": "^2.1.5",
    "fs": "npm:bare-node-fs"
  }
}

The only thing the wrapper does is module.exports = require('bare-fs') and at version *, meaning the version you specify is the one that wins. Using the wrapper saves you space as it means npm will only include bare-fs once even if multiple modules depend on it.

Import maps

When writing a module that uses a Node.js builtin, such as fs, you can also choose to specify directly in that module what builtin should map to instead of relying on the compatibility layer. You would do that using an import map by adding the following to your package.json:

{
  "imports": {
    "fs": {
      "bare": "bare-fs",
      "default": "fs"
    },
    "fs/*": {
      "bare": "bare-fs/*",
      "default": "fs/*"
    }
  },
  "dependencies": {
    "bare-fs": "^2.1.5"
  }
}

This way your module is in full control of exactly which version of the builtin it wants to bind to in Bare. If you can, this is the best option as it provides the best of all worlds; Node.js compatible, but full control of your dependencies.

Say goodbye to broken apps and modules due to Node.js core changes.

Modules

Node.js Bare Wrapper Status
assert bare-assert npm:bare-node-assert
async_hooks bare-async-hooks npm:bare-node-async-hooks
buffer bare-buffer npm:bare-node-buffer
child_process bare-subprocess npm:bare-node-child-process
cluster None npm:bare-node-cluster
console bare-console npm:bare-node-console
constants None npm:bare-node-constants ⛔️ Obsolete
crypto bare-crypto npm:bare-node-crypto
dgram bare-dgram npm:bare-node-dgram
diagnostics_channel bare-diagnostics-channel npm:bare-node-diagnostics-channel
dns bare-dns npm:bare-node-dns
domain None npm:bare-node-domain ⚠️ Deprecated
events bare-events npm:bare-node-events
fs bare-fs npm:bare-node-fs
http bare-http1 npm:bare-node-http
http2 None npm:bare-node-http2
https bare-https npm:bare-node-https
inspector bare-inspector npm:bare-node-inspector
module bare-module npm:bare-node-module
net bare-net npm:bare-node-net
os bare-os npm:bare-node-os
path bare-path npm:bare-node-path
perf_hooks bare-performance npm:bare-node-perf-hooks
process bare-process npm:bare-node-process
punycode bare-punycode npm:bare-node-punycode ⚠️ Deprecated
querystring bare-querystring npm:bare-node-querystring
readline bare-readline npm:bare-node-readline
repl bare-repl npm:bare-node-repl
sea None npm:bare-node-sea
sqlite None npm:bare-node-sqlite
stream bare-stream npm:bare-node-stream
string_decoder bare-string-decoder npm:bare-node-string-decoder
sys None npm:bare-node-sys ⛔️ Obsolete
test None npm:bare-node-test
timers bare-timers npm:bare-node-timers
tls bare-tls npm:bare-node-tls
trace_events None npm:bare-node-trace-events ⛔️ Obsolete
tty bare-tty npm:bare-node-tty
url bare-url npm:bare-node-url
util bare-utils npm:bare-node-util
v8 bare-v8 npm:bare-node-v8
vm bare-vm npm:bare-node-vm
wasi None npm:bare-node-wasi
worker_threads bare-worker npm:bare-node-worker-threads
zlib bare-zlib npm:bare-node-zlib

License

Apache-2.0

About

Compatibility modules for Node.js builtins in Bare

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •