Skip to content

Serve apps/effect to hosted app Workers - #2620

Open
kristojorg wants to merge 1 commit into
UsefulSoftwareCo:v2from
kristojorg:serve-apps-effect-in-workers
Open

kristojorg wants to merge 1 commit into
UsefulSoftwareCo:v2from
kristojorg:serve-apps-effect-in-workers

Conversation

@kristojorg

Copy link
Copy Markdown

An app that imports wrap from apps/effect, to use an Effect Schema as a tool's input, deploys on Cloud but fails when its Worker starts:

No such module "apps/effect"

compileWorkerApp marks every apps/* import external. It then provides a module only for each name in frameworkExports, and the framework's server runtime (runtime.json) holds only serverEntries. apps/effect was in neither list, so it only shipped to browser bundles. This adds it to both. bun run apps:protocols reports no host protocol change.

app-worker-modules.spec.ts now also deploys an app whose greet input is wrap(Schema.Struct({ name: Schema.String }), false) and calls it cold.

I couldn't run the Cloud target here: the stack runs out of memory under the 6 GB limit on my machine. Instead, I compiled that app with compileWorkerApp (the built apps dist as host.apps) and loaded the reachable modules in workerd through Miniflare:

  • v2: apps/effect is not in the bundle, and workerd fails with No such module ".../apps/effect".
  • This branch: the bundle has apps/effect, and the Worker loads.

bun run e2e:check and oxfmt --check pass. This changes packages/apps. If its release needs a version bump, I'll add it, or you can bump it when you port this.

app-worker-modules.spec.ts

The app bundler marks every apps/* import external and then provides a
module only for each entry in frameworkExports. apps/effect was not in
that list or in the framework's server runtime, so an app that imports
wrap from apps/effect deployed but failed when its Worker loaded:
No such module "apps/effect".

Release-note: Fix: Apps can import apps/effect, so a tool's input can be an Effect Schema passed through wrap.
Amp-Thread-ID: https://ampcode.com/threads/T-b202b012-54e3-4a0a-8c9e-3b9a240ce4f1
Co-authored-by: Kristo Jorgenson <[email protected]>

This branch has not been deployed

No deployments
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