1 | var browserify = require('../');
|
2 | var vm = require('vm');
|
3 | var test = require('tap').test;
|
4 |
|
5 | test('multi bundle', function (t) {
|
6 | t.plan(5);
|
7 |
|
8 | var core = browserify();
|
9 | core.require(__dirname + '/multi_bundle/b.js', { expose: true });
|
10 |
|
11 | var app = browserify([__dirname + '/multi_bundle/a.js']);
|
12 |
|
13 | app.external(__dirname + '/multi_bundle/b.js');
|
14 |
|
15 | core.bundle(function (err, src) {
|
16 | var c = {
|
17 | console: console,
|
18 | t : t,
|
19 | baton: {
|
20 | times: 0
|
21 | }
|
22 | };
|
23 |
|
24 |
|
25 | vm.runInNewContext(src, c);
|
26 | t.equal(c.baton.times, 0);
|
27 |
|
28 |
|
29 | app.bundle(function (err, src) {
|
30 | vm.runInNewContext(src, c);
|
31 |
|
32 |
|
33 | t.equal(c.baton.times, 1);
|
34 |
|
35 |
|
36 |
|
37 | vm.runInNewContext(src, c);
|
38 |
|
39 |
|
40 |
|
41 | t.equal(c.baton.times, 1);
|
42 | });
|
43 | });
|
44 | });
|
45 |
|
46 |
|
47 | test('multi bundle', function (t) {
|
48 | t.plan(8);
|
49 |
|
50 | var core = browserify({ exposeAll: true });
|
51 | core.require(__dirname + '/multi_bundle/a.js', { expose: true });
|
52 |
|
53 | var app = browserify([__dirname + '/multi_bundle/c.js']);
|
54 |
|
55 | app.external(core);
|
56 |
|
57 | core.bundle(function (err, src) {
|
58 | var c = {
|
59 | console: console,
|
60 | t : t,
|
61 | baton: {
|
62 | times: 0
|
63 | }
|
64 | };
|
65 |
|
66 |
|
67 | vm.runInNewContext(src, c);
|
68 | t.equal(c.baton.times, 0);
|
69 |
|
70 |
|
71 | app.bundle(function (err, src) {
|
72 | vm.runInNewContext(src, c);
|
73 |
|
74 |
|
75 | t.equal(c.baton.times, 1);
|
76 |
|
77 |
|
78 |
|
79 | vm.runInNewContext(src, c);
|
80 |
|
81 |
|
82 |
|
83 | t.equal(c.baton.times, 1);
|
84 | });
|
85 | });
|
86 | });
|