Skip to content

fix: preserve transform sourcemaps for webpack and rspack - #615

Open
SyMind wants to merge 1 commit into
unjs:mainfrom
SyMind:fix/webpack-rspack-transform-sourcemaps
Open

SyMind wants to merge 1 commit into
unjs:mainfrom
SyMind:fix/webpack-rspack-transform-sourcemaps

Conversation

@SyMind

@SyMind SyMind commented Aug 26, 2026

Copy link
Copy Markdown

Fixes #616

Summary

  • preserve transform sourcemaps when no input sourcemap is provided to the loader
  • combine transformed and upstream sourcemaps for Webpack and Rspack instead of dropping either mapping layer
  • add regression coverage for sourcemap passthrough and composition in both adapters

Tests

  • pnpm test
  • pnpm typecheck
  • pnpm lint
  • pnpm build

Summary by CodeRabbit

  • Bug Fixes
    • Improved source-map handling for Webpack and Rspack transformations.
    • Preserved transformed or incoming source maps when only one is available.
    • Correctly combines source maps when both transformed and incoming maps exist.
  • Tests
    • Added coverage for transformed source maps and combined source-map output.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f9763ce4-099e-4ed1-8906-5c6120ab7deb

📥 Commits

Reviewing files that changed from the base of the PR and between 48b18ba and 512e90d.

📒 Files selected for processing (4)
  • src/rspack/loaders/transform.ts
  • src/webpack/loaders/transform.ts
  • test/unit-tests/rspack/loaders/transform.test.ts
  • test/unit-tests/webpack/loaders/transform.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Both transform loaders now compose returned and incoming source maps. Tests cover direct forwarding, composition, and native build-context callbacks.

Changes

Transform source map handling

Layer / File(s) Summary
Compose transform and incoming maps
src/rspack/loaders/transform.ts, src/webpack/loaders/transform.ts
Both loaders use @jridgewell/remapping when both maps exist. Each loader forwards the available map when only one exists.
Validate source map results
test/unit-tests/rspack/loaders/transform.test.ts, test/unit-tests/webpack/loaders/transform.test.ts
Tests add source-map fixtures and verify direct forwarding, composed mappings, and native build-context callback results.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 512e9

The PR preserves and composes transform sourcemaps for Webpack and Rspack without any supplied merge-blocking concern; no actionable risk remains beyond normal checks and review.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving transform source maps for both Webpack and Rspack adapters.
  • Fix all pre-merge checks with AI
✨ 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.

@sxzz

sxzz commented Aug 31, 2026

Copy link
Copy Markdown
Member

Please send an issue first.

@SyMind

SyMind commented Aug 31, 2026

Copy link
Copy Markdown
Author

Created #616 with a runnable Rspack reproduction: https://github.com/SyMind/unplugin-rspack-sourcemap-repro

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.

webpack/rspack: transform hook sourcemaps are dropped or not composed

2 participants