-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Open to JS code improvements/restructuring #287
Comments
|
Additionally, making this a native ESM library would be preferable and if people insist on using cjs they can just transpile this dependency. |
Isn't this already the case? The cjs etc targets are created by esbuild here: https://github.com/protomaps/PMTiles/blob/main/js/package.json#L14 |
There's a few more things required that's outlined well here: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c Also making it an ESM only package is desirable now to encourage people to stop using cjs as it's a constant burden on the ecosystem. Instead of us transpiring it, let them do it, ESM has support as far back as node 12, we should only be supporting 18, and soon 20 (current LTS). I also aim to eliminate all usage of the |
Thanks for the example. We need to stay on Node 18 instead of 20 because AWS Lambda doesn't have Node 20 yet. In general, I'm OK with the packaging set-up as is although it may not align with every individual developer's preferences. Ideally it should use as few devDependencies as possible to minimize the possibility of situations across all the platforms (all browsers + node + lambda + cloudflare workers + demo). Is there a specific pain point you intend to resolve with your changes that we might find another solution for? |
I am of the same mindset, minimal dependencies and minimal maintenance burden (reduced dev environment complexity). node 18 is fine, just keeping up with LTS is the important part, not necessarily running the current release. One thing that needs further looking into is the usage of globals from leaflet as it references AMD modules which are rarely used these days, my proposal would likely be to include leaflet types as a dev dependency so it's not actually bundled, and just mark it as an external dependency so the import is still included. One of the reasons I think this restructuring is important is in future I believe it would be good to adopt independent exports for different versions of the spec and not piggyback off of the previous version. A prime example of this is https://github.com/auth70/paseto-ts import {PMTiles, TileType} from "pmtiles/v4" |
Another option would be to put that into
|
Added Biome with these rules https://github.com/protomaps/PMTiles/blob/main/js/biome.json to ease the transition from Prettier. |
3.0 will also change to |
* make use of ===, if branches, let/const, string templates, var names consistent style.
Reading through your link https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c?permalink_comment_id=3850849#gistcomment-3850849 it looks like there are some risks with the dual |
ESM only is a good solution, people that require cjs support can just tanslile the module. |
Many of the major build tools/bundlers have options. One option outlined here may be a good workaround for most https://adamcoster.com/blog/commonjs-and-esm-importexport-compatibility-examples |
Namely async import |
* rename FileAPISource to FileApiSource * add @types/leaflet as dev dependency
as of https://github.com/protomaps/PMTiles/pull/337/files I have the uses of
Still haven't figured out a good solution to either. |
What if a seperate package was published to support leaflet? |
Apart from the examples are IIFE's actually still used by people? |
Yes, especially with Leaflet, and I need to support that use case. I'm already maintaining |
* In a few cases we need to use any and biome-ignore. Deferring any restructuring here to js v4. * replace prettier with biome
* rename FileApiSource to FileSource * In a few cases we need to use any and biome-ignore. Deferring any restructuring here to js v4. * replace prettier with biome
I backpedaled on some of the |
Add linters to AWS and cloudflare implementations [#287]
* pmtiles js v4: remove pmtiles spec v2 compatibility [#287] * restructure ts files into src * add tsup for building ESM/CJS and making types work in ESM * bump fflate dependency * update CHANGELOG for js 4.0.0
I published V4 which improves the ESM and TS situation (uses tsup) as well as drops spec v2 support, which has shown a deprecation notice for at least a year now. The IIFE build is now under 10KB compressed. Going to close this umbrella issue, please open other issues around specific improvements |
Hi, I use this library quite frequently, would you be open to receiving a PR that includes a bunch of project related improvements;
Use PNPM, modern exports, auto linting etc?
I'll prep the changes and if there there are specifics you don't agree with, I can revert them.
Thanks.
The text was updated successfully, but these errors were encountered: