entry_expose.js 526 B

123456789101112131415161718
  1. var test = require('tap').test;
  2. var browserify = require('../');
  3. var vm = require('vm');
  4. test('entry expose', function (t) {
  5. t.plan(3)
  6. var b = browserify();
  7. b.add(__dirname + '/entry_expose/main.js');
  8. b.require(__dirname + '/entry_expose/main.js', { expose: 'x' });
  9. b.bundle(function (err, src) {
  10. t.ifError(err);
  11. var c = { console: { log: log } };
  12. function log (msg) { t.equal(msg, 'wow') }
  13. vm.runInNewContext(src, c);
  14. t.equal(c.require('x'), 555);
  15. })
  16. });