Git Product home page Git Product logo

Comments (10)

tmcw avatar tmcw commented on August 22, 2024

Bizarre, thanks for pointing this out. Not much has changed in between - might be a rollup regression.

from togeojson.

tmcw avatar tmcw commented on August 22, 2024

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.

chris-m92 avatar chris-m92 commented on August 22, 2024

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.

Screenshot 2022-03-07 154224

from togeojson.

chris-m92 avatar chris-m92 commented on August 22, 2024

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.

ewrayjohnson avatar ewrayjohnson commented on August 22, 2024

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.

SDBurt avatar SDBurt commented on August 22, 2024

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.

tmcw avatar tmcw commented on August 22, 2024

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.

SDBurt avatar SDBurt commented on August 22, 2024

I installed the update and things looks good thus far. Will reply back if I find any issues.

from togeojson.

tmcw avatar tmcw commented on August 22, 2024

👍 Okay, let me know if anyone encounters any other issues.

from togeojson.

chris-m92 avatar chris-m92 commented on August 22, 2024

Looks good, thanks!

from togeojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.