this.js 539 B

123456789101112131415161718192021222324
  1. /**
  2. * In node.js `this` on the module root is the same as `exports`. Browser-pack
  3. * should act like it too.
  4. **/
  5. var test = require('tap').test;
  6. var pack = require('../');
  7. test('this', function (t) {
  8. t.plan(1);
  9. var p = pack();
  10. var src = '';
  11. p.on('data', function (buf) { src += buf; });
  12. p.on('end', function () {
  13. var r = Function([], 'return ' + src)();
  14. t.deepEqual(r("abc"), { foo: "bar" });
  15. });
  16. p.end(JSON.stringify([{
  17. id: 'abc',
  18. source: 'this.foo = "bar"'
  19. }]));
  20. });