Skip to content

Backend functions: include reachable shared modules in deploy payload (CFW multi-file) #562

Description

@guyofeck

Context

base44-dev/apper PR #15137 adds CFW multi-file backend functions: a function may import a within-function helper (./util.ts) or a cross-function shared module (../../shared/x.ts). The CFW bundler compiles each function independently and resolves relative imports only within that function's submitted files set.

On the backend, the interactive deploy paths (editor save, single-function PUT, file-tree deploy) expand these server-side — they gather each function's reachable files before bundling. The batch full-sync endpoint (POST /backend-functions, used by base44 deploy) intentionally does not expand server-side: it deploys each function's files exactly as submitted (it stays the full-sync endpoint — it also prunes functions/automations removed from the payload, so it should keep being used; no new/special endpoint is needed).

Problem

If the CLI submits only each function's entry (flat main.ts / entry-only files), a function that imports ../../shared/x.ts (or ./util.ts) deploys without the shared module. The bundler then fails with the historical "...can't reach outside the function" error, or ships stale code.

Action

When deploying backend functions, the CLI should include each function's reachable backend files in that function's files payload:

  • within-function helpers under base44/functions/<name>/…
  • cross-function shared modules reachable via ./ / ../ imports (base44/shared/*.ts, and any other reachable base44/… file), resolved transitively

so the server-side bundler resolves the relative imports within the submitted files. Resolution is exact-posix-match on the real project paths (e.g. ../../shared/x.ts from base44/functions/foo/entry.tsbase44/shared/x.ts).

Only base44/ code is bundleable — src/ (frontend) and root files (package.json, tailwind.config.js, index.html) must stay excluded (an escape into them should not resolve).

Notes

  • Keep using the batch full-sync endpoint; this is a payload change (include reachable files), not an endpoint change.
  • Managed builder apps are already covered server-side (they deploy through the file-tree path, which expands). This is specifically about CLI / Backend-Platform (unmanaged) deploys, where the CLI payload is the source of truth.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions