r/webdev • u/Accurate-Screen8774 • 18d ago
Best-Practices for Publishing a JS Framework
Im working on a project for myself. Its an unreviewed, unaudited and far from finished. It started of as a person curiosity and evolved from there. Its shaping up well enough to publish and share.
If i publish something on NPM, there are strict controls around versioning for which i havent burdened myself on my own projects (but clearly important when making something for a wider community). I also wonder if im overlooking any other details.
I wonder what best practices there are for something like this. Should i be publishing new versions with CI/CD? Are there any tips or advice for doing this in the modern js ecosystem?
Edit:
The project in question is found here. To explain it briefly, its basically an attempt to create JSX for webcomponents. You can learn more bout it here. Nobody should be using this. Is is not production ready.
6
u/PippaKelly62 18d ago
Stay on 0.x until the api settles, then follow semver from 1.0. Publish from ci with npm provenance and two factor on your account, ship only built files, and check what goes out with npm pack dry run. Add a readme with a minimal example, a license, and a changelog, and changesets can automate the versioning.
1
u/pikkola_lab 17d ago
A few things that caused more pain than versioning did:
Ship the types explicitly. For a JSX library the first wall is not your API, it is the user's tsconfig: they need to know what to set (jsx: react-jsx with jsxImportSource pointing at your package, or jsxFactory/jsxFragment on classic) and they need your .d.ts reachable through the exports map, not just main. If the package registers custom elements on import, put that in a separate entry like ./define and keep the main entry pure, because anyone marking the package sideEffects: false will otherwise drop the registration and get a blank page with no error.
Treat a version as permanent. Changesets handles the bump, but the unpublish window is 72 hours and only when almost nothing depends on you. Publishing with a dist-tag is cheap insurance: latest stays on the one you trust, next gets every 0.x bump, and testers install with the next tag.
Prove the tarball instead of trusting CI: npm pack, install the .tgz in an empty project, then import it as ESM and through a bundler. npm pack --dry-run lists files but does not catch a broken exports map.
One last one: publishing with provenance through GitHub OIDC needs a public repo, so decide the repo layout now rather than moving it after people start depending on it.
1
u/BoomerDan 16d ago
There are a couple good messages about versioning, I have to wonder why you would spend your time building another framework when something like https://lit.dev/docs/frameworks/react/ would accomplish the same goal of producing web components using jsx. So, is this just a learning project for you? If so, I would recommend putting the goals of your framework in the repo.
Either way, good luck.
2
u/[deleted] 18d ago
[removed] — view removed comment
1
u/[deleted] 18d ago
[removed] — view removed comment