protomaps / protomaps-leaflet

Lightweight vector map rendering + labeling and symbology for Leaflet
https://protomaps.com/docs/frontends/leaflet
BSD 3-Clause "New" or "Revised" License
767 stars 43 forks source link

Error Importing #161

Closed George-Madeley closed 4 months ago

George-Madeley commented 4 months ago

I cannot use leafletLayer or import anything from the protomaps-leaflet module as I am constantly getting import errors relating to the import extensions within the module

No default export exists so I cannot use:

import protomapsL from "protomaps-leaflet"

When I try and import leafletLayer, I get the following error:

ERROR in ~/node_modules/protomaps-leaflet/dist/frontends/static.js 32:0-35 Module not found: Error: Can't resolve '../painter' in '~\node_modules\protomaps-leaflet\dist\frontends' Did you mean 'painter.js'? BREAKING CHANGE: The request '../painter' failed to resolve only because it was resolved as fully specified (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"'). The extension in the request is mandatory for it to be fully specified. Add the extension to the request.

This is also repeated for:

claustres commented 4 months ago

It's probably a duplicate of https://github.com/protomaps/protomaps-leaflet/issues/158.

claustres commented 4 months ago

By the way you can "simulate" a default export with everything like this: import * as protomapsL from "protomaps-leaflet"

bdon commented 4 months ago

We need some way to reproduce your issue, which also depends on if your environment is CommonJS or ES Modules, what bundler you are using, TypeScript, etc. Can you create and share a minimal example?

George-Madeley commented 4 months ago

Environment: CommonJS, Bundler: Webpack, Typescript: 4.7.4,

ts.config:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": ["src", "src/tabs/.tsx"]
}
bdon commented 4 months ago

Can you please try 4.0.0-alpha.0

bdon commented 4 months ago

v4.0.0 has been published - please reopen if you are still having this issue. https://www.npmjs.com/package/protomaps-leaflet