double_bundle_parallel_cache.js 842 B

1234567891011121314151617181920212223242526272829303132333435
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('double bundle parallel cached', function (t) {
  5. t.plan(7);
  6. var sources = [];
  7. var b = browserify(__dirname + '/entry/main.js', {
  8. cache: {}
  9. });
  10. var pending = 2;
  11. b.bundle(check(0));
  12. b.bundle(check(1));
  13. function check (index) {
  14. return function (err, src) {
  15. t.ifError(err);
  16. var c = {
  17. done : function (one, two) {
  18. t.equal(one, 1);
  19. t.equal(two, 2);
  20. }
  21. };
  22. vm.runInNewContext(src, c);
  23. sources[index] = src.toString('utf8');
  24. if (--pending === 0) done();
  25. };
  26. }
  27. function done () {
  28. t.equal(sources[0], sources[1]);
  29. }
  30. });