-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug] Release ESM compliant package (was: Does not build with AstroJS) #2272
Comments
Revert this once visgl/react-map-gl#2272 is resolved…
I also experienced the same issue trying to run |
This comment was marked as outdated.
This comment was marked as outdated.
I found a workaround for my Issue in AstroJS using "bun": (Sorry, I commented previously that this did not work, but it does…) After "reading" https://youtu.be/dWqNgzZwVJQ?si=rK9KsaYgIw74BU1Q&t=140 which claims that bun is super smart about resolving commonJs <> ES Modules issues, I wanted to try if it would resolve the given issue. One can use https://docs.astro.build/de/recipes/bun/ as a guide to switch to bun. However, you also need to delete your I then get the same error as before …
However, this time following the suggestion is a valid work around, so after applying… -import * as reactmapgl from 'react-map-gl/maplibre'
+import * as reactmapgl from 'react-map-gl/dist/es5/exports-maplibre.js' on all files, the build works 🥳 . FYI with this setup, the error message when using the "regular" import like Error message
|
We will need to build the source differently if we want to switch to a proper ESM module, not just modify package.json. I can get a 7.2.0-beta release for testing. There are so many bundlers and build environments now it's hard to test them all. @csdiehl I'd appreciate a repo that reproduces your issue with webpack. |
Try |
@Pessimistress it looks like this solves all issues! I was able to build and deploy using bun in https://github.com/tordans/berlin-bikenetwork-monitoring Thanks a lot! |
@Pessimistress a quick update on my testing of However, I just watched https://www.youtube.com/watch?v=jmNuEEtwkD4 and the docs made me aware of those testing pages … which still show some errors… The publint.dev looks most helpfull.
|
@tordans Thanks for the pointers. They are quite useful indeed. |
Description
Using ReactMapGL within an AstroJS Project (https://docs.astro.build/) does work great in Dev mode but fails on build
npm run build
.It looks like #2268 is partial solution but the
*.mjs
part that was mentioned in this PR is still required to get it working.Test 1:
import ReactMapGl, { NavigationControl } from 'react-map-gl/maplibre'
Using the standard import does result is errors like this:
CODE: https://github.com/tordans/berlin-bikenetwork-monitoring/blob/0704fe8a517e75669154e1bf2a9e5ec0ca810da8/src/components/Map/Map.tsx
Test 2:
import ReactMapGl, { NavigationControl } from 'react-map-gl/dist/es5/exports-maplibre.js'
Following the advice of the error output from test 1 …
CODE: tordans/berlin-bikenetwork-monitoring@d390bbf
This fails with:
Test 3 Modify package and `import * as reactmapgl``
I overwrote my
node_modules/react-map-gl/package.json
based on https://github.com/visgl/react-map-gl/pull/2268/files and updated the imports.CODE: tordans/berlin-bikenetwork-monitoring@e54fb18
Example of the change
Expected Behavior
No response
Steps to Reproduce
Environment
Logs
No response
The text was updated successfully, but these errors were encountered: