-
Notifications
You must be signed in to change notification settings - Fork 113
ES Module Build System #224
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
base: master
Are you sure you want to change the base?
Conversation
2288ad5 to
63e1326
Compare
BREAKING CHANGE: Source files moved to src/ directory, built files in dist/ - Restructure project: source in src/, distribution files in dist/ - Add Rollup build system to generate ES module and IIFE distributions - Use named imports from Leaflet (Control, DomUtil, DomEvent, Map) - Configure dual package exports in package.json (ESM + IIFE) - Add Leaflet as peerDependency (^1.7.0 || >=2.0.0-alpha.1) - Add demo pages for both ESM and IIFE usage patterns with Import Maps - Create landing page with feature overview and demo links - Update README with build command documentation
626de4d to
cacf19c
Compare
|
Awesome, thx for this hard work ! Has i've already said before, i'm "a bit" away/oldschool on javascript ecosystem so i plainly trust your choices on module format and tools to use :)
I've tried to update myself on the subject and reading some posts like https://dev.to/fkkarakurt/javascript-module-formats-and-tools-3mg9 & https://javascript.works-hub.com/learn/javascript-modules-358ee let me think that's a good choice + the fact i like smaller/simpler options (y)
This refresh should be very welcomed by users, again, thx for that. You haven't mentioned this point, but if i'm not wrong your PR allow compatibility with future leaflet 2.0 ref #208 and it's great. Any thought on this @BePo65 ? |
|
Thanks! I'm glad you like the changes 😃 Regarding IIFE: Regarding Leaflet 2.0 compatibility:
Landing page So this PR addresses #208 and prepares us for the future but is still compatible with Leaflet 1.x 😃 |
|
IMHO this is a great PR and it solves the migration to leaflet@^2 too. And I love the demos 😄. Perhaps I could add a few ideas:
What do you think about this? |
|
Thx for the feedback @BePo65 :) 1.1 => good point, if it's easy to maintain these patterns we should do it. We can drop them later when they'll be obsolete. 3 => I was going to say that the dist folder is handy for people who want to get the script from a simple wget on the repo, but i see that Leaflet main branch doesn't provide it anymore, so maybe that's the way to do it now... |
|
Thanks from me too! 👍
That's also fine for me. I'll re-add UMD and drop IIFE 🙂
Exactly. In the long term, I see all plugins being ESM only.
I agree to your points. I'll take another look at it later and add a commit as a suggestion.
I kind of like it when the build files are in the repo. It makes it easier for me to check the diffs when I do a build after a change. But yes, they don't really belong in the repo. I'll add a commit for that. |
- UMD supports AMD, CommonJS and global L (browsers) - Renamed demo.iife.html to demo.umd.html - Added require export back to package.json
Build artifacts should not be tracked in git. They are reproducible via 'npm run build'.
- Add 'files' field to publish only dist/ - Add 'browser' field pointing to UMD - Add 'exports.require' field pointing to UMD
50cc71f to
4fddd36
Compare
|
I just added the changes. To "2. content for this package on npmjs ..." I've addressed this by adding the "files": ["dist/"]npm automatically includes The package now only publishes what's needed: I also added the What do you both think? 🙂 |
|
using the |
@BePo65 (y) can you approve the PR please ? |
This is a big change, but sooner or later this step would have been necessary, I think 🙂
It's difficult to review so much changes properly, I'm sorry. But in small, manageable PRs, it would be a very long process.
What's changed?
Project structure:
src/dist/npm run build)Modernizations:
import { Control, DomUtil } from 'leaflet')package.jsonBreaking Change:
The file structure has completely changed - hence this is a major release. But if users install the package via npm, users shouldn't notice thanks to proper exports configuration.
For users
With bundlers (Vite, Webpack, etc.):
Works as before, just with real ESM now.
In the browser with script tags:
Also works as before, just the file is now called
.umd.jsinstead of.js.Demos
Check out the new demos:
index.html- Landing pagedemo/demo.esm.html- ESM with Import Mapsdemo/demo.umd.html- Classic script tags2025-11-25 Edit: rollback from IIFE to UMD after review.