Skip to content

fix(api): eliminate require("tslib") in Worker bundle#17

Merged
ofcskn merged 2 commits into
mainfrom
development
May 19, 2026
Merged

fix(api): eliminate require("tslib") in Worker bundle#17
ofcskn merged 2 commits into
mainfrom
development

Conversation

@ofcskn

@ofcskn ofcskn commented May 19, 2026

Copy link
Copy Markdown
Owner

The pre-built libs emit require("tslib") via CJS importHelpers. The @nx/esbuild executor doesn't forward custom conditions to esbuild, so it resolved @minimalblock/* to their pre-built dist/ CJS output.

Fix:

  • build-worker.mjs: direct esbuild script with conditions array that includes "@minimalblock/source" — resolves workspace libs to their TypeScript source, bypassing CJS dist output entirely
  • tsconfig.worker.json: importHelpers=false + esnext/bundler module settings so TypeScript emits no tslib references
  • esbuild.worker.mjs: config object (unused by build target, kept as reference for local testing)
  • project.json: build:worker target now runs node build-worker.mjs instead of @nx/esbuild:esbuild executor

Result: zero dynamic require() calls in dist/apps/api/worker.js.

The pre-built libs emit require("tslib") via CJS importHelpers.
The @nx/esbuild executor doesn't forward custom conditions to esbuild,
so it resolved @minimalblock/* to their pre-built dist/ CJS output.

Fix:
- build-worker.mjs: direct esbuild script with conditions array that
  includes "@minimalblock/source" — resolves workspace libs to their
  TypeScript source, bypassing CJS dist output entirely
- tsconfig.worker.json: importHelpers=false + esnext/bundler module
  settings so TypeScript emits no tslib references
- esbuild.worker.mjs: config object (unused by build target, kept as
  reference for local testing)
- project.json: build:worker target now runs node build-worker.mjs
  instead of @nx/esbuild:esbuild executor

Result: zero dynamic require() calls in dist/apps/api/worker.js.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 19, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
minimalblock 4e1aa55 May 19 2026, 02:46 PM

… static IDs

Cloudflare Workers forbid crypto.randomUUID() (via generateId) in global
scope — only inside request handlers. demo-products.ts initialised four
exported constants with generateId() at module level, causing a Worker
validation error (code 10021) on deploy.

Replace all generateId() calls with stable hardcoded ID strings. Demo
data doesn't need random IDs — they're fixtures and should be stable
across builds anyway.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 19, 2026

Copy link
Copy Markdown

Deploying minimalblock with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4e1aa55
Status: ✅  Deploy successful!
Preview URL: https://bc4140a2.minimalblock.pages.dev
Branch Preview URL: https://development.minimalblock.pages.dev

View logs

@ofcskn ofcskn merged commit 4e129b2 into main May 19, 2026
2 of 3 checks passed
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