Skip to content

Feat/cloudflare workers - #3

Open
ri0n-dev wants to merge 11 commits into
mainfrom
feat/cloudflare-workers
Open

ri0n-dev wants to merge 11 commits into
mainfrom
feat/cloudflare-workers

Conversation

@ri0n-dev

@ri0n-dev ri0n-dev commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

This PR adds support for Cloudflare Workers.

Copilot AI lite review requested due to automatic review settings September 3, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A confirmed path traversal issue exists in getRegistryAsset() (unsandboxed filesystem read), and the registry redirect path drops caching/robots headers, impacting security and operational behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds a Vite/Vinext + Wrangler-based deployment path to run the UI on Cloudflare Workers, replacing runtime filesystem access (for Workers-incompatible routes) with build-time import.meta.glob() inlined sources/assets.

Changes:

  • Add Cloudflare Workers configuration (wrangler.jsonc) and Vinext/Vite build setup (vite.config.ts) with runtime aliasing to Workers-safe “.vite.ts” modules.
  • Replace runtime filesystem reads for docs/blog/registry flows with build-time globbed content and asset URL redirects where needed.
  • Adjust MDX configuration to use explicit remark plugin imports and add Vinext/Wrangler scripts + dependencies.
File summaries
File Description
wrangler.jsonc Adds Wrangler configuration for Workers deployment (assets, cache, KV, images).
vite.config.ts Introduces Vinext + Cloudflare Vite plugin config and pre-resolve aliasing for Workers-safe modules.
package.json Adds Vinext/Cloudflare/Wrangler tooling, scripts, and ESM package type.
next.config.ts Updates MDX remark plugins to imported plugin functions (not string names).
lib/registry-source.vite.ts Build-time globbing for registry source/** content and asset URLs.
lib/registry-loader.vite.ts Workers-safe replacement for shadcn/registry backed by local registry.json + globbed sources.
lib/registry-asset.vite.ts Workers-safe registry asset resolver returning emitted asset URLs (no raw byte reads).
lib/registry-asset.ts Node runtime registry asset reader returning Uint8Array bodies.
lib/read-code-path.vite.ts Workers-safe code browser implementation using globbed sources instead of filesystem walking.
lib/docs-runtime.vite.ts Workers-safe docs enumerator using globbed MDX sources + compiled components.
lib/docs-runtime.ts Node runtime docs enumerator using explicit imports + filesystem reads for sources.
lib/content.ts Shifts docs content enumeration/reads to getDocAssets() instead of filesystem traversal.
lib/blog.ts Shifts blog post enumeration/reads to getBlogSourceEntries() instead of filesystem access.
lib/blog-sources.vite.ts Workers-safe blog source/component resolution via build-time globbing.
lib/blog-sources.ts Node runtime blog source reads and dynamic component import.
app/(main)/registry/[...path]/route.ts Serves registry assets via getRegistryAsset() with redirect for emitted asset URLs.
app/(main)/docs/[slug]/page.tsx Loads docs from getDocAsset() and injects MDX components mapping explicitly.
app/(main)/blog/[slug]/page.tsx Loads blog components via getBlogPostComponent() and injects MDX components mapping.
app/(api)/docs-md/[...slug]/route.ts Serves MDX source for docs via getDocAsset() rather than filesystem reads.
.gitignore Ignores Vinext/Wrangler build output directories (dist, .vinext, .wrangler).
Review details
  • Files reviewed: 19/21 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/registry-asset.ts
Comment thread app/(main)/registry/[...path]/route.ts
ri0n-dev and others added 2 commits September 4, 2026 00:10
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ri0n-dev

ri0n-dev commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

On hold for now, as it is currently deployed on Render.

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.

2 participants