-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
remove sourceMappingURL if it doesn't have the same name with the js … #58
base: master
Are you sure you want to change the base?
remove sourceMappingURL if it doesn't have the same name with the js … #58
Conversation
…file. use the last map file if there is no map file with the same name with the js file. this is possibly wrong and it might rather be correct to raise an error in such case.
This commit has a logic error. |
This is the correct logic: let url = srcURL.getFrom(src);
let lastUrl = srcURL.getFrom(src);
// Make sure vendor.map is being used because vendor.js can have multiple sourceMappingURL if modules also have it.
while (url && url.match(/.+?(?=\.map$)/)[0] !== relativePath.match(/(.*\/)?(.+)\.js/)[2]) {
src = srcURL.removeFrom(src);
lastUrl = url;
url = srcURL.getFrom(src);
}
// If there is no map url which has an identical name with the js file, use the last one.
// It's possible we should rather raise an error instead.
if (!url) {
url = lastUrl;
} |
thanks @ashleysommer , you understood my intention correctly. I will update the PR. |
@@ -100,6 +100,18 @@ UglifyWriter.prototype.processFile = function(inFile, outFile, relativePath, out | |||
|
|||
if (srcURL.existsIn(src)) { | |||
let url = srcURL.getFrom(src); | |||
let lastUrl = null; | |||
// Make sure vendor.map is being used because vendor.js can have multiple sourceMappingURL if modules also have it. | |||
while (url && url.match(/.+?(?=\.map$)/)[0] !== relativePath.match(/(.*\/)?(.+)\.js/)[2]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a heads-up, tests will be required
@maxvoltage sorry, I don't understand what problem exactly this PR is trying to fix. #55 should have fixed most of the issues. please make sure you're using the current version of this dependency. |
#55 fix only applies when there is a single sourceMappingURL in the src file. It simply reads the directive, checks if the file exists, and ignores the sourceMap if it doesn't exist. It doesn't check for other sourceMappingURL directives in the src. This fix applies in the case that there are two or more sourceMappingURL directives in the src (usually caused by concatenating multiple third-party libraries into a single vendor.js file). This fix asserts that the most likely correct sourceMappingURL will be the one that matches/contains the filename of the src file. Failing that, it falls back to using the last found sourceMappingURL, because the spec indicates that the correct sourceMappingURL should be at the end of the src file, and any before that must be artifacts from concatenation. |
vendor.js file can have multiple
sourceMappingURL
locations when modules have their ownsourceMappingURL
.source-map-url
module finds only onesourceMappingURL
at a time. This PR removes sourceMappingURL if it doesn't have the same name with the js file until it finds the correct one.Use the last map file if there is no map file with the same name with the js file. This is possibly wrong and it might rather be correct to raise an error in such case.
Related issue: ember-cli/ember-cli-terser#29