FIX: when processing sourcemap files that do not exist, also remove nested transformation extensions #504
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.
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
.mapextension, 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.jsoncould also represent a valid file extension. Browsers also attempt to fetch.map.jsonsourcemaps if they are specified as asourceMappingURL, hinting that they are indeed valid:Previously, the
removed_sourcemap_commentmethod in theSourcemappingUrlProcessorwould strip thesourceMappingURL=file.js.mapcomment 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.jsoncode, which of course broke the script:This PR ensures that if the
sourceMappingURLcomment references a sourcemap file with a nested file extension that does not exist, that the nested file extension itself is also removed when the//# sourceMappingURLcomment is scrubbed.