box2d.ts
box2d.ts copied to clipboard
Evaluate Build & Publishing Tools
Goal: It would be nice to have tooling that supports build/release/publish workflows including good changelogs without requiring a steep learning curve, as that prevents people from contributing.
So there are multiple ways to go about this:
- Manual workflow:
- Yarn (current setup)
- supports installs for workspaces
- Good documentation
- Comfort shortcuts to execute scripts on one or multiple packages.
- No publishing helpers
- NPM v7
- Very new, not battle-tested
- supports installs for workspaces
- documentation scarce
- No comfort shortcuts like yarn workspace(s) command
- No publishing helpers
- todo: research PNPM
- todo: research additional tooling:
- semantic-release
- commitlint
- auto-changelog
- release-it
- ...
- Yarn (current setup)
- Advanced workflow:
- Lerna
- todo: research pros/cons
- Rush
- todo: research pros/cons
- Lerna
- todo: research more tools
Nice read: https://medium.com/@askjkrishna/scaffolding-a-project-using-lerna-and-lerna-changelog-cad6156f6f36
It looks as if the requirement to learn lerna can be moved to a select few people, as it works with yarn workspaces in a way, that enables developers to just use yarn when doing changes and creating PRs.
Also, lerna seems to be the de facto standard: https://www.npmtrends.com/release-it-vs-semantic-release-vs-standard-version-vs-lerna-vs-@microsoft/rush
So I'll give this setup a try: yarn + workspaces + lerna + lerna-changelog.
So, publishing with lerna seems to work nicely.
lerna-changelog on the other hand is a lot of work:
- You need to mark PRs with labels, so they appear in the changelog
- When running lerna-changelog, Changelog will only be printed to the console. It won't be merged automatically into the changelog.md file and it won't be added to github release descriptions either. You have to copy/paste it.
I was hoping that lerna would handle that last part, but it doesn't seem to do that. Or maybe I'm not getting how to configure it correctly.
Will take a look at other tools.
After searching about monorepos and workspaces I can tell :
- Pnpm: It has a high performance module/dependency resolution system ("cleaner" node_modules) and it allows to run workspaces commands with filtering pattern (not possible with lerna). Also the workflow seems to be designed to avoid popular problems or redundant tasks with other tools, but I didn't dig enough to be sure. It's also more recent than other tools and not much popular, trends are going up slowly but stable compared to Lerna.
- Rush: Honestly this thing is built behind attractive marketing and their official page only mention Microsoft related products/companies using it, I stopped searching about it quite fast especially since the trends hardly goes up.
- Npm 7: I'm almost finished refactoring all my code in a monorepo with npm 7 workspaces. It works great, node_modules only in root folder, local modules resolution is seamless and I can run my scripts just fine, no helper indeed. I'll give some feedback after publishing.
I'm not using any tools for now but I will probably install Lerna to automate some tasks based on what you did here :)
- pnpm: Unless I am reading the documentation wrong, the don't offer anything for publishing workpaces unless you want to publish the root package.json.
- npm 7 compared to yarn: Try running scripts or adding dependencies of/to a package from the root folder and you'll notice the difference in comfort.
- Rush: I tried it once actually, but it's too much configuration. There's also this little quote: "NPM 4.5.0 is the most recent version that’s known to work very reliably, but unfortunately it’s pretty old."
I'm using lerna only for releasing and publishing new versions. It seems a bit overkill for just this "simple" task, but I wasn't able to find any good alternatives yet. Most of these release libraries don't natively support workspaces.
I didn't face any problems with dependencies, but I manage them manually in package.json files. I only run npm install from the root folder, never in sub folders. It's really feels ok for me to write dependencies manually because VSCode has completion on npm packages and the version is filled with the latest one.
About pnpm sadly the pnpm recursive publish is still in developments, I thought it was already working. In their issue pnpm#2225 someone link to an interesting project called changesets, you should take a look !
Nice read: medium.com/@askjkrishna/scaffolding-a-project-using-lerna-and-lerna-changelog-cad6156f6f36
It looks as if the requirement to learn lerna can be moved to a select few people, as it works with yarn workspaces in a way, that enables developers to just use yarn when doing changes and creating PRs.
Also, lerna seems to be the de facto standard: npmtrends.com/release-it-vs-semantic-release-vs-standard-version-vs-lerna-vs-@microsoft/rush
So I'll give this setup a try: yarn + workspaces + lerna + lerna-changelog.
TBH yarn workspaces should be enough. Maybe you didn't try yarn workspaces of version 3. It's so simple and so efficient... Lerna has been deprecated for a while but somebody recently took over and continued the maintenance therefore you can still use it with no issue, but still, I think you can remove complexity here :) . Wanna me to try?
Hi, just passing by again :)
I've been using NX to manage multiple libraries and applications in the same workspace and it works perfectly, with convenient commands ! It works with npm, yarn and you can even integrate lerna.
Using this tool has been a real relief to manage a workspace !
I was suggesting removing complexity not adding some. NX is probably great but being minimalist if the project has no special need can be a plus to improve maintainability.
Besides that I apologize, it was not intended to create a debate that is useless to the core of the project.
I've been using nx in some other projects and I was thinking about using it here as well. It makes development a lot easier, as changes from a library can instantly be seen in the testbed rather than having to recompile the library first.
I've seen, that nx developers took over lerna, but I tend towards not using lerna anymore, as the release process can be done with a simple script, at least from linux: https://github.com/Lusito/tsx-dom/blob/master/release.ts
I'll give this a try soon.
What'll still have to be decided is the automatic changelog creation. Maybe this can be done semi-automatic. I've done something similar recently at work.