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

Error "Can't find variable: Map" for app with Turf v5.1 in PhantomJS #1245

Closed
ath0mas opened this issue Feb 2, 2018 · 3 comments
Closed

Comments

@ath0mas
Copy link
Contributor

ath0mas commented Feb 2, 2018

Testing my app with PhantomJS worked well till updating Turf from v4.6 to v5.1.6 ; it now fails with ReferenceError: Can't find variable: Map for a given line in turf.min.js (custom build through turf-builder).

It seems to be kind of a known issue when Map is called inside PhantomJS as it doesn't support ES6 features.

found that the source file in v5.1 includes new Map();:

  function HashMap () {
    MapInterface.call(this);
    this.map_ = new Map();
  }

and that in v5.0 it was polyfilled:

var MapImpl = typeof Map === 'undefined' || !Map.prototype.values ? MapPolyfill : Map;
...
function HashMap() {
  /**
   * @type {Object}
   * @private
  */
  this.map_ = new MapImpl();
}

as a result, source is not pure ES5
know why this change?

@DenisCarriere
Copy link
Member

That's another jsts Polyfill.

@ath0mas I'd recommend using the specific modules that you need instead of the global Turf.

We won't be publishing another global bundle until v6.x, so even if this change is patched it "should" no longer use jsts (which uses this Map polyfill).

@ath0mas
Copy link
Contributor Author

ath0mas commented Feb 5, 2018

Problem is with dep change from jsts to turf-jsts that rewrote HashMap dropping MapPolyfill

@tmcw
Copy link
Collaborator

tmcw commented Jun 25, 2018

Closing; #88 is the tracking issue for JSTS.

@tmcw tmcw closed this as completed Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants