fix(sourcemaps): do not encode inline sourcemaps #3163
Merged
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.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm test
) were run locally and passednpm run test.karma.prod
) were run locally and passednpm run prettier
) was run locally and passedPull request type
Please check the type of change your PR introduces:
What is the current behavior?
this commit fixes a regression originally introduced in #3100, where
inline sourcemaps that are data URI's are erroneously encoded using
RFC-3986. this causes the sourcemaps for tests to not correctly map the
transpiled output back to the original source code.
GitHub Issue Number: #3147
What is the new behavior?
do not URI encode the data prefix+mime type
Does this introduce a breaking change?
Testing
To test, I spun up 2 component libraries using
npm init stencil
:with-sourcemap-issue
, which is the standard output one would see from the Stencil CLI (with v2.11.0 installed)with-local-stencil-build
, which differs from the above only in name and has a Stencil build with this branch installed on it (npm ci && npm run build && npm pack
to generated the tarball, then installed withnpm i <PATH_TO_TAR>
)From there, I ran through the two test cases described in the issue summary of #3147, described below
'For Call Stacks'
Reproduction setup (in both projects):
utils.ts
and add a throwing code to line 2. Example: '1'.d();export function format(first: string, middle: string, last: string): string { + '1'.d(); return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : ''); }
npm test -- --coverage --verbose --no-cache
Outcomes:
In
with-sourcemap-issue
, the sourcemap does not map back to the correct line, which should be "(src/utils/utils.ts:2:7)" (where I added the line). Inwith-local-stencil-build
, the sourcemap maps back to the correct line. The results are shown below, wherewith-sourcemap-issue
is on the left, andwith-local-stencil-build
is on the right'For Coverage'
Reproduction setup (in both projects):
utils.ts
and add a branching expression that will never be hitnpm test -- --coverage --verbose --no-cache
Outcomes:
In
with-sourcemap-issue
, the sourcemap does not map back to the correct line when opening the coverage report. (the coverage reports can be found in thecoverage/
dir in the root of each project). Inwith-local-stencil-build
, the sourcemap maps back to the correct line in the coverage report. The results are shown below, wherewith-sourcemap-issue
is on the left, andwith-local-stencil-build
is on the right.Note how the uncovered line number column is incorrect for the following code (which is the same piece of code in each project) on the left, and correct on the right


Other information
Shoutout to @johnjenkins for their work in debugging this! #3147 (comment)