Skip to content
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

feat(dev): added Turbo monorepo / build runner #108

Closed
wants to merge 7 commits into from

Conversation

danielweck
Copy link

@danielweck danielweck commented Mar 4, 2022

https://turborepo.org/docs/getting-started

FULL TURBO

Without Turbo (PNPM recursive):

time pnpm build_ => 92.68s user 5.85s system 503% cpu 19.581 total

With Turbo:

  1. time pnpm build => 138.76s user 9.68s system 520% cpu 28.510 total (cold run, no cache)
  2. time pnpm build => 0.69s user 0.61s system 177% cpu 0.737 total (subsequent run with full cache hit and "replay" of dist output + console log)

I added the clean-turbo script in package.json to delete Turbo caches (alternatively, --force or --no-cache can be passed to pnpm build on the command line).

Note that the original build script was excluding specific packages, but Turbo builds everything faster.

PS: I fixed a Preact typings issue (JSX), and I updated the PNPM lockfile in order to work around a React typings conflict (multiple different versions in node_module).

UPDATE: I added a Turbo-driven alternative to the dev script in the root package.json. The developer experience is improved thanks to Turbo caching, compared with Rollup's own watcher mode.

@vercel
Copy link

vercel bot commented Mar 4, 2022

Someone is attempting to deploy a commit to a Personal Account owned by @pablo-abc on Vercel.

@pablo-abc first needs to authorize it.

@vercel
Copy link

vercel bot commented Mar 4, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pberganza10/felte-docs/H1wJHPVLPFaxZBw1ggYZSUesxkQ3
✅ Preview: Canceled

[Deployment for d78370e canceled]

@pablo-abc
Copy link
Owner

Thanks! I had experimented a bit with Turbo but not decided yet if I wanted to move this repo to using it. Mainly due to the missing --filter feature (I use it heavily locally).

From this:

"<!-- Turbo bug / missing feature -->": "https://github.com/vercel/turborepo/pull/81#issuecomment-1058911676 --scope=\"@felte/*\" --scope=\"felte\" --scope=\"!@example/*\" --scope=\"!@felte/site\" --ignore=\"examples/**/*\" --ignore=\"packages/site/**/*\"",

I understand this feature hasn't been implemented yet?
And is the purpose of this "command" to be replaced by something else in the future?


What would be the advantage of using chokidar instead of relying on rollup -cw? Better caching for Turbo?

The main reason I had not gone with Turbo yet was that running rollup -cw basically removed all the cache from Turbo, making every build a cold run after that.


Note that the original build script was excluding specific packages, but Turbo builds everything faster.

The packages I excluded were the examples (which I never need to build since they're meant for CodeSandbox which relies on the dev command), and the documentation site (which only gets built on CI). Is this where you were getting the typing issues with Preact? I have not experienced anything like that yet.


It seems some tests are failing, but I see you didn't modify any source code in that sense.


Anyway, I'll pull this and see how it feels later today!

@danielweck
Copy link
Author

danielweck commented Mar 7, 2022

Hello again :)

Having tried Turbo on multiple projects (including this modest Felte PR), the benefits are immediately perceivable: much shorter build and re-build times (e.g. "watch" mode or just subsequent manual builds) thanks to cache replay of both the dist artefacts and the console log. The DX is much improved.
As you can see in the PR, the lack of --filter equivalent in the current version of Turbo is not a blocker (everything builds fine first time around, and subsequent cache hits are cheap), but eventually it will be nice to activate the equivalent of your original CLI / build task package filters (which is why I left the comment in package.json).
Using chokidar means that there is a single global watcher over the monorepo, and Turbo takes care of caching / rebuilds. Have you tried?
On my MacBook M1 (original base model) the Uvu tests fail in a pure clone of your repository, so I am not able to comment about the CI failure here in this PR.
The Preact failure was due to React @types in PNPM node_modules (version conflict). Oh, and the React code itself was failing to build but I solved that by making sure to use the latest semantic versions of your original NPM packages (thus why the pnpm-lock.yml file is updated).

@pablo-abc
Copy link
Owner

Hey again! I tried this locally a bit and I do feel the improvements. I just saw this: vercel/turborepo#887

If you feel like it, I'd love it if we can wait for that before this gets merged! There's some specific niceties of "--filter" I have that I do miss while using this. Let me know what you think!

@danielweck
Copy link
Author

I've been using Turbo's --filter feature in a side project, it works great 👍

https://github.com/vercel/turborepo/releases/tag/v1.2.0

I'm not sure I'll have time to update this PR soon though 😢

@danielweck
Copy link
Author

Hello, I am closing this PR due to lack of activity. Keep up the good work :)
Daniel

@danielweck danielweck closed this Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants