Skip to content

fix: skip CSS files when packaging worker for deploy - #9

Closed
hyfdev wants to merge 1 commit into
mainfrom
fix/skip-css-in-worker-upload
Closed

hyfdev wants to merge 1 commit into
mainfrom
fix/skip-css-in-worker-upload

Conversation

@hyfdev

@hyfdev hyfdev commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Skip .css files when collecting worker modules in packageBuild and packageFrameworkBuild
  • Vite's SSR build extracts CSS into the worker output directory (dist/<worker>/assets/*.css), but these files are only needed on the client side
  • Uploading them as worker modules causes Cloudflare to reject the deploy with SyntaxError: Unexpected token '.' (CSS parsed as JS)

Test plan

  • Deploy a project with CSS imports (e.g. react-notion-x) — should no longer fail with syntax error
  • Verify client-side CSS still loads correctly (CSS is in dist/client/assets/, unaffected)

🤖 Generated with Claude Code

Vite's SSR build extracts CSS files into the worker output directory,
but these are only needed on the client side. Including them in the
worker upload causes Cloudflare to reject the deploy with a
SyntaxError when it tries to parse CSS as JavaScript.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hyfdev hyfdev closed this Mar 1, 2026
@cpojer
cpojer deleted the fix/skip-css-in-worker-upload branch May 7, 2026 07:54
cpojer pushed a commit that referenced this pull request Sep 11, 2026
…host metadata (#132)

P0 prod hotfix. PR #131's cross-script DO host architecture was 100%
broken for sandbox deploys: every user-worker PUT was rejected by CF
with `DURABLE_OBJECT_NOT_CONTAINER_ENABLED`.

Root cause: putSandboxHostScript's metadata omitted the
`containers: [{ class_name: 'Sandbox' }]` declaration. CF requires the
script that OWNS a DO class to declare it as container-enabled — without
that, cross-script DO bindings to that class are rejected.

Fix:
  * Add `containers: [{ class_name: 'Sandbox' }]` to host metadata in
    the base object (applies to both first-create and re-PUT branches
    of the migration_tag protocol). Tells CF the Sandbox class is
    container-backed; the actual container app is still POSTed via the
    /containers/applications API.
  * Hoist `putSandboxHostScript` to run UNCONDITIONALLY at the start of
    `provisionSandboxHost` (after lock + status check, before resource
    lookup). The PUT is idempotent (migration_tag preserves namespace),
    and ensures host-metadata fixes propagate to existing tenants on
    their next deploy. The cached fast path can short-circuit the
    namespace lookup + container POST as before; only the host PUT
    becomes mandatory.
  * Drop redundant putSandboxHostScript call from create-or-recover
    branch.
  * Drop the redundant host-script HEAD check in verifyAndReconcileCached
    (we just PUT it). The live binding probe stays — still validates
    external host delete + recreate.

Mock CF API hardening: helpers.ts now rejects user-worker PUTs that
have a cross-script DO binding (script_name set) when the referenced
host's last-PUT metadata.containers does NOT contain a matching
class_name. Mirrors CF's actual validation; would have caught this
regression in tests had it been in place. CF-shaped error envelope
with code 10103 and the literal `DURABLE_OBJECT_NOT_CONTAINER_ENABLED`
message.

Tests:
  * Unit #2/#3: assert ONE host PUT (was zero), body OMITS migrations
    (tag preserved), INCLUDES containers signal.
  * Unit #4 retitled — with always-PUT, cached fast path now succeeds.
  * Unit #9/#10/#10b: assert containers signal present in BOTH
    migration_tag branches.
  * Integration #2/#3: assert ONE host PUT per redeploy, no namespace
    rotation, no container POST/DELETE/PATCH on unchanged-config redeploys.
  * Integration #12: seedHostScript now includes containers metadata so
    the success-path sanity check survives the new mock validation.

Verification: pnpm check / lint / fmt --check all clean.
Unit sandbox-host: 20/20. Integration api-sandbox: 11/11 + 1 skipped.
api-deploy + api-delete: 169/169 unchanged.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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