Skip to content

Build the libraries before the storybook - #816

Merged
acasazza merged 1 commit into
v5.0.0from
fix/netlify-build-workspace-deps
Aug 21, 2026
Merged

Build the libraries before the storybook#816
acasazza merged 1 commit into
v5.0.0from
fix/netlify-build-workspace-deps

Conversation

@acasazza

Copy link
Copy Markdown
Member

The Netlify deploy on #619 failed with:

Error: [vite]: Rolldown failed to resolve import
"@commercelayer/core-components" from
"/opt/build/repo/packages/react-components/src/hooks/useCommerceLayer.ts".

Cause

The storybook's Vite config aliases @commercelayer/react-components straight to its source, which is why #815 assumed no prior build was needed. That assumption was wrong: the aliased source imports @commercelayer/core-components, a workspace package whose entry point is ./dist/index.js, and nothing aliases that. On a clean checkout dist/ does not exist, so rolldown cannot resolve it.

It passed locally only because dist/ was left over from earlier builds. Deleting the three dist/ directories reproduces the Netlify failure exactly — same message, same file, exit 1 — and pnpm build makes it pass again.

This is not about publishing to npm. The dependency is declared "@commercelayer/core-components": "workspace:*", so pnpm links the local package and never consults the registry; the reproduction above happens with nothing published.

Fix

pnpm build && pnpm docs:build in netlify.toml, and the same in the gh-pages workflow, which carried the identical latent bug — it also ran docs:build alone and would have failed the same way on a clean runner. It has just been re-armed with its push trigger, so it would have broken on the next push to main.

Verification

Simulating a clean checkout by deleting packages/*/dist and running the exact command Netlify will run:

  • pnpm build && pnpm docs:build → exit 0, packages/docs/storybook-static produced
  • without the fix, from the same clean state → exit 1 with the error above
  • pnpm test — 998 passed / 24 skipped

The Netlify deploy preview on #619 remains the only real end-to-end signal; it will re-run once this lands on v5.0.0.

The Netlify deploy failed with 'Rolldown failed to resolve import @commercelayer/core-components from packages/react-components/src/hooks/useCommerceLayer.ts'.

The storybook's Vite config aliases @commercelayer/react-components straight to its source, so it looked like no prior build was needed. But that source imports @commercelayer/core-components, a workspace package whose entry point is ./dist/index.js — and nothing aliases it. On a clean checkout dist/ does not exist, so resolution fails. It passed locally only because dist/ was left over from earlier builds; deleting the three dist/ directories reproduces the Netlify error exactly, and pnpm build makes it pass again.

Not a publishing problem: the dependency is declared as workspace:*, so pnpm links the local package and never consults the npm registry.

The gh-pages workflow had the same latent bug — it also ran docs:build alone and would have failed identically on a clean runner.
@acasazza acasazza added the task label Aug 21, 2026
@acasazza acasazza self-assigned this Aug 21, 2026
@acasazza
acasazza merged commit ba0645a into v5.0.0 Aug 21, 2026
2 checks passed
@acasazza
acasazza deleted the fix/netlify-build-workspace-deps branch August 21, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant