-
Notifications
You must be signed in to change notification settings - Fork 87
Adding support for referencing external, global helpers #41
Conversation
@joeldenning Thanks. Squash commits please. |
20f2bdf
to
fb4fc89
Compare
Just squashed the commits. When would you plan on publishing to npm? |
@@ -103,6 +107,7 @@ export default function babel ( options ) { | |||
intro () { | |||
const helpers = Object.keys( bundledHelpers ); | |||
if ( !helpers.length ) return ''; | |||
if ( externalHelpers ) return ''; |
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.
This could be moved to the top of the method, as we can return immediately if we're using external helpers. I'm liking the changes overall! 👍
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 -- just changed that.
fb4fc89
to
24838bc
Compare
Thanks for the PR @joeldenning. There is an existing option called Incidentally |
@Rich-Harris http://www.2ality.com/2015/12/babel6-helpersstandard-library.html is a really good article that explains the difference between babel-polyfill, babel-runtime, and external-helpers-2. Especially take a look at 2.2, which explains the external-helpers-2 plugin. In a nutshell, babel-runtime will put something like The case for using external-helpers-2 is (at least) twofold: Anyway, all that explanation was just to arrive at the conclusion that, without my pull request, it is impossible for the |
24838bc
to
0743932
Compare
Ping |
@joeldenning It looks good to me. |
Adding support for referencing external, global helpers
Released in v2.4.0. |
Great thanks! |
This adds a backwards-compatible option for indicating that you want to call babel helpers on the global
babelHelpers
object, instead of inlining the functions for this bundle.I hesitated to add an option to the plugin that is not part of the normal babel options, but saw no other way to add in this feature without breaking backwards compatibility of code already using rollup-plugin-babel. The reason why it could not be solved with any combination of plugins is because rollup-plugin-babel assumes that babelHelpers need to be bundled even when you use the external-helpers or external-helpers-2 plugins. Also see here and here for the relevant code I'm referring to.
If there is some combination of
external-helpers
plugins that works without this pull request, then I'm all ears and will gladly switch to that and close this :)