Skip to content

Fix the provider bundle test: put sharp back at the top level - #3482

Merged
forgetso merged 2 commits into
mainfrom
fix/cli-bundle-sharp-resolution
Oct 2, 2026
Merged

forgetso merged 2 commits into
mainfrom
fix/cli-bundle-sharp-resolution

Conversation

@forgetso

@forgetso forgetso commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

What's broken

@prosopo/cli's bundle test fails on every branch cut after the npm→pnpm migration (#3447), so every open PR is red. The error is:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sharp'
  imported from packages/cli/dist/bundle/provider.cli.bundle.js

Why

sharp is a native image library. It is deliberately not put inside the bundle — bundling its JavaScript part without the matching platform binary breaks the provider at runtime, which is why vite.backend.config.ts keeps it on the externals list and the provider Dockerfile installs it next to the bundle instead.

So the bundle expects to find sharp somewhere nearby when it runs. The test runs it from packages/cli/dist/bundle/, which has no node_modules of its own, so Node looks in each parent folder up to the top of the repo. npm used to put every package at the top, so sharp was always found there. pnpm only puts a package where something actually asked for it, and the only thing that asks for sharp is @prosopo/puzzle-assets. Nothing nearby, nothing found.

What changed

One setting in pnpm-workspace.yaml telling pnpm to also put sharp at the top level, which is where it used to be:

publicHoistPattern:
  - "sharp"

Nothing about the bundle changes: sharp is still external, and the Docker image still installs it exactly as before.

The other way to fix it is to list sharp as a dependency of packages/cli. That works too — I pushed it first and the bundle test went green — but lint:refs then fails, correctly, because no file in packages/cli imports sharp. Hoisting is the honest fix: it is an install-layout problem, not a missing dependency.

How it was verified

  • Pushed the dependency version first: the previously failing tests run went green, confirming sharp resolution was the only thing wrong.
  • Reproduced the failure and both fixes in a throwaway four-file pnpm workspace with the same shape (package A depends on a library, package B depends on A, run a script from B/dist/bundle/): resolution fails as shipped, and succeeds under publicHoistPattern.

🤖 Generated with Claude Code

sharp is a native module and is deliberately external to the bundle; the
provider image installs it beside the bundle at build time. The bundle test
runs it straight out of packages/cli/dist/bundle, which has no node_modules,
so resolution walks up to the workspace root — where npm's hoisting happened
to leave sharp. pnpm links a package only under whatever asked for it, and
only @prosopo/puzzle-assets asks for sharp, so the bundle test has failed
with ERR_MODULE_NOT_FOUND on every branch cut after the pnpm migration.

publicHoistPattern puts it back at the root. Declaring it on @prosopo/cli
instead also works, but the CLI's sources never import it and lint:refs
rightly rejects a dependency nothing imports.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@forgetso
forgetso force-pushed the fix/cli-bundle-sharp-resolution branch from 3bc22c0 to a09a5f8 Compare October 2, 2026 10:29
@forgetso forgetso changed the title Fix the provider bundle test: declare sharp as a CLI dependency Fix the provider bundle test: put sharp back at the top level Oct 2, 2026
@forgetso
forgetso enabled auto-merge (squash) October 2, 2026 11:50
@forgetso
forgetso merged commit b7a963a into main Oct 2, 2026
15 checks passed
@forgetso
forgetso deleted the fix/cli-bundle-sharp-resolution branch October 2, 2026 11:53
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.

1 participant