-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathbundle-pack-bower.js
34 lines (26 loc) · 916 Bytes
/
bundle-pack-bower.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
/*jshint asi: true */
process.env.BROWSERIFYSHIM_DIAGNOSTICS=1;
var browserify = require('browserify')
, test = require('tap').test
, path = require('path')
, vm = require('vm')
function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err.message); return t.end(); }
var ctx = { window: {}, console: console };
ctx.self = ctx.window;
var require_ = vm.runInNewContext(src, ctx);
var main = require_(require.resolve(relPath));
t.deepEqual(
main
, { root: '$.position', fn: '$.fn.position', ui: '$.ui.position' }
, 'shims it correctly including requiring its dependends'
);
t.end()
});
}
test('\nbundling pack that has shimmed bower component dependency'
, bundleNcheck.bind(null, './bower'))