Skip to content

chore: build rolldown-plugin before tsdown to avoid install race#78

Open
sam-goodwin wants to merge 1 commit into
mainfrom
fix/runtime-build-plugin-race
Open

chore: build rolldown-plugin before tsdown to avoid install race#78
sam-goodwin wants to merge 1 commit into
mainfrom
fix/runtime-build-plugin-race

Conversation

@sam-goodwin

Copy link
Copy Markdown
Contributor

packages/cloudflare-runtime/tsdown.config.ts imports @distilled.cloud/cloudflare-rolldown-plugin, which resolves to dist/plugin.js. When the workspace is built with bun run --filter (as the alchemy repo's prepare script does on bun install), bun orders workspace scripts by dependencies but not devDependencies — the plugin is only a devDependency of the runtime, so the runtime's build can start before the plugin's dist exists:

Cannot find module .../cloudflare-rolldown-plugin/dist/plugin.js
  imported from .../cloudflare-runtime/tsdown.config.ts

(Seen intermittently in alchemy's website.yml "Install dependencies" step, e.g. run 29860893544. cloudflare-vite-plugin doesn't race because it lists the plugin as a regular dependency.)

Fix: build the plugin explicitly before tsdown:

-    "build": "tsdown",
+    "build": "bun run --cwd ../cloudflare-rolldown-plugin build && tsdown",

Under turbo this is an incremental tsc no-op since ^build already built the plugin. Verified by deleting the plugin's dist + .cache and running bun run --filter '@distilled.cloud/cloudflare-runtime' build from the alchemy repo root — the plugin now builds first and the runtime build completes.

🤖 Generated with Claude Code

… install race

tsdown.config.ts imports @distilled.cloud/cloudflare-rolldown-plugin, which
resolves to dist/plugin.js. When built via bun run --filter (as the alchemy
repo's prepare script does), bun orders workspace scripts by dependencies but
not devDependencies, so the runtime's build could start before the plugin's
dist existed, failing config load with "Cannot find module .../dist/plugin.js".

Build the plugin explicitly first; under turbo this is an incremental tsc no-op
since ^build already ran.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

@distilled.cloud/cloudflare-rolldown-plugin

bun add https://pkg.distilled.cloud/cloudflare-rolldown-plugin/816e7e8

@distilled.cloud/cloudflare-runtime

bun add https://pkg.distilled.cloud/cloudflare-runtime/816e7e8

@distilled.cloud/cloudflare-vite-plugin

bun add https://pkg.distilled.cloud/cloudflare-vite-plugin/816e7e8

@sam-goodwin sam-goodwin changed the title fix(cloudflare-runtime): build rolldown-plugin before tsdown to avoid install race chore: build rolldown-plugin before tsdown to avoid install race Jul 21, 2026
@john-royal

Copy link
Copy Markdown
Collaborator

This seems like something that should be handled by turbo? Dev dependencies are still dependency-ordered for tasks unless turbo isn't running

@sam-goodwin

Copy link
Copy Markdown
Contributor Author

Might be an issue of git submodule in alchemy. I don't use turbo in alchemy

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