Skip to content

Conversation

@cspotcode
Copy link
Collaborator

TypeScript 4.1.1 started percent-encoding the filenames in //# sourceMappingURL

Before TS 4.1.1:

//# sourceMappingURL=foo bar.js.map

After TS 4.1.1

//# sourceMappingURL=foo%20bar.js.map

Changes made to support --transpiler (#1160) effectively avoided this issue. We computed where we thought the comment should begin, but if it wasn't at that position, we simply appended our sourceMappingURL comment, overriding whatever was already there. This means if a path was percent-encoded, we didn't care: we appended, overrode, and users were happy.

Nevertheless, this PR implements logic to percent-encode the path and check for a sourceMappingURL comment at that offset.

The new logic is:

  • check based on non-percent-encoded path. If found, replace the comment
  • check based on percent-encoded path. If found, replace the comment
  • If neither found, append our sourceMappingURL comment after any comment that might already be there

See also: #1322

@codecov
Copy link

codecov bot commented May 22, 2021

Codecov Report

Merging #1330 (e813ef7) into main (6b8323e) will increase coverage by 0.20%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
src/index.ts 78.64% <100.00%> (+0.55%) ⬆️

@cspotcode cspotcode merged commit 16b66eb into main May 23, 2021
@cspotcode cspotcode deleted the ab/handle-percent-encoded-sourcemappingurls branch October 11, 2021 03:46
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.

2 participants