Closed chriswible closed 6 years ago
This is not for server-side use, by the way. I've also read the RequireJS docs for this error and followed their recommendations. (http://requirejs.org/docs/errors.html)
Interesting that the error goes away when I put rrule and nlp in the same file. It would appear that the error is being caused by nlp?
RRule works for me, but I have to merge the two files (rrule.js and nlp.js) in order for that error to go away. Am I missing something?
I don't think loading of the .js files via RequireJS has ever been tested. require()
works properly when the scripts are already loaded though:
Thanks for looking into it for me, I've been quite confused. In your changelog, under 1.1.0, you said you added support for RequireJS - I took that to mean I could include rrule and nlp as requirejs modules and load them via js.
Thanks for checking though.
RequireJS has been added via a pull request someone has opened. Feel free to look into fixing this.
@chriswible Because nlp.js
has an implicit dependency on rrule.js
, you need to shim it in your configuration. (At least, this is what worked for me.)
requirejs.config({
paths: {
"rrule": "path/to/rrule/rrule",
"rrule-nlp": "path/to/rrule/nlp"
},
shim: {"rrule-nlp": {
deps: ["rrule"]
}
}
});
For me, I got the message:
Module name "nlp" has not been loaded yet for context: _
even though I had the shim as described above and I was including rrule-nlp as a dependency on the module where I was using it. My fix was to rename the module in my require configuration from rrule-nlp
to nlp
(to match the Require error I was getting.)
It seems like Require is looking for the nlp module by name rather than by path, although this line seems to be referencing it by path: https://github.com/jakubroztocil/rrule/blob/master/lib/rrule.js#L2271
Please reopen if you are still experiencing issues.
I'm having a very hard time implementing RRule with Require.js.
The rrule Changelog says there's Require.js support so I would expect to be able to do something like:
define([ 'jquery', 'underscore', 'backbone', '../../rrule/rrule', '../../rrule/nlp', ], function ($, _, Backbone, RRule, NLP) { ...
Or something similar. However, all variations I've tried result in this error:
Uncaught Error: Module name "rrule" has not been loaded yet for context: _
I've searched all over and I can't find an example of RRule being used with require in the wild. Is there any chance you could help me out? I think other users would benefit as well.
Thank you for your time, I'm so psyched to use your work.
Chris