fix(api): eliminate require("tslib") in Worker bundle#17
Merged
Conversation
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>
Deploying with
|
| 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>
Deploying minimalblock with
|
| Latest commit: |
4e1aa55
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bc4140a2.minimalblock.pages.dev |
| Branch Preview URL: | https://development.minimalblock.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Result: zero dynamic require() calls in dist/apps/api/worker.js.