Closed nicolashery closed 10 years ago
Hum, wrapping it in an IEF seems to do the trick for the browser:
// src/index.js
(function() {
var addOne = v => v + 1;
var evens = [2, 4, 6];
var odds = evens.map(addOne);
console.log(odds);
}());
Maybe that's just it? I guess since I'm using webpack
or browserify
usually, they do it for me so that's fine?
You found a bug! Sorry, I added that recently without thinking it through. Will fix right now and publish a new version.
Yeah, it binds arguments
from the outer scope (ES6 semantics), but I forgot to check if arguments
even exists. This is still early!
Glad I could help! Learned a thing about ES6 along the way too :)
Fixed and published in npm, so just do npm install es6-macros
again.
Wonderful! Installed 0.0.6
and ran my example again, works great!
Thanks for quickly fixing this!
It's still appear in my chrome browser . Why ?
I'm new to ES6 and Sweet.js, so apologies if I'm missing something obvious :)
Given this source:
Running
sjs src/index.js -m es6-macros -o bundle.js -c
produces:And I get
Uncaught ReferenceError: arguments is not defined
when runningbundle.js
in the browser. However, it seems to work fine usingnode bundle.js
.What am I missing? Thanks!