Comments (10)
Bizarre, thanks for pointing this out. Not much has changed in between - might be a rollup regression.
from togeojson.
I'm having a lot of trouble replicating this error. Importing directly from the esm file, using webpack… I can't find a setup that has this error. The dist files on npm look normal and mostly unchanged. Can you share anything about your setup or a repro case that'd help me debug? Thanks!
from togeojson.
Yeah, here's what my package.json looks like
"dependencies": {
"@arcgis/core": "^4.22.2",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@fontsource/roboto": "^4.5.1",
"@iconify-icons/carbon": "^1.1.7",
"@iconify-icons/mdi": "^1.1.42",
"@iconify/react": "^3.1.2",
"@mui/icons-material": "^5.2.5",
"@mui/material": "^5.2.8",
"@mui/system": "^5.2.8",
"@reduxjs/toolkit": "^1.7.1",
"@tmcw/togeojson": "^4.5.0",
"browser-xml2js": "^0.4.19",
"buffer": "^6.0.3",
"client-zip": "^2.0.0",
"geodesy": "^2.3.0",
"leaflet": "^1.7.1",
"leaflet-ellipse": "^0.9.1",
"milsymbol": "^2.0.0",
"react": "^17.0.2",
"react-color": "^2.19.3",
"react-dom": "^17.0.2",
"react-leaflet": "^3.2.2",
"react-leaflet-custom-control": "^1.2.2",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.1",
"redux-undo": "^1.0.1",
"typescript": "~4.1.5",
"uuid": "^8.3.2"
}
Running npm install
installs @tmcw/[email protected]
as expected.
Node is version 17.3.0
NPM is version 8.3.0
Looking in /node_modules/@tmcw/togeojson/dist/togeojson.js
the exports are definitely there, but for some reason, it does not like it.
from togeojson.
The relevant code in my handler file is:
import { kml } from '@tmcw/togeojson'
const domParser = new DOMParser()
const parsedKML = domParser.parseFromString(reader.result, 'text/xml')
let geojson = kml(parsedKML, { styles: true })
from togeojson.
I am getting the error too using require:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: [....\node_modules]()@tmcw\togeojson\dist\togeojson.js
require() of ES modules is not supported.
from togeojson.
I am having the same issues, both with loaders.gl/kml
, and @tmcw/togeojson
.
togeojson.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename togeojson.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /path/to/project/node_modules/@tmcw/togeojson/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
NPM: 8.5.2
NodeJS: v10.19.0
@tmcw/togeojson": "^4.5.0
from togeojson.
Okay, it was the type: "module"
field, which opens a real can of worms. Introduced 4.6.1, which renames main
to .cjs
and adds an export
field in package.json to direct users to that. Any luck with that?
from togeojson.
I installed the update and things looks good thus far. Will reply back if I find any issues.
from togeojson.
👍 Okay, let me know if anyone encounters any other issues.
from togeojson.
Looks good, thanks!
from togeojson.
Related Issues (20)
- Remove swc dep?
- Add support for LinearRing outside Polygon HOT 1
- GPX conversion adds "s" character to extension names HOT 1
- TS7016: Could not find a declaration file
- GPX metadataType HOT 2
- KML Bounds Not Parsed HOT 3
- Unexpected link to online shop in dist/lib HOT 1
- skipEmpty option for KML HOT 1
- KMZ overlay with rotation not working correctly HOT 2
- KMZ overlays not aligning same as seen in Google Earth HOT 3
- gpxx extensions without namespace HOT 1
- Reason for not mapping all found TrackPointExtensions, and only keeping one? HOT 2
- Which babel loader required to import KML HOT 3
- gpx() and kml() types aren't symmetric HOT 2
- This should complain if the input is not valid XML or valid KML HOT 1
- Unable to use ESM import HOT 5
- Translate TCX courses to folders
- Translate GPX trk elements to Folders
- Keep KML placemarks with missing coordinates HOT 4
- Folder data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from togeojson.