fix: re-enable CLI bundle by routing import.meta through package name#141
Open
Mkassabov wants to merge 2 commits into
Open
fix: re-enable CLI bundle by routing import.meta through package name#141Mkassabov wants to merge 2 commits into
Mkassabov wants to merge 2 commits into
Conversation
PR #135 disabled the bin/alchemy.ts tsdown bundle because relative import.meta.* references inside the CLI's import graph misresolve once the modules are inlined into bin/alchemy.js (they end up pointing at the bundle, not the original source file). Apply the PR #128 pattern (import.meta.resolve("alchemy/...") + matching exports entries) to the two real offenders pulled into the CLI bundle, then re-enable the tsdown config so react/ink/pathe stay out of runtime dependencies: - Cloudflare/Local/Sidecar.ts: package-name-resolve SidecarServer.ts instead of "./SidecarServer.ts" relative to import.meta.url - Cloudflare/StateStore/Api.ts: package-name-resolve Api.ts instead of import.meta.filename (the bundled value would be bin/alchemy.js, which has no default export and breaks the worker bundler) - package.json: export the two newly-referenced source paths - tsdown.config.ts: uncomment bin/alchemy.ts entry, with a comment documenting the import.meta constraint for future bundle additions
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/6416d6d@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/6416d6d@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/6416d6d |
Contributor
Website Preview DeployedURL: https://alchemyeffectwebsite-worker-pr-141-l2o7tfwuhibm4spw.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
sam-goodwin
reviewed
May 1, 2026
Comment on lines
247
to
-249
| "./bin/alchemy.js": "./bin/alchemy.js", | ||
| "./bin/exec.ts": "./bin/exec.ts", | ||
| "./bin/exec.js": "./bin/exec.js" |
Contributor
There was a problem hiding this comment.
why do we export these?
Api.ts is itself a Cloudflare Worker — the same module that holds the `main: ...` config gets shipped as the worker after deploy. The previous top-level `import.meta.resolve(...)` call evaluated in the Workers runtime too, where `resolve` isn't a function, throwing `(intermediate value).resolve is not a function` at script startup. Guard the call with `typeof import.meta.resolve === "function"` and fall back to `import.meta.filename` in Workers (the value is unused there — the worker bundler already consumed `main` at deploy time).
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.
#135 disabled the
bin/alchemy.tstsdown bundle because relativeimport.meta.*references inside the CLI's import graph misresolve once inlined intobin/alchemy.js— they point at the bundle, not the original source file.This applies the #128 pattern (
import.meta.resolve("alchemy/...")+ matchingexportsentries) to the two real offenders, then re-enables the tsdown config so react/ink/pathe stay out of consumer-visible runtime deps.Cloudflare/Local/Sidecar.ts— package-name resolveSidecarServer.tsinstead of./SidecarServer.ts.Cloudflare/StateStore/Api.ts— package-name resolveApi.tsinstead ofimport.meta.filename. The bundled value isbin/alchemy.js, which has nodefaultexport and breaks the worker bundler with[MISSING_EXPORT] "default" is not exported by "bin/alchemy.js".package.json— export./Cloudflare/Local/SidecarServer.tsand./Cloudflare/StateStore/Api.ts.tsdown.config.ts— uncommentbin/alchemy.tsentry; document theimport.metaconstraint inline.Agent/util/parser.tsalso usesimport.meta.urlbut isn't in the CLI bundle's import graph (only reached viaBundle/Docker.ts), so it's left alone.