external.js 521 B

1234567891011121314151617181920
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('external', function (t) {
  5. t.plan(2);
  6. var b = browserify(__dirname + '/external/main.js');
  7. b.external('freelist');
  8. b.bundle(function (err, src) {
  9. if (err) return t.fail(err);
  10. vm.runInNewContext(
  11. 'function require (x) {'
  12. + 'if (x==="freelist") return function (n) { return n + 1000 }'
  13. + '}'
  14. + src,
  15. { t: t }
  16. );
  17. });
  18. });