2016-11-21 4 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으로 확장하면 더 큰 트리를위한 많은 메모리를 먹을 수 있습니다.