Skip to content

Instantly share code, notes, and snippets.

@Globegitter
Forked from eventualbuddha/index.js
Last active August 29, 2015 14:18
Show Gist options
  • Save Globegitter/ee46154b9a1b7506af19 to your computer and use it in GitHub Desktop.
Save Globegitter/ee46154b9a1b7506af19 to your computer and use it in GitHub Desktop.
// index.js
require('babel/register')({ only: /tests/ });
require('./tests');
// lib/index.js
console.log('' + this);
var promise = new Promise(function (resolve, reject) {
resolve(0);
});
// tests/index.js
require('../lib');
class Foo {
}
@Globegitter
Copy link
Author

If I have code above (with npm i babel of course) and it via node index.js on v0.10.36 it all works fine even though it does not support Promise.

If I now comment out // require('babel/register')({ only: /tests/ }); as well as the //class Foo { } and run node index.js again it throws an error as it should:

ReferenceError: Promise is not defined
    at Object.<anonymous> (test-project/lib/index.js:4:19)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (test-project/tests/index.js:2:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

So there does seem to be something up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment