maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
727 stars 58 forks source link

ReferenceError: iced is not defined #94

Open jots opened 10 years ago

jots commented 10 years ago

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?

maxtaco commented 10 years ago

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

jots commented 10 years ago

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

maxtaco commented 10 years ago

I made some comments on the gist

jots commented 10 years ago

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

rajgaire commented 9 years ago

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

m1sta commented 9 years ago

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

() -> await defer() 
rajgaire commented 9 years ago

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 commented 9 years ago

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

runtime: "window"

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

osyed commented 9 years ago

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