arthur-e / Wicket

A modest library for moving between Well-Known Text (WKT) and various framework geometries
https://arthur-e.github.io/Wicket/
Other
586 stars 226 forks source link

`wicket-gmap3.js` doesn't work with webpack #132

Closed freewind closed 5 years ago

freewind commented 5 years ago

I build my code with webpack, and the code is:

import Wkt from 'wicket/wicket-gmap3.js';
const wicket = new Wkt.Wkt('POINT(30 10)');
document.write(JSON.stringify(wicket, null, 2));

and package.json is:

"dependencies": {
    "wicket": "kbejnar/Wicket#add-umd"
  }

When I run, it reports error like:

Uncaught TypeError: wicket_wicket_gmap3_js__WEBPACK_IMPORTED_MODULE_0___default.a.Wkt is not a constructor
    at eval (entry.js:6)
    at Module../entry.js (bundle.js:97)
    at __webpack_require__ (bundle.js:20)
    at bundle.js:84
    at bundle.js:87

I found such code:

https://github.com/arthur-e/Wicket/blob/d48397f6e1478d54445a31015d7090c9744a626b/wicket-gmap3.js#L21-L25

I have to modify it to:

// CommonJS 
module.exports = factory( require('./wicket') ); 

Is this a bug or do I miss anything?