contracts.coffee icon indicating copy to clipboard operation
contracts.coffee copied to clipboard

Require.js support broken

Open mlippens opened this issue 12 years ago • 2 comments

I know that the feature was marked as experimental but anyways. I tried the example supplied, which didn't seem to be working, so I ended up digging in to see what's going on. I tore apart the code that is wrapped around each file that is compiled with the contracts flag. I set up a similar small example to test.

  • An uncaught error happens! fyi: I checked by compiling without contracts that the error is not my module definition.
Uncaught TypeError: undefined is not a function 

If wanted I can create a gist with the code to illustrate the error. If you have any pointers I can look on how to fix it myself.

Here is the relevant part of the code injected by the contracts.coffee compiler: https://gist.github.com/froginvasion/6925391 I annotated it, but this piece of code doesn't particularely make much sense to me. I put it next to the implementation of define in require.js but more than a general sense of what's actually happening I don't have.

Maybe a solution is reverting to an older version of require.js? This is what i'll try next.

mlippens avatar Oct 10 '13 20:10 mlippens

Sorry about the delayed response. Did reverting to an older version of require.js work for you? If not could you post the entire compiled script that is failing for you? I'm guessing that the __contracts function is not getting bound correctly.

disnet avatar Oct 29 '13 22:10 disnet

For me, using either chrome-stable with flags enabled or Firefox 25 the initial test failes in contracts.coffee/test/webtest/modules.html. You are correct in your assumption. Firebug reports TypeError __contracts is null. Any input on how to fix this? I debugged the code that contracts.coffee generates to support Require.js but couldn't exactly figure out what the problem is. Thanks for your response! (And sorry for my own late response)

mlippens avatar Nov 11 '13 15:11 mlippens