Skip to content

Fix broken relative .flyde imports after file moves - #295

Open
schwankeith wants to merge 2 commits into
flydelabs:mainfrom
schwankeith:fix-issue-112-20261025
Open

schwankeith wants to merge 2 commits into
flydelabs:mainfrom
schwankeith:fix-issue-112-20261025

Conversation

@schwankeith

Copy link
Copy Markdown

Summary

This change ensures that relative imports inside .flyde files remain valid after the importing file is moved. The import transformer now resolves relative module specifiers to absolute paths based on the source file location, preventing stale relative paths.

Changes Made

  • Updated importToGlobalTransformer to accept an optional fileName and resolve relative import specifiers to absolute paths using Node's path utilities.
  • Modified transpileFile to pass the current file name to the transformer.
  • Added detailed comments and documentation for clarity.

Why

When a .flyde file is moved, its stored relative import paths become incorrect, causing the loader to fail to locate the referenced nodes. By converting these paths to absolute paths at transpile time, the imports stay accurate regardless of file moves.

Testing

The existing unit tests for import handling continue to pass, and the new logic has been exercised manually by moving files and confirming that imports resolve correctly.

Impact

No breaking changes for existing code; the transformer now optionally receives a file name (default behavior unchanged for callers that don’t provide it).

Fixes #112

/claim #112

Prepared with an AI-assisted workflow; happy to adjust anything in review.

This branch has not been deployed

No deployments
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.

Broken imports after moving files

1 participant