मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)5.4k · #14846

cloudflare-bundler-apps

यह क्या करती है

यह स्किल एजेंट को प्रोजेक्ट का ढाँचा ऐसा बनाना सिखाती है कि Cloudflare worker bundler उसे साफ़ तरीके से बना सके। इसमें wrangler कॉन्फ़िग, फ़ोल्डर लेआउट, स्टैटिक फ़ाइलें और सर्वर एंट्री पॉइंट शामिल हैं।

कब इस्तेमाल करें

  • ✓जब कोई डेवलपर ऐसा प्रोजेक्ट बनाता या बदलता है जो Cloudflare worker bundler से बनेगा।
  • ✓जब किसी Cloudflare प्रोजेक्ट के प्रीव्यू में खाली पेज या बिल्ड फ़ेल दिखे।
  • ✓जब किसी प्रोजेक्ट को सर्वर एंट्री पॉइंट के साथ स्टैटिक असेट भी परोसने हों।

Skill का लिंक

https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरा Cloudflare प्रोजेक्ट इस तरह सेट कीजिए कि bundler उसे बनाए और प्रीव्यू बिना गलती के पेज दिखाए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट मुख्य एंट्री, कंपैटिबिलिटी सेटिंग्स और असेट फ़ोल्डर के लिए wrangler कॉन्फ़िग पढ़ता है, फिर प्रोजेक्ट को bundler के नियमों के अनुसार लगाता है। वह डिपेंडेंसी सीमाएँ और खाली पेज की आम गलतियाँ जाँचता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

This skill teaches how to build apps that deploy cleanly through the space deploy pipeline. Every project committed to a space is built by @cloudflare/worker-bundler (createApp when there are static assets, createWorker when there are none) and served on a Dynamic Worker via WorkerLoader. Get the conventions right and the preview "just works". Get them wrong and you get a blank page, a 500, or a Build failed error.

How the pipeline works

When deploy_space(branch) is called, the space DO:

  1. Reads every file from the branch's working tree (skipping .git/).
  2. Parses wrangler.json / wrangler.jsonc / wrangler.toml for main, compatibility_date, compatibility_flags, and [assets].
  3. If [assets].directory is set, files under that directory become static assets served host-side by handleAssetRequest. Everything else is built into a Worker via createApp (with server: <main>).
  4. If no assets directory is configured, only createWorker({ entryPoint: <main> }) is run. The output is loaded as a Dynamic Worker; all requests go to the Worker.
  5. Previews are served at /space/:name/preview/:branch/*. Responses with content-type: text/html are run through HTMLRewriter, which prefixes root-relative src / href / action attributes with the preview base path. JS-side fetches and dynamic imports are NOT rewritten.

Practical consequences:

  • You can rely on root-relative src="/foo.js" and href="/style.css" in HTML. They will be rewritten to the preview path automatically.
  • You cannot rely on root-relative paths inside JS strings: fetch("/api/x"), new URL("/foo", location.origin), dynamic import("/lib.js"). These hit the wrong path under the preview prefix. Use relative paths (./api/x, import.meta.url) or read the base path from <base href> / a meta tag injected at build time.
  • The <base href> tag is also rewritten if present — using it lets all relative URLs resolve against the preview path.

Project layout

A typical full-stack space project:

/
├── wrangler.json          # required for non-trivial setups
├── package.json           # npm deps (text-only packages, see limits below)
├── src/
│   └── index.ts           # server entry: export default { fetch }
└── public/                # static assets directory (configurable)
    ├── index.html
    ├── app.js             # compiled, no JSX
    └── styles.css

A static-only SPA can skip src/ entirely — just wrangler.json + public/ is enough as long as main points to a minimal pass-through worker or you accept that all requests fall through assets.

Wrangler config

Minimum viable wrangler.json:

{
  "main": "src/index.ts",
  "compatibility_date": "2025-04-01",
  "assets": {
    "directory": "./public",
    "html_handling": "auto-trailing-slash",
    "not_found_handling": "single-page-application"
  }
}

Notes:

  • main is required when there's any server code. The bundler also auto-detects src/index.ts, src/index.js, index.ts, index.js if missing.
  • compatibility_date defaults to 2025-04-01 if omitted. Set it explicitly for newer features.
  • Add "compatibility_flags": ["nodejs_compat"] only if you actually need Node built-ins.
  • assets.directory is the only way to ship static files. Files outside this directory are bundled into the Worker or ignored — they will not be reachable via URL.
  • html_handling: "auto-trailing-slash" is usually what you want for multi-page sites; SPAs should also set not_found_handling: "single-page-application" so deep links return index.html.

TOML works too (wrangler.toml), but the parser only handles top-level scalar fields plus an [assets] table — no inline tables, no env overrides. Prefer JSON.

Server entry: one Durable Object class named App

Your entire backend is one Durable Object. Your main module exports a class named App extending DurableObject. The platform loads it as a Cloudflare Durable Object Facet of the host SpaceDO and forwards every non-asset request — including WebSocket upgrades — to your App.fetch(request).

Do not export default { fetch }. A default fetch handler will be ignored. There is no separate worker; the DO is the worker.

// src/index.ts
import { DurableObject } from "cloudflare:workers";

export class App extends DurableObject {
  async fetch(request: Request): Promi
अक्सर पूछे जाने वाले सवाल

खाली प्रीव्यू का कारण क्या होता है?

स्किल कॉन्फ़िग और लेआउट की उन गलतियों को सूचीबद्ध करती है जिनसे खाली पेज या बिल्ड फ़ेल होते हैं।

क्या ब्राउज़र के अनुरोध फिर से लिखे जाते हैं?

स्किल कहती है कि प्रीव्यू पथ के लिए HTML एट्रिब्यूट फिर से लिखे जाते हैं, लेकिन JavaScript के fetch और import नहीं।

यह कौन-सी कॉन्फ़िग फ़ाइलें पढ़ती है?

यह wrangler.json, wrangler.jsonc या wrangler.toml पढ़ती है।

जानकारी

लेखक का मूल विवरण

Author Cloudflare Worker Bundler-compatible apps that build and preview correctly inside a space. Use this skill whenever you scaffold, modify, or deploy a project that will be built with `@cloudflare/worker-bundler` (i.e. anything served from `/space/:name/preview/:branch/`). Covers wrangler config, project layout, static asset rules, server entry conventions, npm dependency limits, and the most common cause of blank previews (JSX in browser scripts).

repo: cloudflare/vibesdk

लोकप्रियता

GitHub स्टार
5.4k
रैंकिंग में स्थान
#14846
लाइसेंस
MIT
अपडेट की गई
21/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills