fix: ensure motia CLI is built before workspace bin linking#1289
fix: ensure motia CLI is built before workspace bin linking#1289addy1947 wants to merge 1 commit intoiii-hq:mainfrom
Conversation
|
@kumaridivya5 is attempting to deploy a commit to the motia Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdded a Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
frameworks/motia/motia-js/packages/motia/package.json (2)
25-25: Consider the performance impact of building on every install.The
preparehook runs on everypnpm install, which means developers will experience build overhead whenever they:
- Switch branches with different dependencies
- Run
pnpm installto update dependencies- Clone the repository fresh
If the tsdown build takes several seconds, this adds friction to common development workflows.
Alternatives to consider:
postinstallinstead ofprepare: Runs after install but not before publish; may still solve the bin symlink issue with less overhead- Separate the CLI: Extract the CLI into a standalone package that doesn't require a build step (e.g., keep source as .mjs)
- Pre-commit hooks: Build the CLI via a pre-commit hook and commit the built artifact (though this adds built files to git)
The current approach is simple and fixes the immediate problem, but consider whether the install-time overhead is acceptable for your team's workflow.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frameworks/motia/motia-js/packages/motia/package.json` at line 25, The package.json currently runs "pnpm build" in the prepare script which triggers a build on every pnpm install; remove or replace this to avoid install-time build overhead by either (A) changing the script key "prepare": "pnpm build" to "postinstall": "pnpm build" if you only want builds after installs (not before publish), (B) remove the prepare script and document building in contributor/developer docs, or (C) extract the CLI into a separate package that ship-bundles the built artifact; update the "prepare" entry in package.json (the "prepare" script key) accordingly and ensure any consumers of the package still receive the needed built assets (or add a postinstall step or CI/publish generation as appropriate).
25-25: Consider updating CI workflows to avoid duplicate builds.The
preparehook will cause motia to be built duringpnpm install --frozen-lockfile. However, CI workflows (context snippets 1 and 3) explicitly build motia again after installation:- name: Install dependencies run: pnpm install --frozen-lockfile # Triggers prepare → builds motia - name: Build Motia run: pnpm --filter motia build # Redundant buildThis creates duplicate builds in CI, wasting compute resources and time. Consider either:
- Update CI workflows to skip the explicit
pnpm --filter motia buildstep (rely on prepare hook)- Use
--ignore-scriptsduring install and keep explicit builds (but then loses the bin fix locally)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frameworks/motia/motia-js/packages/motia/package.json` at line 25, The prepare script in package.json ("prepare": "pnpm build") causes motia to be built during pnpm install, creating a duplicate build when CI later runs pnpm --filter motia build; either remove the explicit CI step that runs pnpm --filter motia build (rely on the prepare hook) or change the install step to pnpm install --frozen-lockfile --ignore-scripts and keep the explicit pnpm --filter motia build; update the CI job accordingly to use one of these two approaches and document the chosen approach in the workflow comments so maintainers know why the build step was removed or why --ignore-scripts is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frameworks/motia/motia-js/packages/motia/package.json`:
- Line 25: The package.json currently runs "pnpm build" in the prepare script
which triggers a build on every pnpm install; remove or replace this to avoid
install-time build overhead by either (A) changing the script key "prepare":
"pnpm build" to "postinstall": "pnpm build" if you only want builds after
installs (not before publish), (B) remove the prepare script and document
building in contributor/developer docs, or (C) extract the CLI into a separate
package that ship-bundles the built artifact; update the "prepare" entry in
package.json (the "prepare" script key) accordingly and ensure any consumers of
the package still receive the needed built assets (or add a postinstall step or
CI/publish generation as appropriate).
- Line 25: The prepare script in package.json ("prepare": "pnpm build") causes
motia to be built during pnpm install, creating a duplicate build when CI later
runs pnpm --filter motia build; either remove the explicit CI step that runs
pnpm --filter motia build (rely on the prepare hook) or change the install step
to pnpm install --frozen-lockfile --ignore-scripts and keep the explicit pnpm
--filter motia build; update the CI job accordingly to use one of these two
approaches and document the chosen approach in the workflow comments so
maintainers know why the build step was removed or why --ignore-scripts is used.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c6fe4643-4344-4ca8-8e5a-13555445ebde
📒 Files selected for processing (1)
frameworks/motia/motia-js/packages/motia/package.json
|
Hey @rohitg00, I tried to fix the issue you reported regarding the error during the build. I made some changes that seem to resolve the problem on my side. Could you please take a look and verify if it works for you as well? |
Fixes #1179
Summary
Fix monorepo build failure where the
motiaCLI binary is unavailable during workspace installation.The
motiapackage exposes a CLI through thebinfield pointing todist/new/cli.mjs, but this file is generated only after running the build. Duringpnpm install, pnpm attempts to create the workspace binary symlink before the file exists, causing the playground build to fail withmotia: not found.This change adds a
preparescript to ensure the CLI is built before pnpm links the binary.How it works
Fix
Add a
preparescript in:What this does
prepareruns automatically duringpnpm installdist/new/cli.mjsis generated before pnpm creates workspace binary linksResult
The playground package can successfully execute:
and the entire monorepo build completes without errors.
Test plan
Before the fix
git clone https://github.com/MotiaDev/motia.git cd motia/motia-jsResult:
The build fails during the playground step with the error:
This happens because the CLI binary is not generated before pnpm tries to link it.
After the fix
git clone https://github.com/MotiaDev/motia.git cd motia/motia-jsAdd the
preparescript.Result:
dist/new/cli.mjsis generated during installationnode_modules/.bin/motiais created successfullymotia buildwithout errorsSummary by CodeRabbit