requirejs/require-cs

RequireJS error callback not used for CoffeeScript not found errors.

guybedford opened this issue · 2 comments

If I try to load a CoffeeScript file that doesn't exist:

  require(['cs!some/module'], function(m) {
  }, function(err) {
    console.log(err.toString());
  });

then instead of the error callback catching it, it throws the error entirely. Ideally, the same error callback could be triggered.

The error message is:

  Uncaught Error: fromText eval for some/module failed: ReferenceError: Not is not defined 

Right, looks like this plugin is not using the load.onerror functionality. If you want to work up a patch, you can look at the text plugin for inspiration. Specifically:

https://github.com/requirejs/text/blob/master/text.js#L165

shows passing an errback function to text.get (which is called fetchText in this plugin), and then fetchText in this plugin would need to be modified to call the errback function on a failure.

Ok great I will get to this along with the xhr hooks, although it may be another week or so yet before I can get down to it.