maphubs / tokml

Convert GeoJSON to KML.
BSD 2-Clause "Simplified" License
13 stars 11 forks source link

ESM compability #6

Closed d-koppenhagen closed 1 year ago

d-koppenhagen commented 1 year ago

Using this library fork (which seems to be the most up-to-date one) with Vite / ESM leads to a warning at console:

rebuilt dependencies successfully

  VITE v4.0.3  ready in 1251 ms

  ➜  Local:   http://127.0.0.1:8080/
  ➜  Network: use --host to expose
  ➜  press h to show help
▲ [WARNING] Converting "require" to "esm" is currently not supported [unsupported-require-call]

    node_modules/@maphubs/tokml/index.js:1:10:
      1 │ var esc = require('./lib/xml-escape')

Nonetheless the lib works.

Adding:

{ 
   "type": "module",
 }

...should solve this.

d-koppenhagen commented 1 year ago

my fault. Needed to change the import to:

import * as tokml from "@maphubs/tokml"
kriscarle commented 1 year ago

@d-koppenhagen I'm keeping this fork alive for now, but the original author tmcw also has a new version here https://github.com/placemark/tokml that you may want to check out.