-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
Return full result from babel.transform
.
#629
Conversation
aef8bbe
to
d60cce3
Compare
src/transform.js
Outdated
|
||
if (map && (!map.sourcesContent || !map.sourcesContent.length)) { | ||
map.sourcesContent = [source]; | ||
} | ||
|
||
return { code, map, metadata }; | ||
return result; |
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.
My one concern here is that result.options
is not serializable to JSON. This change makes the full options
object available to result
override callbacks, but it'll only be useful if you're running without the cache, since the cache version would reload and be missing stuff.
When you asked originally I was fine with removing the whitelist of props, but now I'm leaning toward saying we'd be better to at least blacklist the result.options
property.
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.
Good point. I can alternatively just add ast
to the whitelist if that's better?
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.
The full set of props is at https://github.com/babel/babel/blob/9283efaeb7a8c5b505b19332c3407dc44c668777/packages/babel-core/src/transformation/index.js#L64
If you want to expand the whitelist to include all of those except options
that sounds good to me.
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.
Will do! 🎉
Previous code only returns an object of the shape `{ code, map, metadata }` which prevents accessing things like the AST when `babel` is configured to output it. This change allows access to more things that `babel` spits out.
d60cce3
to
1620d4a
Compare
All set @loganfsmyth 😄 thanks for the feedback and quick turnaround! |
Thanks! |
Previous code only returns an object of the shape
{ code, map, metadata }
which prevents accessing things like the AST whenbabel
is configured to output it. This change allows access to more things thatbabel
spits out.Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior? (You can also link to an open issue here)
Returns only
{ code, map, metadata }
.What is the new behavior?
Returns more result data (
ast
andsourceType
).Does this PR introduce a breaking change?