-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathbundle-deps.js
29 lines (22 loc) · 918 Bytes
/
bundle-deps.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
'use strict';
/*jshint asi: true */
var browserify = require('browserify')
, test = require('tap').test
, 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(), { noncjs: { name: 'non-cjs', version: 1.1 } }, 'shims non-cjs, requireing non-cjs-dep ');
t.end()
});
}
test('\nshimming deps with external shim, with depends all exposed'
, bundleNcheck.bind(null, './deps/extshim/main'))
test('\nshimming nodeps with inlined shim, with depends all exposed'
, bundleNcheck.bind(null, './deps/inlineshim/main'))