Skip to content

feat: pass filename to the Babel transform#443

Open
cprecioso wants to merge 1 commit into
unjs:mainfrom
cprecioso:pass-filename
Open

feat: pass filename to the Babel transform#443
cprecioso wants to merge 1 commit into
unjs:mainfrom
cprecioso:pass-filename

Conversation

@cprecioso
Copy link
Copy Markdown

@cprecioso cprecioso commented May 19, 2026

Resolves #442

Passes the file name from the transform options into the filename setting of Babel.
Added a test to check that it's received on the Babel plugin side.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Source file paths are now correctly passed to transformation plugins. Previously, file paths were always omitted during transformations, which could impact error reporting and plugin functionality.
  • Tests

    • Added comprehensive test coverage for source file path handling in transformations to verify that file paths are properly preserved and accessible through the transformation pipeline.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42ba08fe-e209-427d-a7a6-221810d42318

📥 Commits

Reviewing files that changed from the base of the PR and between fd3bb28 and 037309e.

⛔ Files ignored due to path filters (1)
  • test/__snapshots__/fixtures.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • src/babel.ts
  • test/transform-options.test.ts
  • vitest.config.ts

📝 Walkthrough

Walkthrough

The PR enables Babel plugins to identify source files by name during transformation. The Babel transform now forwards the filename from input options instead of always using an empty string, allowing plugins to conditionally enable processing for files matching specific patterns (e.g., *.wasp.ts). A new test verifies the filename correctly reaches Babel plugins throughout the JITI transform pipeline.

Changes

Babel filename forwarding

Layer / File(s) Summary
Babel transform filename option
src/babel.ts
The Babel transform options now set _opts.filename from opts.filename when provided, falling back to an empty string.
Test filename propagation and configuration
test/transform-options.test.ts, vitest.config.ts
New test verifies createJiti passes the source file path to custom Babel plugins via the Program visitor. Vitest config updated to include the new test in the test suite.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A filename passed through Babel's sight,
Plugins now see the path so bright,
Wasp files dance, conditions gleam,
Testing proves the forwarded dream!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: passing the filename parameter to Babel's transform configuration, which is the primary focus of all changes in the pull request.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #442 by passing filename to Babel transform, enabling plugins to make decisions based on file patterns as requested.
Out of Scope Changes check ✅ Passed All changes directly support the core objective: src/babel.ts implements filename passing, test file verifies the feature works, and vitest config enables the test.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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.

Pass filename to the Babel transform

1 participant