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

Can't resolve internal file imports in distribution package #158

Closed
claustres opened this issue Jul 11, 2024 · 8 comments
Closed

Can't resolve internal file imports in distribution package #158

claustres opened this issue Jul 11, 2024 · 8 comments

Comments

@claustres
Copy link

claustres commented Jul 11, 2024

Switching from v1 to v3 in an app using WebPack but without using TS I struggled with import errors like this:
image

It appears that the missing .js extension of the import statements in the dist folder get WebPack messy. Just to confirm the issue I used https://github.com/beenotung/fix-esm-import-path to fix it like this fix-esm-import-path node_modules/protomaps-leaflet/dist/index.js. However, I am not a TS gourou so I guess there is a compile option to do so as it would ease integration.

@claustres
Copy link
Author

I made some research and it seems that the best thing to do is to specify file extension at the source level (ie TypeScript) otherwise you have to use the kind of hacking tool I used like babel plugins or so.

@bdon
Copy link
Member

bdon commented Jul 16, 2024

Can you create and share a minimal WebPack example that reproduces your problem without TypeScript?

@claustres
Copy link
Author

Probably not so easy but I can first share the setup of our application, which is based on Quasar Webpack support.

@bdon
Copy link
Member

bdon commented Jul 16, 2024

We're likely going to migrate the build scripts to https://github.com/egoist/tsup which should improve the CommonJS situation, and also stop using default exports.

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

@claustres
Copy link
Author

claustres commented Jul 26, 2024

It seems to work fine now @bdon, thanks. Let me know when you plan to release a fix.

@bdon
Copy link
Member

bdon commented Jul 26, 2024

This major release will also move from bundled ESM modules/CJS to unbundled, which is what people expect for ES6 frontend and NodeJS projects. Waiting on #162 (comment) to see that there is a workable resolution for ESM-in-the-browser.

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 released: 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

2 participants