fix(cli): propagate resolve hook to the alchemy converge child - #244
Draft
kristof-siket wants to merge 2 commits into
Draft
fix(cli): propagate resolve hook to the alchemy converge child#244kristof-siket wants to merge 2 commits into
kristof-siket wants to merge 2 commits into
Conversation
The resolve hook registered by `entry-resolution.ts` only applied inside the CLI's own process. When `run-alchemy.ts` spawns the alchemy converge child (a separate Node process), the child had no hook, so `.js`-extension imports inside the user's entry graph failed with ERR_MODULE_NOT_FOUND. Fix: ship `register-entry-resolution.ts` as a standalone dist entry (`dist/register-entry-resolution.mjs`) in both `@internal/cli` and `@prisma/composer-cli`. Inject it into the converge child via `NODE_OPTIONS=--import=<file:// URL>` in the spawn env, appending to any existing `NODE_OPTIONS` value. Under Bun the env addition is skipped — Bun resolves `.js` → `.ts` natively without a hook. Closes: repro at https://github.com/kristof-siket/next-stock/actions/runs/32148447586 Signed-off-by: Kristof Siket <siket@prisma.io>
…ge child Signed-off-by: Kristof Siket <siket@prisma.io>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
kristof-siket
added a commit
to kristof-siket/next-stock
that referenced
this pull request
Aug 18, 2026
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.
What broke and why
When
prisma-composer deployruns under Node, the CLI registers a synchronous resolve hook (node:moduleregisterHooks) so that.js-extension and extensionless specifiers resolve to.tssource files. That hook applies only to the CLI's own process.run-alchemy.tsthen spawns the workspace's installedalchemybin as a separate Node child process. That child has no hook, so imports like:fail with
ERR_MODULE_NOT_FOUNDinside the generatedalchemy.run.tsstack file.Repro: https://github.com/kristof-siket/next-stock/actions/runs/32148447586
Fix
Build
src/register-entry-resolution.tsas a standalone entry (dist/register-entry-resolution.mjs) in both@internal/cliand@prisma/composer-cli. The module's only job is to callregisterEntryResolution()at import time.Pass it to the converge child via
NODE_OPTIONS=--import=<file:// URL>in the spawn environment, appending to any existingNODE_OPTIONSvalue. Under Bun the env addition is skipped — Bun resolves.js→.tsnatively.The URL is derived from
import.meta.urlof the running bundle, so it resolves to the correct file whether the CLI is run from@internal/cli/dist/or@prisma/composer-cli/dist/.Tests added
childNodeOptions()unit tests — exercise the Node path (noNODE_OPTIONS, existingNODE_OPTIONSpreserved) and the Bun path (returnsundefined), using the explicitisBunRuntimeparameter so the suite works regardless of which runtime runs it.node --import=<register module> <driver>where the driver dynamically imports a fixture that uses./js-ext-service.js(only.tsexists). Asserts exit 0. A paired test without--importasserts exit 1 with the module-not-found error, confirming the hook is what makes it work.Checklist
pnpm --filter @internal/cli typecheck— cleanpnpm --filter @internal/cli test— 251 passpnpm --filter @internal/cli build— producesdist/register-entry-resolution.mjspnpm --filter @prisma/composer-cli build— producesdist/register-entry-resolution.mjspnpm lint— no errors