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

Check for proj4 in a way that also works in module environments #2333

Merged
merged 1 commit into from Jul 10, 2014

Conversation

ahocevar
Copy link
Member

This is better than #2330, and it should also address @probins's concern.

@marcjansen
Copy link
Member

Please merge once travis is happy, Andreas. Thanks.

ahocevar added a commit that referenced this pull request Jul 10, 2014
Check for proj4 in a way that also works in module environments
@ahocevar ahocevar merged commit 121d19e into openlayers:master Jul 10, 2014
@ahocevar ahocevar deleted the better-proj4-check branch July 10, 2014 18:36
@mokkabonna
Copy link

This still requires proj4 to be in the global namespace even when using module loaders. And since proj4 hides from the scope when using AMD this requires code that uses it to force a leak of proj4 like this: window.proj4 = proj4

Something like this needs to be done:

(function (root, factory) {
  if (typeof define === "function" && define.amd) {
    define(['proj4'], factory);
  } else if (typeof exports === "object") {
    //is this for node??, if so use this, if not root.proj4 as well here
    module.exports = factory(require("proj4"));
  } else {
    root.ol = factory(root.proj4);
  }
}(this, function (proj4) {

@ahocevar
Copy link
Member Author

@mokkabonna Thanks for pointing this out. Would you be able to provide a pull request with this fix?

@tcoopman
Copy link

tcoopman commented Apr 5, 2015

@mokkabonna I would love a fix for this!

@mokkabonna
Copy link

I can put together something yes. Just need to find some time, will put it in my backlog :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants