refactor: use magic-string for proper source maps in WASM fix#234
Merged
dmarcos merged 2 commits intosparkjsdev:mainfrom Dec 11, 2025
Merged
Conversation
Improve the WASM data URL fix to use magic-string for accurate source map generation. This eliminates build warnings and ensures proper debugging support. - Replace string.replace() with MagicString.overwrite() - Return both code and source map from renderChunk - Uses existing magic-string dependency (via vite-plugin-dts)
- Replace match.index! with proper undefined check - Fix CRLF to LF line endings (biome format)
dmarcos
reviewed
Dec 7, 2025
| const matches = [...code.matchAll(dataUrlPattern)]; | ||
| if (matches.length === 0) return null; | ||
|
|
||
| const s = new MagicString(code); |
Contributor
There was a problem hiding this comment.
no single character variable names. can you come up with something else?
Contributor
|
What warnings are you referring to? I don't see any on my side when running |
Collaborator
With #231 merged the generated source map is no longer correct. Rollup detects that the plugin doesn't provide any sourcemap and logs the following warning when performing a build (twice): Do these warnings not show up for you when running |
Contributor
|
Yeah I see the warning now. Overlooked. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Improve the WASM data URL fix to use magic-string for accurate source map generation. This eliminates build warnings and ensures proper debugging support.