GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(unplugin): emit column-accurate sourcemaps by official-burak · Pull Request #563 · unjs/unimport

Conversation

@official-burak

@official-burak official-burak commented Aug 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

unplugin's transform called MagicString#generateMap() with no options, so the map had one mapping per line (all at column 0) and sources: [""]. Auto-imports are prepended, so line numbers still roughly line up, but V8 coverage (@vitest/coverage-v8) drops any module that references an auto-imported global and reports 100% (0/0).

Pass { hires: 'boundary', source: id }. hires: 'boundary' matched hires: true for coverage in the report while producing a smaller map.

Fixes #562

Test plan

  • test/unplugin.test.ts: injected import is present, map.sources is the module id, and mappings have more than one segment on at least one line
  • Unchanged files still skip the transform
  • pnpm vitest run (237 tests)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@official-burak
fix(unplugin): emit column-accurate sourcemaps
57f3bb3
Bare generateMap() collapses every mapping to column 0, so V8 coverage
drops modules that use auto-imports. Pass hires: 'boundary' and source.
@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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: 12ff6256-30d6-4dde-9ccf-941a6eb443f3

📥 Commits

Reviewing files that changed from the base of the PR and between a86212a and 57f3bb3.

📒 Files selected for processing (2)
  • src/unplugin.ts
  • test/unplugin.test.ts

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


📝 Walkthrough

Walkthrough

The unplugin transform now emits boundary-level, column-aware source maps with the input file as the source. New tests verify import injection, source-map accuracy, and undefined results when no auto-import is used.

Changes

Unplugin sourcemap precision

Layer / File(s) Summary
Boundary-level sourcemap generation
src/unplugin.ts
The transform generates source maps with boundary-level mappings and the input file identifier.
Transform and sourcemap validation
test/unplugin.test.ts
Tests verify plugin transformation, injected imports, populated sources, column-level mappings, and undefined results without auto-import usage.

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

Merge Risk: ⚪ Minimal · up to 57f3b

This change makes generated sourcemaps column-accurate and associates them with the transformed module while preserving unchanged-file behavior; no actionable merge-blocking 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 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 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 The changes satisfy issue #562 by generating boundary-level, column-accurate sourcemaps with source id populated. The tests verify injected imports, source mapping, multiple mapping segments, and unch…
Out of Scope Changes check ✅ Passed All changes are within scope. The source change fixes unplugin sourcemap generation, and the added tests validate the linked issue requirements.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: emitting column-accurate sourcemaps for the unplugin transform.
Full details: Linked Issues check

Explanation

The changes satisfy issue #562 by generating boundary-level, column-accurate sourcemaps with source id populated. The tests verify injected imports, source mapping, multiple mapping segments, and unchanged-file behavior.

  • 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@antfu
antfu merged commit febe97a into unjs:main Sep 8, 2026
1 of 4 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Sep 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.60%. Comparing base (a4a5e0a) to head (57f3bb3).
⚠️ Report is 187 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #563      +/-   ##
==========================================
- Coverage   98.73%   94.60%   -4.13%     
==========================================
  Files          14       15       +1     
  Lines        1817     1076     -741     
  Branches      374      363      -11     
==========================================
- Hits         1794     1018     -776     
- Misses         23       52      +29     
- Partials        0        6       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Sep 23, 2026
fix: Generate high resolution sourcemaps when injecting auto-imports wxt-dev/wxt#2606
Closed
Auto-imports emit a line-only sourcemap, silently collapsing code coverage (regression since v0.19.27, affects build and test) wxt-dev/wxt#2604
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

unplugin's transform emits a line-only sourcemap (generateMap() with no options), silently collapsing code coverage

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@official-burak @antfu
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.