Closed jaydson closed 9 years ago
I found the issue.
It seems like the config property 6to5
in build.js
is being ignored.
I changed the gulpfile
to this:
.pipe(plugins['6to5'], { experimental: true })
instead of this:
.pipe(plugins['6to5'], build.config['6to5'])
and it works.
Probably the blacklisted generators
never were blacklisted until now.
Probably the blacklisted generators never were blacklisted until now.
Weird. I'm pretty sure co-prompt was throwing errors when we transpiled generators.
It looks like the async functions transform converts them to generators, so the async functions transform doesn't work/is ignored when we blacklist generators. I believe this makes sense, anyway, @sebmck can you confirm?
@jaydson change the build.js
to remove generators from the blacklist and enable the experimental option:
'6to5': { experimental: true },
Does this work?
If that's the issue, then we can replace co-prompt with Inquirer (#68) then remove generators from the blacklist and use async functions. :smile:
Async functions and generators are transformed in the same transformer (it's delegated to regenerator). It's confusing I know but since 3.0.0 is going to include a regenerator fork it'll allow it to be split up into multiple transformers.
@sebmck oh nice! Thanks for the clarification. :smile:
@UltCombo both '6to5': { experimental: true }
and '6to5': { blacklist: ['generators'], experimental: true }
works in the same way.
@jaydson I believe blacklist: ['generators']
disables the async transform as @sebmck explained.
Doesn't '6to5': { experimental: true }
work? It fails to transpile async functions or throws some specific error?
Oh, now i got it.
'6to5': { experimental: true }
works (transpile async functions).
We can remove generators from the blacklist :)
Oh nice. :)
Btw, the whole idea behind the build.js
file is to have project-specific settings outside of the gulpfile, so that whenever we update the gulpfile we can seamlessly copy it to the slush-es6 repository forth and back. This way we can pull updates from slush-es6 by simply copying the files over.
Of course, in the future Harmonic may need a more complex gulpfile than slush-es6's, but for the time being this workflow has been working nicely. :smiley:
@jaydson also, please test harmonic init
before committing the changes.
IIRC, co-prompt was throwing an error when we passed a transpiled generator to it.
As we've discussed earlier, we can't transpile generators with regenerator as co
and co-*
libs are not transpiled (they work with native generators only). So I guess we have to drop the co
dependency(ies) before un-blacklisting generators.
There's probably regenerator'ed versions of co
out there, but if we're using it only for the CLI input we can easily replace it with Inquirer and drop co
. What do you think?
I think we can replace co
and focus on async/await
.
Weird thing is i've tested harmonic init
and it worked well. I'm probably missing something.
@jaydson perhaps it was an issue with one of our dependencies that got fixed. Never mind it if it is working as expected for you. :D
focus on
async/await
:+1:
We're already using async functions
yay!
https://github.com/JSRocksHQ/harmonic/commit/c4bb69d0495f6b9d795b1e39075b7f919559fa6b
I'm trying to use async/await(es7) (experimental feature in 6to5) but i'm not sure gulp-6to5 is working. I've changed
build.js
file:My sample code:
And i get the following error:
events.js:85 throw er; // Unhandled 'error' event ^ /home/jaydson/Workspace/harmonic/dist/bin/parser.js:19 async function test() { ^^^^^^^^ SyntaxError: Unexpected token function
The async function is not being transpiled.
Any thoughts @UltCombo ?