new-core

0.0.0 • Public • Published

new-core

give node a new core.

This module makes it easy to create an alternative distribution of node with different core modules. Via a few carefully placed hacks in node's module system, you can now make a node executable which now comes shipped with extra modules which are always available, as fs or net or http currently are.

Let be clear, I wish I didn't need to do this, but npm is just not reliable or secure enough (especially for binary addons) to distribute the kind of software I am making (cryptographically-secure decentralized databases) but this approach allows me to create a stable core that includes the C-touching bits (and it rarely changes, that is the point of core) and then have a rapidly changing javascript layer.

example

#! /usr/bin/env node

//shim some binary modules, which are useful for p2p
require('new-core')({
  level: require('level'),
  chloride: require('chloride'),
  utp: require('utp-native'),
  webrtc: require('webrtc'),
})

//and use the following boiler-plate to run a file

//mutate the argv, so that it looks like the current script is a real executable.
process.argv.splice(0, 3, 'new_core', require('path').resolve(process.argv[2]))

//and execPath...
process.execPath = __filename

//then call run main, to execute the file
require('module').runMain()

now you can publish that on npm (useful for dev) to make a bundle that is an executable, my plan is to use electron, since there are already tools to bundle that, and we are using electron for the UI anyway.

other ideas

you could also use this to turn off node core, and make a coreless node from node. see also nucelus and nojs

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i new-core

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • nopersonsmodules