dongyuwei / CommonJS.erl

A CommonJS Module Packager in Erlang
Other
3 stars 0 forks source link
commonjs module package

CommonJS.erl

A CommonJS Packager in Erlang.

Project Goal: speed, speed, and speed!

  1. Bundle Common JS modules in parallel using Erlang processes. It is expected to work like browserify.
  2. Watch and incrementally rebuild Common JS modules concurrently using Erlang processes. It is expected to work like watchify.
  3. It's expected to be a tiny and simple CommonJS Packager. I do't plan to implement all the features like browserify.

Status

  1. The core features of Common Js packager/loader was done(It can bundle the test/commonjs/entry.js now).
  2. Watch and rebuild feature was done, Design Ref:
    1. If the changed js's dependencies also changed, process the js and it's dependent modules.
    2. If the dependencies of the changed js are not changed, only update the changed js itself.

The project structure was generated by rebar3 new lib commonjs

Build

$ rebar3 compile

API

  1. commonjs:bundle_single_js(Js_entry_file, Output_file)
  2. commonjs:bundle_js_in_dir(Input_dir, Output_dir, Watch_mode)

Run eunit test:

rebar3 eunit