Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonapi-datastore does not work with requirejs #20

Open
theirishpenguin opened this issue Dec 14, 2015 · 7 comments
Open

jsonapi-datastore does not work with requirejs #20

theirishpenguin opened this issue Dec 14, 2015 · 7 comments

Comments

@theirishpenguin
Copy link

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?

@theirishpenguin
Copy link
Author

P.S. With the above workaround I also have to change my require slightly to be...

var JsonApiDataStore = require("JsonApiDataStore").JsonApiDataStore;

@beauby
Copy link
Owner

beauby commented Mar 10, 2016

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?

@berlincount
Copy link

#15 & #16 address this as well.

@theirishpenguin
Copy link
Author

@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?

@berlincount
Copy link

well, they are closed in master - verify whether they fix this for you :)

@beauby
Copy link
Owner

beauby commented Oct 21, 2016

Is this fixed?

@theirishpenguin
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants