Open jots opened 10 years ago
Likely you are doing something incorrectly. Can you paste the relevant code into a gist?
https://gist.github.com/jots/7454559 I run as iced ta.coffee if i uncomment iced = require('iced-coffee-script').iced it works. otherwise: ReferenceError: iced is not defined
I made some comments on the gist
removing .js didn't do it for me. I commented back but I don't know if you get notified of that,
any solution to the problem? I am using mimosa-iced-coffee to compile my iced coffeescript and get the same error.
try adding this as the first line in your source file as a workaround...
() -> await defer()
sorry m1sta, the workaround did not work either. I am using mimosa-iced-coffeescript to compile my script and serve it as a javascript. When checked the compiled javascript, there are a lot of references to variable iced. For example:
___iced_passed_deferral = iced.findDeferral(arguments);
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral
});
..
return iced.trampoline(function() {
++i;
return _while(__iced_k);
});
Certainly iced is not defined, and so the browser is complaining.
turned out that the solution was rather simple. I needed to define
runtime: "window"
in mimosa config. window.iced was created after that!
@jots your code might have an 'await' without any 'defer' following it.
if I require an iced file that uses await, I get this error: ReferenceError: iced is not defined
I fix it by adding to the top of the required file; iced = require('iced-coffee-script').iced
Is this intended behavior or am I doing something weird?