Skip to content

Fix #4780: Babel should get correct options #4785

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

Merged
merged 1 commit into from
Nov 14, 2017

Conversation

GeoffreyBooth
Copy link
Collaborator

Fixes #4780. Currently when compiling with --transpile, the options object being sent to Babel isn’t “clean”—it’s a mutated version of the same options object for each iteration of the loop of each file that’s being compiled. So in #4780 the result of this was that some of the fields of source maps .map files were the same values for all files, when they shouldn’t be. This PR fixes things so that the options object is never mutated, but rather if we need to make adjustments to the options we pass to Babel, those adjustments happen in a copy.

@lydell you would be proud.

…d transpiling, so that options are correct on subsequent iterations
@@ -140,12 +140,14 @@ exports.compile = compile = withPrettyErrors (code, options = {}) ->
transpiler = options.transpile.transpile
delete options.transpile.transpile

transpilerOptions = Object.assign {}, options.transpile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good opportunity for some objects spreads 😄

transpilerOptions = { options.transpile... }

Copy link
Collaborator Author

@GeoffreyBooth GeoffreyBooth Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, indeed. 😄 I’m avoiding using them in the codebase, though, because the compiler is supposed to stay compatible with Node 6 and at some point that syntax will reach Stage 4 and we’ll start outputting it as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other notes?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, LGTM.

@GeoffreyBooth GeoffreyBooth merged commit bd824c7 into jashkenas:master Nov 14, 2017
@GeoffreyBooth GeoffreyBooth deleted the fix-transpile-options branch November 22, 2017 03:35
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.

CLI: --transpile and --map used together generate source maps with some incorrect values
2 participants