Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: when processing sourcemap files that do not exist, also remove nested transformation extensions #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markrmullan
Copy link
Contributor

@markrmullan markrmullan commented Mar 9, 2022

The requirements about file extensions for sourcemaps, per the spec (https://sourcemaps.info/spec.html#h.9ppdoan5f016), are hazy at best. There is a recommendation that sourcemap file names may match the generated file but with a .map extension, but it appears they do not explicitly need to end with .map.

On a similar note, sourcemap files MUST contain one valid JSON object (https://sourcemaps.info/spec.html#h.1ce2c87bpj24) and as a result, .map.json could also represent a valid file extension. Browsers also attempt to fetch .map.json sourcemaps if they are specified as a sourceMappingURL, hinting that they are indeed valid:

Screen Shot 2022-03-09 at 2 24 03 PM

Previously, the removed_sourcemap_comment method in the SourcemappingUrlProcessor would strip the sourceMappingURL=file.js.map comment from the digested asset if the sourcemap file did not exist, but it would not remove nested file extension transformations. This caused an issue for us because the end result would be an uncommented piece of .json code, which of course broke the script:

Screen Shot 2022-03-09 at 11 59 00 AM

This PR ensures that if the sourceMappingURL comment references a sourcemap file with a nested file extension that does not exist, that the nested file extension itself is also removed when the //# sourceMappingURL comment is scrubbed.

@markrmullan
Copy link
Contributor Author

Hey @rafaelfranca 👋 just wanted to bump this PR and see if you had any thoughts / concerns. Thank you + other contributors for your blood, sweat and tears on this project and much more!

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.

None yet

1 participant