Repository navigation
Conversation
`sourceMap: true` on `bundle`/`bundleApp` returns `map` beside `module`: an esbuild map of the final compile (not the per-function probes) with no sourcesContent and no sourceRoot. The module keeps the trailing `//# sourceMappingURL=_bundled.mjs.map` comment Cloudflare reads to remap stack traces, and otherwise matches the option-off build byte for byte. The map's sources name the request's files: per-app `fn_<index>/` is stripped and checked against that function's files, and a function's entry becomes its optional `entryPath` (its real stored path). Every other source stays in place, so the mappings' indices hold, behind a `base44-internal:` prefix. Off by default; the public CLI never sets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e_map Cloudflare remaps only the stacks of uncaught exceptions it captures; a stack the Worker logs itself (the per-app entry's console.error before rethrowing, or user logs) stays minified. Run a throwing function in workerd with a Tail Worker, for both entries, and map the exception's frames back to the app's files by hand — local workerd does no remapping — and pin that the logged per-app crash line stays minified. Say in the README what is remapped automatically and what a consumer must remap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.2.2-pr.677.e0cc2a5Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.2.2-pr.677.e0cc2a5"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.2.2-pr.677.e0cc2a5"
}
}
Preview published to npm registry — try new features instantly! |
DescriptionAdds an opt-in external source map to The option defaults to off, and the public
Request and response changes
Successful response with the option on: { "ok": true, "module": "…\n//# sourceMappingURL=_bundled.mjs.map\n", "source_map": "{\"version\":3,\"sources\":[…],\"mappings\":\"…\",\"names\":[…]}", "main_module": "_bundled.mjs", … }What gets remapped, and by whom
Changes
Not touched: the generated entries, the crash path, response headers, actor entries (an actor request with Evidence that output with the option off is unchanged
Tests
Size and timeLargest fixtures in the repo, on an Apple-silicon laptop with a warm dependency cache:
The per-app timing is noisy on a laptop. Treat it as "up to about 2× on a very large app" until Base44 measures real apps from S3. Notes for review
🤖 Generated with Claude Code |
Note
Description
Adds an opt-in
sourceMapflag to@base44/functions-compiler's/v1/bundleand/v1/bundle-apprequests. When set, the compiler returns an external source map (source_map) besidemodule, with itssourcesrewritten so a minified stack frame maps back to the file a user actually wrote. It is off by default and the public CLI never sets it — with it off the output is unchanged, so this is purely additive for existing callers. Only Base44's bundler service turns it on, so Cloudflare can remap uncaught-exception stacks in Tail Worker events and consumers can remap logged stacks themselves.Related Issue
None
Type of Change
Changes Made
src/source-map.ts: rewrites esbuild'ssourceslist. Auser:<key>source that is one of the request's own files becomes that file's path; in a per-app bundle thefn_<index>/prefix is stripped and the path is validated against that function's files (viaObject.hasOwn, so inherited keys likeconstructorcan't masquerade as app files). Everything else — the shim, generated entry/wrappers, virtual runtime modules, npm and remote modules — stays in the list (the mappings index into it) behind abase44-internal:prefix.sourceRootandsourcesContentare stripped.entryPathin the request contracts: optional per-function field (bundleRequestSchema,appFunctionSchema) carrying a function's real stored path for a function submitted asmain.ts. Only the source map reads it; compilation still usesentry.sourceMapin the request contracts andsource_map?: stringonBundleResponse/BundleAppResponse.deno-bundle.ts: emitssourcemap: "linked"withsourcesContent: falseandoutfile: MAIN_MODULEwhen asked — "linked" rather than "external" so the trailing//# sourceMappingURL=_bundled.mjs.mapcomment Cloudflare reads is kept. Output-file validation now expects exactly a module plus its map in map mode.NORMALIZED_MAIN_MODULEmoved here and exported asMAIN_MODULE, since the map's filename derives from it.bundler.ts: the per-app build flags are threaded as oneAppBuildobject (telemetry,runtimeSecrets,sourceMap) instead of positional booleans, replacing severalcompileApp(entries, telemetry, runtimeSecrets)call sites. The per-app map is built from a sparsefunctionsarray indexed byfn_<index>, so original positions survive the exclude-and-rebuild path. Per-function attribution probes skip the map (their module is discarded), as they already skip telemetry.test/source-map.test.ts(unit — source-index stability,entryPathsubstitution, unknown/missing function slots,sourceRoot/sourcesContentremoval) andtest/source-map.e2e.test.ts(real builds: off-by-default parity, app-file naming, generated→original position mapping, workerd execution, pinned-sources snapshots, and a Miniflare Tail Worker crash whoseexceptionsstack and self-logged stack are both remapped by hand throughsource_map).base44-internal:convention, and the caveats (local workerd does no remapping; two functions in one bundle can both listmain.ts, so frame→function attribution comes from the log line).Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
Scoped entirely to
packages/functions-compiler— no CLI-side changes, and no package version bump is included here. The feature is inert unless a caller passessourceMap: true; actor entries andcompileFunctionShardsnever ask for one. Cloudflare's own remapping of Tail Worker exception stacks can only be confirmed against a deployed Worker — the e2e test proves the positions workerd reports line up with the emitted map, which is as far as a local check goes.🤖 Generated by Claude | 2026-10-23 15:08 UTC | e0cc2a5