fix(functions): include shared modules reachable via parent-escape imports#563
Draft
guyofeck wants to merge 1 commit into
Draft
fix(functions): include shared modules reachable via parent-escape imports#563guyofeck wants to merge 1 commit into
guyofeck wants to merge 1 commit into
Conversation
…ports Functions that import shared utilities via ../../shared/... were only uploading files inside their own subfolder; the server bundler would reject the missing imports at deploy time. Walk the import graph from each function's file set and collect any additional files inside base44/ (backendRoot) that are reachable via relative specifiers but outside the function directory. The new files are appended to filePaths before deploy — loadFunctionCode's existing relative(functionDir, filePath) then produces the correct ../../shared/… paths in the payload. Closes #562 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Note
Description
When a Base44 function imports a shared module that lives outside its own directory (e.g.
../../shared/response.ts), that file was previously not collected and therefore not deployed, breaking the function at runtime. This PR walks the relative-import graph starting from each function's files and includes any additional modules reachable inside the backend root, ensuring shared code is bundled and deployed alongside the functions that depend on it.Related Issue
None
Type of Change
Changes Made
packages/cli/src/core/resources/function/reachability.tswithcollectReachableBackendFiles(), which BFS-walks relative imports (static/dynamicimport,export ... from, andrequire) from a function's files and returns extra modules that live inside the backend root but outside the function directory..js/ship-.tsconvention, extensionless specifiers, andindex.{ts,js}directory imports; imports that escape the backend root are ignored.readFunction()and the config-less function path inreadAllFunctions()(config.ts) to merge these reachable files into each function'sfilePaths(deduped), passing a computedbackendRoot.function-shared-importsfixture (two functions sharingshared/response.ts) verifying the shared file is included and that its relative path is preserved for deploy.Testing
Checklist
Additional Notes
The traversal is confined to `backendRoot` so imports pointing outside the project are safely skipped, and results are deduped against the function's own files to avoid duplicate paths.
🤖 Generated by Claude | 2026-07-09 14:20 UTC | 27b0341