Skip to content

fix: Generate missing sourcemap in wxt:unimport plugin - #381

Merged
aklinker1 merged 2 commits into
mainfrom
add-missing-sourcemap-unimport
Jan 29, 2024
Merged

aklinker1 merged 2 commits into
mainfrom
add-missing-sourcemap-unimport

Conversation

@aklinker1

Copy link
Copy Markdown
Member

Apart of #236, addresses issue with wxt:unimport plugin transforming code, but not providing sourcemaps for the transformed code.

@netlify

netlify Bot commented Jan 29, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 40e16c9
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/65b7ca99857d7b00080d3b15
😎 Deploy Preview https://deploy-preview-381--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov

codecov Bot commented Jan 29, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f9718a1) 80.16% compared to head (40e16c9) 80.04%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #381      +/-   ##
==========================================
- Coverage   80.16%   80.04%   -0.13%     
==========================================
  Files         104      104              
  Lines        7528     7532       +4     
  Branches      679      677       -2     
==========================================
- Hits         6035     6029       -6     
- Misses       1477     1487      +10     
  Partials       16       16              

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

@aklinker1
aklinker1 marked this pull request as ready for review January 29, 2024 16:24
@aklinker1 aklinker1 self-assigned this Jan 29, 2024
@aklinker1 aklinker1 added the bug label Jan 29, 2024
@aklinker1
aklinker1 merged commit 5acf51a into main Jan 29, 2024
@aklinker1
aklinker1 deleted the add-missing-sourcemap-unimport branch January 29, 2024 16:30
zizzfizzix pushed a commit to zizzfizzix/wxt that referenced this pull request Aug 29, 2026
`unimport/unplugin` calls `MagicString#generateMap()` with no options,
which produces a line-level sourcemap with no `source`. Since auto-imports
are injected at the top of the file, tools that rely on columns - like V8
code coverage - see the whole module as a single statement.

The result is that any module referencing an auto-imported variable
(`browser`, `storage`, ...) silently drops out of coverage reports, which
inflates the reported percentage and lets thresholds pass when they
shouldn't.

This was fixed once in wxt-dev#381, but wxt-dev#1412 replaced the `wxt:unimport` plugin
with `UnimportPlugin.vite()` in both the build path and `WxtVitest()`,
dropping the `hires` option along the way.

Restore the `wxt:unimport` plugin with the sourcemap options from wxt-dev#381,
keeping the `enforce: 'post'` ordering and the include/exclude filter that
wxt-dev#1412 relied on. The defaults are imported from `unimport/unplugin`, so
they can't drift. Both the build path and `WxtVitest()` share the plugin.

Fixes wxt-dev#2604

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011PEx8LKp7AtQkR3tJfyFrY
zizzfizzix pushed a commit to zizzfizzix/wxt that referenced this pull request Aug 29, 2026
`unimport/unplugin` calls `MagicString#generateMap()` with no options,
which produces a line-level sourcemap with no `source`. Since auto-imports
are injected at the top of the file, tools that rely on columns - like V8
code coverage - see the whole module as a single statement.

The result is that any module referencing an auto-imported variable
(`browser`, `storage`, ...) silently drops out of coverage reports, which
inflates the reported percentage and lets thresholds pass when they
shouldn't.

This was fixed once in wxt-dev#381, but wxt-dev#1412 replaced the `wxt:unimport` plugin
with `UnimportPlugin.vite()` in both the build path and `WxtVitest()`,
dropping the `hires` option along the way.

Restore the `wxt:unimport` plugin with the sourcemap options from wxt-dev#381,
keeping the `enforce: 'post'` ordering and the include/exclude filter that
wxt-dev#1412 relied on. The defaults are imported from `unimport/unplugin`, so
they can't drift. Both the build path and `WxtVitest()` share the plugin.

Fixes wxt-dev#2604

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011PEx8LKp7AtQkR3tJfyFrY
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