feat: add Deno deployment adapter - #194
Conversation
Add @marko/run-adapter-deno for deploying Marko Run apps to Deno and Deno Deploy. - SSR target webworker with the deno export condition; the build produces a self-contained dist/index.js - The entry serves the app via Deno.serve and falls back to serving static assets from dist/public (with immutable caching for /assets and a path traversal guard), listening on the PORT env var - Exposes the request info (remoteAddr) to handlers via DenoPlatformInfo - Adds a run-package test fixture (preview skipped; it needs the Deno CLI)
🦋 Changeset detectedLatest commit: 8282016 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis PR adds a new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/adapters/deno/package.json (1)
23-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueEmpty
testscript.No tests are wired up for this package. Given the README's documented
DenoPlatformInfo/static-serving behaviors, at least minimal unit coverage ofbuildEnd's renaming logic orviteConfig's SSR options would help guard against regressions. Not blocking given the existing fixture-based integration test inpackages/run.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/adapters/deno/package.json` around lines 23 - 26, The package currently has an empty test script, so wire up a real test command in the scripts section and add at least minimal unit coverage for the Deno adapter. Focus on the uniquely named entry points `buildEnd` and `viteConfig`, covering the renaming behavior and SSR/static-serving options described by `DenoPlatformInfo` so regressions are caught even if line numbers shift.packages/adapters/deno/scripts/build.ts (1)
40-44: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
splitting: truehas no effect with a single entry point.Code-splitting only kicks in with multiple entry points or dynamic imports across them; here
entryPointsis just["src/index.ts"], so this flag is currently a no-op. Harmless, but consider removing for clarity unless splitting acrossdefault-entry.ts/index.tsis intended (in which case both would need to be in the sameentryPointsarray).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/adapters/deno/scripts/build.ts` around lines 40 - 44, The build configuration in build() is setting splitting: true even though the entryPoints list only contains a single entry, so the flag is a no-op. Update the build options in the deno build script to remove splitting unless you intend to add multiple entry points such as src/index.ts and default-entry.ts together in the same entryPoints array. Keep the change localized to the build() call so the configuration reflects the actual bundling behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/adapters/deno/src/default-entry.ts`:
- Line 76: The PORT parsing in default-entry should not use a truthy fallback
because Number(Deno.env.get("PORT")) || 3000 treats explicit 0 as missing.
Update the logic in default-entry to preserve a valid 0 value by checking for
NaN instead of using ||, so the existing port selection behavior remains
unchanged for unset or invalid values while allowing PORT=0 to pass through.
In `@packages/adapters/deno/src/index.ts`:
- Around line 1-13: The preview process in denoAdapter() is using shell
wrapping, which can leave the underlying deno child running after close().
Update the process launch in denoAdapter and its preview/close handling to avoid
shell: true by spawning deno directly, or if shell wrapping must stay, change
the termination logic to kill the full process group rather than only the
wrapper process. Use the denoAdapter symbol and the preview process setup to
locate the fix.
---
Nitpick comments:
In `@packages/adapters/deno/package.json`:
- Around line 23-26: The package currently has an empty test script, so wire up
a real test command in the scripts section and add at least minimal unit
coverage for the Deno adapter. Focus on the uniquely named entry points
`buildEnd` and `viteConfig`, covering the renaming behavior and
SSR/static-serving options described by `DenoPlatformInfo` so regressions are
caught even if line numbers shift.
In `@packages/adapters/deno/scripts/build.ts`:
- Around line 40-44: The build configuration in build() is setting splitting:
true even though the entryPoints list only contains a single entry, so the flag
is a no-op. Update the build options in the deno build script to remove
splitting unless you intend to add multiple entry points such as src/index.ts
and default-entry.ts together in the same entryPoints array. Keep the change
localized to the build() call so the configuration reflects the actual bundling
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2483a3f2-8e91-4cc1-96f5-882dbb932f3e
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonand included by**packages/run/src/__tests__/fixtures/deno-adapter/__snapshots__/dev.expected.mdis excluded by!**/__snapshots__/**and included by**
📒 Files selected for processing (18)
.changeset/deno-adapter.mdcspell.jsonpackages/adapters/deno/README.mdpackages/adapters/deno/package.jsonpackages/adapters/deno/scripts/build.tspackages/adapters/deno/scripts/importMetaURL.jspackages/adapters/deno/src/default-entry.tspackages/adapters/deno/src/index.tspackages/adapters/deno/src/types.tspackages/adapters/deno/tsconfig.jsonpackages/run/src/__tests__/fixtures/deno-adapter/.gitignorepackages/run/src/__tests__/fixtures/deno-adapter/.marko-run/routes.d.tspackages/run/src/__tests__/fixtures/deno-adapter/package.jsonpackages/run/src/__tests__/fixtures/deno-adapter/src/components/counter.markopackages/run/src/__tests__/fixtures/deno-adapter/src/routes/+page.markopackages/run/src/__tests__/fixtures/deno-adapter/test.config.tspackages/run/src/__tests__/fixtures/deno-adapter/tsconfig.jsonpackages/run/src/__tests__/fixtures/deno-adapter/vite.config.ts
The runtime's fetch returns a 404 response (not undefined) for unmatched paths, so the entry must fall back to serving static assets on a 404 rather than only when fetch returns nothing. Otherwise requests for static files (eg. /assets/*.js) returned 404 and the client bundle never loaded.
- Add package.toggle.json so publish points exports/types at dist/ - Make the injected import.meta.url shim a string (.href) for the CJS build - Fix the README platform example to read from context.platform - Preserve an explicit PORT=0 (free port) instead of falling back to 3000 - Throw instead of exiting the process when the Deno CLI is missing
Use `shell: true` only on Windows. On POSIX the CLI is spawned directly, so `close()` kills Deno itself instead of an orphaned shell wrapper and argument values are no longer re-parsed by the shell. Also handle the child's error event.
Clarify that Marko Run automatically uses an installed adapter with no Vite config, and move the `npm run build` + deployctl deploy steps to a Deploying section right after installation.
Description
Adds a new adapter package,
@marko/run-adapter-deno, for previewing and deploying Marko Run apps to Deno and Deno Deploy.webworkerwith thedenoexport condition andnoExternal: true, so the build produces a single self-contained server entry atdist/index.js.Deno.serveand, when no route matches, falls back to serving static files fromdist/public— withimmutablecaching for/assets/*, a content-type lookup, and a path-traversal guard. It listens on thePORTenvironment variable (default3000).deno run --allow-net --allow-read --allow-env dist/index.js) and deploys to Deno Deploy by pointing the entrypoint atdist/index.js(e.g.deployctl deploy --entrypoint=dist/index.js).Deno.serverequest info (includingremoteAddr) via the exportedDenoPlatformInfotype.Also adds a test fixture to the
@marko/runpackage (deno-adapter) mirroring the existing adapter fixtures, and a changeset for the new package.Motivation and Context
Deno and Deno Deploy are a natural target for Marko Run since the runtime is built on web standards, but no adapter existed. This provides a zero-config build that runs on the Deno CLI and deploys to Deno Deploy, alongside the existing Node, static, and Netlify adapters.
Screenshots (if appropriate):
Checklist:
Generated by Claude Code