Skip to content

Keep relative imports working when a module is flattened - #25

Merged
roble merged 1 commit into
mainfrom
dev
Oct 11, 2026
Merged

roble merged 1 commit into
mainfrom
dev

Conversation

@roble

@roble roble commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

When a module is installed, its framework folder is flattened: resources/js/vue/components/Card.vue becomes resources/js/components/Card.vue. The file moves up one folder, but its imports were left as written. An import of a shared file, such as ../../lib/money or ../../types, then pointed one level too high and the app's build failed.

Found by installing the seven Saucebase modules into a plain Laravel app: Vite reported 9 unresolved imports and the type check 32, across billing, themes, tenancy and others. The contributor checkout never hit it, because modules are not flattened there.

Fix

While flattening, a relative import that leaves the framework folder loses one ../. Imports that stay inside the folder moved with the file and are left alone.

File (inside vue/) Import before Import after
components/Card.vue ../../lib/money ../lib/money
components/Card.vue ../helper ../helper (unchanged)
app.ts ../branding ./branding

It covers from, import() and require() in .vue, .ts, .tsx and .js files. Every relative import in the current modules uses from.

How it was checked

  • New test test_flattening_keeps_relative_imports_pointing_at_shared_files, written first and seen failing. 77 tests pass.
  • A new Laravel app with core and all seven modules now builds, with 0 type errors in app code.

Release note

A patch release (v3.0.1). The @modules/... alias rewrite is unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed relative imports in copied framework files so they continue to resolve correctly after files are moved.

A flattened file sits one folder higher, so an import that reached outside its
framework folder (shared lib/, types) was one ../ too long and the build failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ecad422-c8bd-442b-84b6-40c8d5817882

📥 Commits

Reviewing files that changed from the base of the PR and between 54963a8 and 61e0c60.


📒 Files selected for processing (2)
  • src/Installer.php
  • tests/ModuleInstallerTest.php

 _____________________________________________
< My #FF570A highlighter marks all the TODOs. >
 ---------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@roble
roble merged commit 8cad693 into main Oct 11, 2026
3 of 4 checks passed
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.

1 participant