-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
allow --in-source-map inline #1490
Conversation
... and just as I started to think about the API case, I just realised any changes to |
bin/uglifyjs
Outdated
function read_source_map(code) { | ||
var match = /\n\/\/# sourceMappingURL=data:application\/json(;.*?)?;base64,(.*)/.exec(code); | ||
if (!match) { | ||
print_error("ERROR: can't read 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.
Perhaps add "inline" to the message so it's easier to catch configuration errors (I'm thinking along the lines of confusing --source-map-inline
with --in-source-map inline
).
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.
Done.
bin/uglifyjs
Outdated
var match = /\n\/\/# sourceMappingURL=data:application\/json(;.*?)?;base64,(.*)/.exec(code); | ||
if (!match) { | ||
print_error("ERROR: can't read source map"); | ||
process.exit(1); |
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.
I don't think it should be a fatal error if the upstream code lacks an inline source map.
Perhaps something like "WARNING: inline source map not found" and return null;
instead of process.exit(1);
?
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.
Done. Commit title updated.
@alexlamsl Thanks - nice job on the CLI. Surprisingly little new code added - mostly rearranging existing code. Glad the example proved useful. I appreciate that adding this feature to The use of Edit: If that's the case, then the exported base64 decode function for the browser can just throw a "not implemented" error as it won't be used. |
@alexlamsl Would you mind changing the PR title and eventual commit description to "[WIP] allow --in-source-map inline"? |
Agreed.
We actually have another problem in that we cannot use I am assuming you are talking about |
I can't be certain, but at least in the browserified version of |
No, I'm referring to the standalone https://github.com/mishoo/UglifyJS2/pull/1366/files#diff-465a5a39285d7d0ab958a973c3d58432R6 |
We want to avoid additional third party modules in Uglify where possible in order to keep Uglify small and fast. I'm fairly sure that |
Are there any features of base 64 decode appears to work correctly in node 0.10.x:
|
I was referring to the use of |
I'd be positively impressed if |
I'm not too worried about that. It's still supported. No uglify user has complained as far as I know. |
So according to MDN we can use |
But it's not supported by |
@alexlamsl Your fix to optionally support inline input source maps works nicely:
|
Thanks - I even have a test case for it 😉 |
Isn't this PR good to go? |
Not really if you mean as it is right now - But delaying of #1366 meant I can now proceed in completing this. And it does looks like a good feature to have for 2.8.0 so I'll get to this right after I finished my local git housekeeping 😉 |
@kzc due to new default optimisation options, I need to update |
I never actually loaded these source maps to verify them, but it looks well formed as far as I can tell. |
It eventually does the same thing... It's a bit confusing how TOPLEVEL can be either an Uglify AST or a Mozilla AST at different points in the program. |
|
Wait... I see what's going on: the first argument of |
I knew that
Cool! |
@kzc ah, that means this PR won't work even for Tempted to explicitedly throw an error for both interfaces if both |
I think Mozilla AST (spidermonkey) and inline input source maps are inherently incompatible because I don't think comments are preserved in the Mozilla AST - and if they are Uglify does not handle them. https://github.com/estree/estree |
@kzc added checks & tests for built-in parser during |
Great. I'm sure it's fine. |
- limited to one input file (or `stdin`) - only works with built-in parser fixes mishoo#520
Don't you think that having |
I could live with |
The behavior should be the same as with |
Seems the choice was arbitrary. Probably should error out for a conflict between At least with the present behavior of Perhaps even have extra aliases |
fixes #520
@kzc separated into two commits so it's easier to see the cli changes (haven't done anything to the API case yet)
You'll be glad to know that #520 (comment) didn't go to waste - aside from educating me on what a source map looks like, it forms the test case inside
test/mocha/cli.js
😉