Skip to content

Fix/config fixes#2636

Open
bramvanderholst wants to merge 3 commits into
canaryfrom
fix/config-fixes
Open

Fix/config fixes#2636
bramvanderholst wants to merge 3 commits into
canaryfrom
fix/config-fixes

Conversation

@bramvanderholst
Copy link
Copy Markdown
Contributor

@bramvanderholst bramvanderholst commented May 28, 2026

Summary

Two config-loading fixes for the GraphCommerce CLI / Next.js build flow.

What's in this PR

fix(next-config): replace cosmiconfig's racing TS loader with SWC

When loading graphcommerce.config.ts, cosmiconfig's built-in sync TypeScript
loader transpiles to a fixed .cjs path on disk and removes it in a finally
block. Under Turbopack (which spawns worker processes that load the config
concurrently), one process deletes the file while another is still trying to
require it — producing panics like Cannot find module …graphcommerce.config.cjs.

The .ts loader now transpiles via SWC (already a dependency) and writes to a
per-process unique filename next to the source —
.graphcommerce.tmp.<pid>-<counter>.cjs — so concurrent workers can never
collide. loadConfig stays synchronous; no callsite changes
(withGraphCommerce, CLI commands, mesh, hygraph-cli).

fix(gql-codegen): codegen no longer stops halfway

gc-gql-codegen would silently stop mid-run — TTY detection in graphql-codegen's
CLI suppressed spinner output and set a wrong exit code.
Piping the command through cat forces a non-TTY pipe so codegen
runs to completion with correct exit semantics.

cosmiconfig's built-in synchronous TypeScript loader transpiles
`graphcommerce.config.ts` to a fixed `.cjs` path on disk and removes it
again in the finally block. When Next.js (especially Turbopack) spawns
worker processes that load the config concurrently, one process can
delete the file while another is still trying to require it — producing
panics like "Cannot find module …graphcommerce.config.cjs".

Replace the `.ts` loader with one that uses `@swc/core`'s
`transformFileSync` and writes to a per-process unique filename:

  .graphcommerce.tmp.<pid>-<counter>.cjs

next to the source. Unique filenames mean concurrent workers can't
collide on the temp path; placing it next to the source keeps any
relative `require()` in the config resolvable. The file is removed in
the finally block as before.

No new dependencies and no API change — `loadConfig` stays sync, so all
existing callsites (`withGraphCommerce`, the CLI commands, mesh, etc.)
keep working unchanged.
…y through

Cursor: The issue was a TTY handling bug in graphql-codegen's CLI. When running in Cursor's terminal without a proper TTY:
The spinner/progress output was suppressed
The exit code was incorrectly set to 1

The fix was to pipe gc-gql-codegen through cat, which forces proper output handling
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: a16bbe5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 86 packages
Name Type
@graphcommerce/next-config Patch
@graphcommerce/magento-open-source Patch
@graphcommerce/magento-graphcms Patch
@graphcommerce/hygraph-dynamic-rows-ui Patch
@graphcommerce/framer-scroller-example Patch
@graphcommerce/magento-storyblok Patch
@graphcommerce/docs Patch
@graphcommerce/browserslist-config-pwa Patch
@graphcommerce/changeset-changelog Patch
@graphcommerce/eslint-config-pwa Patch
@graphcommerce/graphql-codegen-markdown-docs Patch
@graphcommerce/graphql-codegen-near-operation-file Patch
@graphcommerce/graphql-codegen-relay-optimizer-plugin Patch
@graphcommerce/misc Patch
@graphcommerce/prettier-config-pwa Patch
@graphcommerce/typescript-config-pwa Patch
@graphcommerce/address-fields-nl Patch
@graphcommerce/algolia-categories Patch
@graphcommerce/algolia-insights Patch
@graphcommerce/algolia-personalization Patch
@graphcommerce/algolia-products Patch
@graphcommerce/algolia-recommend Patch
@graphcommerce/algolia-search Patch
@graphcommerce/cli Patch
@graphcommerce/demo-magento-graphcommerce Patch
@graphcommerce/ecommerce-ui Patch
@graphcommerce/framer-next-pages Patch
@graphcommerce/framer-scroller Patch
@graphcommerce/framer-utils Patch
@graphcommerce/google-datalayer Patch
@graphcommerce/google-playstore Patch
@graphcommerce/googleanalytics Patch
@graphcommerce/googlerecaptcha Patch
@graphcommerce/googletagmanager Patch
@graphcommerce/graphcms-ui Patch
@graphcommerce/graphql-mesh Patch
@graphcommerce/graphql Patch
@graphcommerce/hygraph-cli Patch
@graphcommerce/hygraph-dynamic-rows Patch
@graphcommerce/hygraph-ui Patch
@graphcommerce/image Patch
@graphcommerce/lingui-next Patch
@graphcommerce/magento-cart-checkout Patch
@graphcommerce/magento-cart-coupon Patch
@graphcommerce/magento-cart-email Patch
@graphcommerce/magento-cart-items Patch
@graphcommerce/magento-cart-payment-method Patch
@graphcommerce/magento-cart-pickup Patch
@graphcommerce/magento-cart-shipping-address Patch
@graphcommerce/magento-cart-shipping-method Patch
@graphcommerce/magento-cart Patch
@graphcommerce/magento-category Patch
@graphcommerce/magento-cms Patch
@graphcommerce/magento-compare Patch
@graphcommerce/magento-customer Patch
@graphcommerce/magento-graphql-rest Patch
@graphcommerce/magento-graphql Patch
@graphcommerce/magento-newsletter Patch
@graphcommerce/magento-payment-adyen Patch
@graphcommerce/magento-payment-afterpay Patch
@graphcommerce/magento-payment-braintree Patch
@graphcommerce/magento-payment-included Patch
@graphcommerce/magento-payment-klarna Patch
@graphcommerce/magento-payment-multisafepay Patch
@graphcommerce/magento-payment-paypal Patch
@graphcommerce/magento-payment-tokens Patch
@graphcommerce/magento-product-bundle Patch
@graphcommerce/magento-product-configurable Patch
@graphcommerce/magento-product-downloadable Patch
@graphcommerce/magento-product-grouped Patch
@graphcommerce/magento-product-simple Patch
@graphcommerce/magento-product-virtual Patch
@graphcommerce/magento-product Patch
@graphcommerce/magento-recently-viewed-products Patch
@graphcommerce/magento-review Patch
@graphcommerce/magento-search-overlay Patch
@graphcommerce/magento-search Patch
@graphcommerce/magento-store Patch
@graphcommerce/magento-wishlist Patch
@graphcommerce/mollie-magento-payment Patch
@graphcommerce/next-ui Patch
@graphcommerce/react-hook-form Patch
@graphcommerce/service-worker Patch
@graphcommerce/storyblok-ui Patch
@graphcommerce/framer-next-pages-example Patch
@graphcommerce/image-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
graphcommerce-246 Ready Ready Preview May 29, 2026 2:03pm
graphcommerce-247 Ready Ready Preview May 29, 2026 2:03pm
graphcommerce-hygraph-dynamic-rows-ui Ready Ready Preview May 29, 2026 2:03pm
graphcommerce-open-source Ready Ready Preview May 29, 2026 2:03pm
graphcommerce-storyblok Ready Ready Preview May 29, 2026 2:03pm

Request Review

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