1 | 'use strict';
|
2 |
|
3 | var bpack = require('browser-pack');
|
4 | var fs = require('fs');
|
5 | var path = require('path');
|
6 | var xtend = require('xtend');
|
7 |
|
8 | var preludePath = path.join(__dirname, 'prelude.js');
|
9 | var prelude = fs.readFileSync(preludePath, 'utf8');
|
10 |
|
11 |
|
12 | var plugin = exports.plugin = function (bfy, opts) {
|
13 | function replacePrelude() {
|
14 | var packOpts = {
|
15 | raw : true,
|
16 | preludePath : preludePath,
|
17 | prelude : prelude
|
18 | };
|
19 |
|
20 |
|
21 | bfy._bpack = bpack(xtend(bfy._options, packOpts));;
|
22 |
|
23 | bfy.pipeline.splice('pack', 1, bfy._bpack);
|
24 | }
|
25 |
|
26 | bfy.transform(require('./transform'));
|
27 | bfy.on('reset', replacePrelude);
|
28 |
|
29 | replacePrelude();
|
30 | };
|
31 |
|
32 |
|
33 | exports.browserify = function (files) {
|
34 | console.error('You are setting up proxyquireify via the old API which will be deprecated in future versions.');
|
35 | console.error('It is recommended to use it as a browserify-plugin instead - see the example in the README.');
|
36 | return require('browserify')(files).plugin(plugin);
|
37 | };
|