react-notion-x
react-notion-x copied to clipboard
#429 Migrate to turbo and pnpm
Description
Replaced Lerna and Yarn with Turbo and Pnpm.
Changes:
- More
tsupand lesstsctsupis the recommended tool inturbodocstsup --watchreplaces all thewatchtasks. It automatically re-builds a package when in development tasks. Docstsupnow generates the type definitions with the configdts: trueontsup.config.tsDocs
- tsconfig's
compositeis not supported bytsup, so I've changed it tofalsehttps://github.com/egoist/tsup/issues/571.- This is also the recommended config on the
turbodocs
- This is also the recommended config on the
- dependencies are linked internally with
"workspace:*". They should get replaced by the actual version when publishing Pnpm workspaces. - Documentation updates (Readme files)
- Organized tasks to match turborepo pattern
- This pattern parallelizes tasks and only runs what's needed
turbotasks docs - Lint tasks moved to each workspace.
turbolinting docs - Test task dependencies coordinated through turbo pipeline (
turbo.json) - "pre" tasks are defined in pipeline as dependencies. Therefore, they were removed from
package.json - publish tasks moved to workspaces and dependencies defined in
turbo.json.- Defined dependencies only for workspaces that use publish because of this bug https://github.com/vercel/turbo/issues/2988
- This pattern parallelizes tasks and only runs what's needed
- Renamed
deploytask tovercel-deployin examples to avoid confusion withpnpm deploy- Now running
pnpm vercel-deployandpnpm run vercel-deployare valid from an example directory - The alternative is to keep the
deployname but that would only work withpnpm run deploybecausepnpm deployis an existent pnpm command.
- Now running
- Configured tasks caches with
turbocaching.
Benefits
This change has the following advantages:
- Simplifies processes: E.g. You can now run
devwith a single command - Faster re-builds: Turbo auto caches builds per package
- Faster builds, lint, test: Turbo runs things in parallel whenever possible
- Faster re-installs: Pnpm auto caches node modules
- Modern tools: Using these new tools is a better developer experience overall and they have better documentation.
Turbo Examples
The configuration was inspired by Turborepo official examples
-
Basic example: https://github.com/vercel/turbo/tree/main/examples/basic
-
CRA example: https://github.com/vercel/turbo/tree/main/examples/with-create-react-app
-
Kitchen sink example; https://github.com/vercel/turbo/tree/main/examples/kitchen-sink
-
This bugfix was needed for a correct build of
notion-x-example-fullhttps://github.com/NotionX/react-notion-x/pull/459
Tests
[x] Installing
pnpm i
[x] Running a global build:
turbo build
[x] Running a build from the package dir
cd packages/notion-utils
pnpm build
[x] Running every dev task
turbo dev
[x] Running tests execute unit eslint and prettier.
turbo test
[x] Running dev in a single example, modifying a dependency, and verifying it rebuilds it
turbo dev --filter=notion-x-example-minimal...
[x] Connecting with nextjs-notion-starter-kit.
yarnlink and the contributing docs from that repo are still valid after this change https://github.com/transitive-bullshit/nextjs-notion-starter-kit/blob/main/contributing.md
[x] Running publish executed the correct tasks
turbo publish
[x] Running vercel deploy
cd examples/minimal
pnpm run vercel-deploy
[x] The cache works as expected in all tasks
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated (UTC) |
|---|---|---|---|
| react-notion-x | ❌ Failed (Inspect) | Apr 8, 2023 9:45am | |
| react-notion-x-minimal-demo | ❌ Failed (Inspect) | Apr 8, 2023 9:45am |
Feedback is encouraged. I had to make a few choices here and there and I'm unsure if they are the best.
Also, it seems like deployments are failing and I can't inspect or check details. @transitive-bullshit let me know if there is anything I can do to fix them.