coffee-script icon indicating copy to clipboard operation
coffee-script copied to clipboard

ReferenceError: iced is not defined

Open jots opened this issue 12 years ago • 9 comments

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?

jots avatar Nov 13 '13 18:11 jots

Likely you are doing something incorrectly. Can you paste the relevant code into a gist?

maxtaco avatar Nov 13 '13 18:11 maxtaco

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

jots avatar Nov 13 '13 19:11 jots

I made some comments on the gist

maxtaco avatar Nov 13 '13 19:11 maxtaco

removing .js didn't do it for me. I commented back but I don't know if you get notified of that,

jots avatar Nov 13 '13 19:11 jots

any solution to the problem? I am using mimosa-iced-coffee to compile my iced coffeescript and get the same error.

rajgaire avatar Feb 17 '15 06:02 rajgaire

try adding this as the first line in your source file as a workaround...

() -> await defer() 

m1sta avatar Feb 17 '15 19:02 m1sta

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.

rajgaire avatar Feb 17 '15 23:02 rajgaire

turned out that the solution was rather simple. I needed to define

runtime: "window"

in mimosa config. window.iced was created after that!

rajgaire avatar Feb 18 '15 00:02 rajgaire

@jots your code might have an 'await' without any 'defer' following it.

osyed avatar May 18 '15 19:05 osyed