external_shim.js 802 B

123456789101112131415161718192021222324252627
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('requiring a shimmed module name from an external bundle', function (t) {
  5. t.plan(1);
  6. var b1 = browserify();
  7. var b2 = browserify();
  8. b1.require(__dirname + '/external_shim/bundle1.js', { expose: 'bundle1' });
  9. b2.external(b1);
  10. b2.require(__dirname + '/external_shim/bundle2.js', { expose: 'bundle2' });
  11. b1.bundle(function (err, src1) {
  12. b2.bundle(function (err, src2) {
  13. var c = {
  14. console: console,
  15. setTimeout: setTimeout,
  16. clearTimeout: clearTimeout
  17. };
  18. vm.runInNewContext(src1 + src2, c);
  19. t.ok(c.require('bundle1').shim === c.require('bundle2').shim);
  20. });
  21. });
  22. });