Fix/config fixes#2636
Open
bramvanderholst wants to merge 3 commits into
Open
Conversation
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 detectedLatest commit: a16bbe5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 86 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 SWCWhen loading
graphcommerce.config.ts, cosmiconfig's built-in sync TypeScriptloader transpiles to a fixed
.cjspath on disk and removes it in afinallyblock. Under Turbopack (which spawns worker processes that load the config
concurrently), one process deletes the file while another is still trying to
requireit — producing panics likeCannot find module …graphcommerce.config.cjs.The
.tsloader now transpiles via SWC (already a dependency) and writes to aper-process unique filename next to the source —
.graphcommerce.tmp.<pid>-<counter>.cjs— so concurrent workers can nevercollide.
loadConfigstays synchronous; no callsite changes(
withGraphCommerce, CLI commands, mesh, hygraph-cli).fix(gql-codegen): codegen no longer stops halfwaygc-gql-codegenwould silently stop mid-run — TTY detection in graphql-codegen'sCLI suppressed spinner output and set a wrong exit code.
Piping the command through
catforces a non-TTY pipe so codegenruns to completion with correct exit semantics.