fix(json-provider): resolve DUMP_DIR when Turbopack strips import.met…#374
Merged
Conversation
…a.dirname `import.meta.dirname` is undefined in workspace-package code that Next.js 16 + Turbopack bundles into server chunks, so the `resolve(import.meta.dirname, '..')` in getStore() threw ERR_INVALID_ARG_TYPE on every API route that touched the JSON dump path (Option A in the README). Pages rendered but every /api/v1/* call 500'd. `import.meta.url` is preserved correctly by Turbopack and still points at the original source file, so fall back to `dirname(fileURLToPath(import.meta.url))` when `import.meta.dirname` is unavailable. Behavior is identical for tsx, plain Node ESM, and vitest, where `import.meta.dirname` is defined and the ?? short- circuits. No production impact: Vercel uses DATABASE_READONLY_URL, never DUMP_DIR, so getStore() is unreachable in prod. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @arygupt's task in 1m 2s —— View job 🟢 LGTM — no blocking issues foundThe fix is correct, minimal, and well-scoped. What I verified:
No test is needed here: this is an environment-detection workaround for a bundler quirk, and it's only exercised in the local Option-A dev path that has no automated coverage today. Todos
|
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.
fix(json-provider): resolve DUMP_DIR when Turbopack strips import.meta.dirname
Bundler removing variable that defines where dump folder lives
import.meta.dirnameis undefined in workspace-package code that Next.js 16 + Turbopack bundles into server chunks, so theresolve(import.meta.dirname, '..')in getStore() threw ERR_INVALID_ARG_TYPE on every API route that touched the JSON dump path (Option A in the README). Pages rendered but every /api/v1/* call 500'd.import.meta.urlis preserved correctly by Turbopack and still points at the original source file, so fall back todirname(fileURLToPath(import.meta.url))whenimport.meta.dirnameis unavailable. Behavior is identical for tsx, plain Node ESM, and vitest, whereimport.meta.dirnameis defined and the ?? short- circuits.No production impact: Vercel uses DATABASE_READONLY_URL, never DUMP_DIR, so getStore() is unreachable in prod.