exoform
Transform CommonJS to asynchronous content-addressed modules.
Last updated 5 years ago by krlkrl .
MIT · Original npm · Tarball · package.json
$ cnpm install exoform 
SYNC missed versions from official npm registry.

Exoform

Exoform takes a module defined in CommonJS style, and recursively transforms it, and its dependencies into asynchronous content-addressed require calls.

This gives you the whole program, and its dependencies, in a content-addressable manner, that you could later require from other programs.

Exoform uses cdump, for now, to store its blobs

Example

Input: test/req/one.js

var a = require('./two.js')
var b = require('./two.js').blorp
var c = require('./two.js').blorp()

var x = { y: { z: {} } }
x.y.z.two = require('./two.js')

console.log(x.y.z.two.blorp())
console.log(a.blorp())
console.log(b())
console.log(c)
exoform test/req/one.js | xargs cdump get

Output:

var __meta
if (typeof arguments !== 'undefined') {
  __meta = arguments[0]
} else {
  __meta = {
    exoform: require('exoform'),
    define: function () {},
    refs: [] } }
var exoform = __meta.exoform
var exports = __meta.mod
var module = { exports: exports }
;
__meta.exoform.require(__meta.refs, '6aa7e2e45e38d55c765ac44dbd98f5ce09f27c60696b823e70cf547816c38d31', function (a) {
__meta.exoform.require(__meta.refs, '6aa7e2e45e38d55c765ac44dbd98f5ce09f27c60696b823e70cf547816c38d31', function (b) {
b = b.blorp
__meta.exoform.require(__meta.refs, '6aa7e2e45e38d55c765ac44dbd98f5ce09f27c60696b823e70cf547816c38d31', function (c) {
c = c.blorp()

var x = { y: { z: {} } }
__meta.exoform.require(__meta.refs, '6aa7e2e45e38d55c765ac44dbd98f5ce09f27c60696b823e70cf547816c38d31', function (two) {
x.y.z.two = two

console.log(x.y.z.two.blorp())
console.log(a.blorp())
console.log(b())
console.log(c)
;
__meta.define(module.exports)
})})})})

The dependency loaded (test/req/two.js):

cdump get 6aa7e2e45e38d55c765ac44dbd98f5ce09f27c60696b823e70cf547816c38d31

outputs:

var __meta
if (typeof arguments !== 'undefined') {
  __meta = arguments[0]
} else {
  __meta = {
    exoform: require('exoform'),
    define: function () {},
    refs: [] } }
var exoform = __meta.exoform
var exports = __meta.mod
var module = { exports: exports }
;__meta.exoform.require(__meta.refs, '47171d069057c67c3f6e8cd2b409e3ea38920881f58407ed1b1ac00b27d8f8ab', function (three) {

module.exports = { blorp: function () { return 'testblorp ' + three('extra')} }
;
__meta.define(module.exports)
})

Todo

Extended support for the browserify ecosystem and browser ports of node modules

Current Tags

  • 2.1.0                                ...           latest (5 years ago)

7 Versions

  • 2.1.0                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |