2016-11-21 6 views
0

私はブラウザ対応のMakefileを作成しようとしています。バンドルされたビルドターゲットの依存関係を調べるために、browserifyにリストするようにお願いします。browserify APIから依存関係のリストを取得

私はすでに達成:

browserify index.js --deps 

すると、リストを抽出するために、私が解析できる、JSONとしてそれらを一覧表示されます。しかし、私がbrowserifyのAPIを通してこれをやろうとすると、より効率的かどうか疑問に思う。

browserify(path.resolve('index.js')) 
    .pipeline.get('deps').on('dep', (dep) => console.log('dep')) 

これは動作しません:(私は最終的にbrowserify APIからの依存関係を取得する方法を発見した

答えて

0

const through = require('through2') 

const bundler = browserify('index.js') 

bundler.pipeline.get('deps').push(through.obj((row, enc, next) => { 
    // simply write the filename to the console 
    console.log(row.id) 
    next() 
})) 

bundler.bundle() 

利点は、私がバッファリングする必要がないということです全体のjsonをstdoutにして、idだけを解析したい場合は、大きな木のために多くのメモリを使用します。

関連する問題