Skip to content

Fix SOURCEMAP_BROKEN warnings: return an empty sourcemap from the transform hook - #12

Merged
evoactivity merged 1 commit into
svg-jar:mainfrom
NullVoxPopuli:fix-sourcemap-broken-warning
Jul 28, 2026
Merged

Fix SOURCEMAP_BROKEN warnings: return an empty sourcemap from the transform hook#12
evoactivity merged 1 commit into
svg-jar:mainfrom
NullVoxPopuli:fix-sourcemap-broken-warning

Conversation

@NullVoxPopuli

Copy link
Copy Markdown
Contributor

Note

This PR was made with Claude (AI) — apologies in advance if anything here misses the mark; happy to adjust or split it up however you prefer.

Problem

The transform hook returns bare strings. Any bundler building with sourcemaps enabled (rolldown/tsdown, rollup, vite build) then warns once per imported SVG:

(svg-jar plugin) [SOURCEMAP_BROKEN] Sourcemap is likely to be incorrect: a plugin (svg-jar)
was used to transform files, but didn't generate a sourcemap for the transformation.

In an icon-heavy library that's dozens of warnings per build.

Fix

The transform replaces each SVG module's code wholesale, so there is no meaningful mapping back to the source. Per the Rollup convention, the hook now returns { code, map: { mappings: '' } } — an explicitly empty sourcemap — instead of a bare string.

Test

Test-first, in the tsdown example project:

  1. test-projects/tsdown/internal-package now builds with sourcemap: true
  2. The tsdown integration test captures the example's build output and asserts it contains no SOURCEMAP_BROKEN — red before the fix (3 warnings, one per SVG import), green after
  3. The tsdown catalog entry is bumped ^0.21.8^0.22.9: the warning only surfaces on current rolldown (1.2.x), not the 1.0.0-rc line the catalog previously resolved to. The lockfile churn beyond tsdown is transitive fallout from that re-resolution.

🤖 Generated with Claude Code

…nsform hook

The transform hook returned bare strings, so bundlers building with
sourcemaps enabled (rolldown/tsdown, rollup, vite build) warned
SOURCEMAP_BROKEN once per imported SVG. The transform replaces each SVG
module's code wholesale, so there is no meaningful mapping back to the
source: return { code, map: { mappings: '' } } per the Rollup convention.

The tsdown example project now builds with sourcemap: true, and its
integration test asserts the build output contains no SOURCEMAP_BROKEN.
The tsdown catalog entry is bumped to ^0.22.9 because the warning only
surfaces on current rolldown (1.2.x), not the 1.0.0-rc line.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@evoactivity

Copy link
Copy Markdown
Contributor

looks like tsdown 0.22.x drops supports for node 20

can you get the bot to drop node 20 from the matrix and add node 26?

@NullVoxPopuli

Copy link
Copy Markdown
Contributor Author

faster for me to do that one by hand #13 <3

@evoactivity evoactivity reopened this Jul 28, 2026
@evoactivity evoactivity added the bug Something isn't working label Jul 28, 2026
@evoactivity
evoactivity merged commit 7c5f58e into svg-jar:main Jul 28, 2026
21 of 30 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants