jsonapi-datastore
jsonapi-datastore copied to clipboard
jsonapi-datastore does not work with requirejs
I'm using jsonapi-datastore (master branch at commit 12dc63e) via requirejs and I have to implement the following workaround to get it to work in jsonapi-datastore/dist/jsonapi-datastore.js...
if ( typeof define === "function" && define.amd ) {
define(function (require, exports, module) {
module.exports = {
JsonApiDataStore: JsonApiDataStore,
JsonApiDataStoreModel: JsonApiDataStoreModel
};
});
}
This hack is based on http://stackoverflow.com/a/29655291.
I'm not sure if this is the best solution to this problem so I haven't put it in a PR. Would adding this block to the end of jsonapi-datastore.js make sense?
P.S. With the above workaround I also have to change my require slightly to be...
var JsonApiDataStore = require("JsonApiDataStore").JsonApiDataStore;
Hi @theirishpenguin, thanks for the feedback – I've been fairly busy lately. If you find some time, would you mind issuing a PR to fix the situation?
#15 & #16 address this as well.
@beauby Ya, happy to PR it. Or @berlincount if this is better solved using #15 and #16 then I will not bother PR'ing this?
well, they are closed in master - verify whether they fix this for you :)
Is this fixed?
Hi, sorry somehow I missed your last message @berlincount.
@beauby, thanks for the follow up. I've just retested master but when I try do the require with...
var JsonApiDataStore = require("JsonApiDataStore");
... I see that JsonApiDataStore is undefined and this causes and error later in the code when I try to instantiate a JsonApiDataStore instance.
I've since moved away from using requirejs on my main projects so this issue is less important for me than it used to be. However I am happy to help debug this.