Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Importing #161

Closed
George-Madeley opened this issue Jul 15, 2024 · 6 comments
Closed

Error Importing #161

George-Madeley opened this issue Jul 15, 2024 · 6 comments

Comments

@George-Madeley
Copy link

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:

  • 'symbolizer.js' in 'dist/default_styles',
  • '../default_style/style' in 'dist/frontends',
  • '../default_style/themes' in '\dist\frontends',
  • '../labeler' in 'dist\frontends',
  • '../painter' in 'dist\frontends',
  • '../view' in 'dist\frontends',
  • './tilecache' in 'dist',
  • './view' in 'dist',
  • './attribute' in 'dist',
  • './line' in 'dist',
  • './text' in 'dist'
@claustres
Copy link

It's probably a duplicate of #158.

@claustres
Copy link

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

@bdon
Copy link
Member

bdon commented Jul 16, 2024

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
Copy link
Author

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 added a commit that referenced this issue Jul 25, 2024
* change IIFE name from protomaps-leaflet.js to index.global.js
* change default export for theme.ts to named export
@bdon
Copy link
Member

bdon commented Jul 25, 2024

Can you please try 4.0.0-alpha.0

bdon added a commit that referenced this issue Jul 28, 2024
* Change to tsup for bundling [#158,#161,#162]
* change default export for theme.ts to named export
* update vector-tile, pbf and point-geometry dependencies [#162]
* 4.0.0
@bdon
Copy link
Member

bdon commented Jul 28, 2024

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

@bdon bdon closed this as completed Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants