npm install
./node_modules/.bin/traceur --out out.js test.js
node main.js
Created
October 30, 2014 16:31
-
-
Save OliverJAsh/7dcc37216ea43ecd6f73 to your computer and use it in GitHub Desktop.
Traceur error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = require('traceur').require('./test.js'); | |
console.log(1, test); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.register("test", [], function() { | |
"use strict"; | |
var $__0 = this; | |
var __moduleName = "test"; | |
var foo = (function() { | |
$__0; | |
}); | |
module.exports = {foo: 'bar'}; | |
return {}; | |
}); | |
System.get("test" + ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "traceur-error", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"traceur": "0.0.72" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = () => { | |
this; | |
}; | |
module.exports = { foo: 'bar' }; |
To correctly emulate the traceur.require you need to compile with commonjs:
./node_modules/.bin/traceur --modules=commonjs --out out.js test.js
The resulting commonjs module fails because this
is used in module scope. That causes our code to add the extra outer function wrapper. Once we make such use of this
illegal in module scope, this bug will also be fixed. See #1478
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be: