-
-
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
fix: Fix sourcemap file lookup #313
Conversation
/cc @ember-cli/ember-cli ⬆️ |
|
||
// Forked from https://github.com/lydell/source-map-url/blob/master/source-map-url.js | ||
// We use a slightly adjusted regex here | ||
const convertSourceMap = require('convert-source-map'); |
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.
any way we can use convert-source-map directly instead of needing teh lib/source-map-url.js file?
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.
It seems to work a bit differently, and I didn't find a good method it exposed (?) to just get all source map URLs in a file - there is a method to just get the last one, and a method to remove all of them in the file, both of which are not suited to what we need here 😓
@@ -16,6 +16,7 @@ Object { | |||
background: white; | |||
}", | |||
"with-broken-sourcemap.js": "function meaningOfLife(){throw new Error(42)}", | |||
"with-sourcemap-like-string.js": "function createURL(e,n,a){var i=void 0===n?null:n,t=decodeBase64(e,void 0!==a&&a),c=t.indexOf(\\"\\\\n\\",10)+1,r=t.substring(c)+(i?\\"//# sourceMappingURL=\\"+i:\\"\\"),o=new Blob([r],{type:\\"application/javascript\\"});return URL.createObjectURL(o)}function createURL2(e,n,a){var i=void 0===n?null:n,t=decodeBase64(e,void 0!==a&&a),c=t.indexOf(\\"\\\\n\\",10)+1,r=t.substring(c)+(i?\\"//# sourceMappingURL=\\"+i:\\"\\"),o=new Blob([r],{type:\\"application/javascript\\"});return URL.createObjectURL(o)}", |
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.
thanks a ton for the additional tests!!!!
@@ -6089,7 +6094,7 @@ source-map-support@^0.5.6, source-map-support@~0.5.19: | |||
buffer-from "^1.0.0" | |||
source-map "^0.6.0" | |||
|
|||
source-map-url@^0.4.0, source-map-url@^0.4.1: | |||
source-map-url@^0.4.0: |
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.
now that 0.4.1 is removed, what's still bringing this in to the dep graph? 🤔
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.
it is some deep dependency (source-map-resolve < snapdragon < nanomatch ....) 😬
thanks a bunch for working on this! 🎉 |
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.
Thanks a ton for working on this!!!
🙏 it would be great if we could merge & release this as a patch level release in order for all packages depending on this getting this fix "for free"! |
We ran into this here: getsentry/sentry-javascript#9168, where the build failed when source maps & terser were enabled.
The root cause is that the used dependency: https://github.com/lydell/source-map-url is very old, and the regex it uses is not bullet proof. So this code (that some dependency generated):
Was incorrectly matched by the regex, but return an
''
url. Which then in turn messed up this addon, because whilefs.existsSync(sourceMapPath)
passed, it actually pointed to a directory, not a path (because oflet sourceMapPath = path.join(inFileDirname, urls[i]);
, where the url is''
).This PR does two thigns: