Open laurentpayot opened 7 years ago
I've just noticed https://github.com/maxtaco/coffee-script/pull/194 but it doesn't seem to work…
I'll try to cut a release today. We just haven't released in a bit. Thanks!
Ah yes it has not been released yet and I have issues building it (Error: Cannot find module 'iced-runtime-3'
). Thanks @maxtaco!
Ok, should be live in v111.1.1
That's a lot of 1s!
Big thanks to @zapu who did all of the work.
ES2015 imports are now working when using promises.
In order to use use async/defer, I have to install the iced-runtime-3
module. But once this module installed ES2015 imports are not working anymore.
@maxtaco Is a new release also needed for iced-runtime-3?
I didn't think so. I wonder what is up.
On Tuesday, November 15, 2016, Laurent Payot notifications@github.com wrote:
ES2015 imports are now working when using promises. In order to use use async/defer, I have to install the iced-runtime-3 module. But once this module installed ES2015 imports are not working anymore.
@maxtaco https://github.com/maxtaco Is a new release also needed for iced-runtime-3?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/maxtaco/coffee-script/issues/198#issuecomment-260690849, or mute the thread https://github.com/notifications/unsubscribe-auth/AA05__2SAvupqM8_Tgft5-WMOSghQ5NVks5q-d3TgaJpZM4Kyo5f .
Weird, maybe installing iced-runtime-3 overwrites iced-coffee-script with a different version?
It really shouldn't. I am st a conference today so might not get a chance to look right away.
On Tuesday, November 15, 2016, Michał Zochniak notifications@github.com wrote:
Weird, maybe installing iced-runtime-3 overwrites iced-coffee-script with a different version?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/maxtaco/coffee-script/issues/198#issuecomment-260691497, or mute the thread https://github.com/notifications/unsubscribe-auth/AA05_8vsoasmmwiYbKOcVtBG_5-OA_Vfks5q-d5TgaJpZM4Kyo5f .
By the way I'm using iced3 -c script.coffee && babel-node script.js
for my tests...
Hm, but won't iced3 -c
compile just the script.coffee
, so anything that script.js tries to import might not be compiled?
I'm importing "standard" js (Firebase modules). And I'm also struggling to get any result from Firebase createUser()
(that returns a promise) with the await/defer syntax. Not to mention catching errors…
async/defer is "just" a syntactic sugar for callback based asynchronous functions. So in theory you could try to do something like await promise_obj.then defer result
but I'm not sure how this would turn out in your code. It might make more sense to just use the promise normally and pass anonymous functions as arguments to then
.
I will try to experiment with iced3 -c
and babel-node
once I get off work, in few hours.
Thank you so much @zapu, it really helped!
Now I'm using something like
await promise_obj.then(defer result).catch((error) -> console.log(error.message))
in a synchronous-like way of coding. Amazing 😃
I still have the ES2015 import issue with await/defer, I get error: import statements must be at top-level scope
, if it helps you…
Thanks again for your time!
If you have top-level await/defer, it has to wrap your entire file in a function, which probably causes this error. Iced should probably handle this better, I overlooked the fact that this may be an issue. Is this the case here?
Spot on. Yes after wrapping my await/defer in a function the imports issues are gone.
But now if using ES2015 imports when I call my function I get:
__iced_passed_deferral = iced.findDeferral(arguments);
^
ReferenceError: iced is not defined
What are your compile flags right now?
Can you try something like iced3 -b -c -I node script.coffee
?
I tried and it worked! The -I node
option was missing. That's strange because the node mode is supposed to be the default, isn't it?
Yes, but I just remembered that ES6 modules in CoffeeScript forces the bare option, because otherwise the whole code is wrapped in a top-level function anyways. So by doing ES6 import/export, it has to "undo" that behavior. I think there was even a discussion about this in CoffeeScript repo on GitHub. In our case, forcing bare also makes it not include the require('iced-runtime')
in the code.
Thank you for going through all of this, I think there are few places that we can make improvements in Iced.
Hello there, a little question.
Since version 1.11 CoffeeScript supports ES2015 import and export syntax by producing an import or export statement in the resulting output. We have to add a layer of transpiler like babel or target ES6 to make it work, just like Iced3. But in Iced3, with babel, when I use the import syntax I get
error: reserved word 'import'
.Is the IcedCoffeeScript codebase moving away from CoffeeScript on this point ?