distify
AST-aware module packager
Last updated 4 years ago by zertosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install distify 
SYNC missed versions from official npm registry.

distify

Experimental browserify-based (mostly backwards-compatible) AST-aware module packager.

Idea

Architecture

Browserify transforms exist in two categories:

  1. nonjs-to-js transforms (henceforth "converters").
* The source cannot be expressed in terms of an esprima-compatible AST because they're not js.
* e.g.: handlebars/underscore templates compilers, coffeeify, jadeify, etc.
  1. js-to-js transforms (not converters, henceforth "legacy transforms").
* The source can be expressed in terms of an esprima AST because they're js.
* These most often do use an AST as intermediate step, but it's not shared.
* [babelify](https://github.com/babel/babelify), [brfs](https://github.com/substack/brfs) (inlines `fs.readFileSync()` calls), [aliasify](https://github.com/benbria/aliasify) (remaps `require` calls), [envify](https://github.com/hughsk/envify) (inlines `process.env` values), [deAMDify](https://github.com/jaredhanson/deamdify), etc.

Internally, browserify has three legacy transforms:

  1. detective. Collects require calls.
  2. insert-module-globals. Wraps modules in an IIFE with references to __filename, __dirname, process and Buffer - if needed.
  3. syntax-error. Syntax checks files – uses acorn's own errors to present helpful messages with line numbers.

Converters are exogenous inputs into the build pipeline. However, Legacy transforms are AST transformations that can benefit from skipping the AST-building step.

  + nonjs-to-js: If Acorn can't read it, these turn it
  | into something that it can. Includes the above mentioned, plus:
  |   * Turning `.json` files into `module.exports=JSON_CONTENT`.
  |   * BOM and shebang stripping.
  |
  |                 : 1. acorn
  |                 : 2. babel transforms
  |                 : 3. babel code gen
  |                 :
  v                 !~~~~~~~~~~~~~~~~!
converters -> JS -> !  AST  ->  JS+  ! -> legacy transforms -> packaging
                    !________________!                            ^
                    ^                                             |
                    |                                   * bundle splitting,
                    |                                   * source maps, etc.
                    |
                    |
                    * babel & it's ES6/7 transforms
                    * user defined transforms
                    * internal transforms rewritten as babel plugins
                    * other transforms like: bundle-collapser, aliasify

Current Tags

  • 0.0.1                                ...           latest (4 years ago)

2 Versions

  • 0.0.1                                ...           4 years ago
  • 0.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (52)
Dev Dependencies (13)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |