-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
6to5ify #1
Comments
Hi @konsumer! Probably you have to enable generators in app.use(browserify({
root: staticPublic,
debug: process.env.NODE_ENV !== 'production',
production: process.env.NODE_ENV === 'production',
transform: to5ify.configure({
blacklist: ["generators"]
}))
})); |
Thanks! It works in Chrome 39.0.2171.99 (64-bit), but then so does this: app.use(browserify({
root: staticPublic,
debug: process.env.NODE_ENV !== 'production',
production: process.env.NODE_ENV === 'production',
})); (no 6to5ify.) Is this just ignoring transpiling generators? Isn't that what 6to5 is for? Here is my test case: function *foo() {
var i = 0;
while(i+=1) yield i;
}
var it = foo();
console.log( it.next().value );
console.log( it.next().value );
console.log( it.next().value );
console.log( it.next().value ); |
@konsumer However, new browsers did support part of Does you code works in chrome? |
Right, that is my question. I am using 6to5 because I want to use ES6 features like generators and support older browsers. Your suggestion was to put generators in the blacklist which would effectively make it useless for me, right? My point is that it doesn't solve my issue, it just skips transforming the code that caused it to have an issue, but in that case it obviously doesn't do what it was intended for, and I might as well leave out 6to5, all the way. Maybe this is more of a question for the 6to5ify folks. I figured that it might have something to do with the funny way koa-browserify handles transforms. |
Ah! I got the point. According to babel/babelify#28, you have to add I've updated var browserify = require('koa-browserify'),
6to5ify = require('6to5ify');
app.use(browserify({
root: './public',
transform: 6to5ify,
runtime: require.resolve('regenerator/runtime')
})); (also you should have |
I get the same error with this: var koa = require('koa'),
app = koa(),
serve = require('koa-static'),
browserify = require('koa-browserify'),
to5ify = require('6to5ify'),
path = require('path'),
port = process.env.PORT || 3000,
staticPublic = path.join(__dirname, 'public');
app.use(browserify({
root: staticPublic,
debug: process.env.NODE_ENV !== 'production',
production: process.env.NODE_ENV === 'production',
transform: to5ify,
runtime: require.resolve('regenerator/runtime')
}));
app.use(serve(staticPublic));
console.log('http://0.0.0.0:' + port)
app.listen(port); I saw suggested here that I should My package.json looks like this, right now: {
"scripts": {
"start": "node index.js"
},
"dependencies": {
"6to5": "^2.13.5",
"6to5ify": "^3.1.2",
"koa": "^0.15.0",
"koa-browserify": "^0.1.0",
"koa-static": "^1.4.8",
"regenerator": "^0.8.9"
}
} |
Here is a complete example. |
I am probably missing something, but I can't seem to use 6to5ify.
In my browser, I get this error:
when I try to use a generator.
The text was updated successfully, but these errors were encountered: