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

Ability to define a custom namespace for external helpers #5217

buzinas opened this Issue Jan 26, 2017 · 6 comments


None yet
4 participants

buzinas commented Jan 26, 2017

Currently the code sets up a hard-coded namespace babelHelpers.

I would like to have the ability to define my own name, eg:

  "plugins": [
    ["external-helpers": { "namespace": "_myNamespace" }]
export default function ({ types: t }) {
  return {
    pre(file) {
      file.set("helpersNamespace", t.identifier(file.opts.namespace || "babelHelpers"));

Do you see any problem if we add this option to the external-helpers plugin?


This comment has been minimized.


babel-bot commented Jan 26, 2017

Hey @buzinas! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.


This comment has been minimized.


hzoo commented Jan 26, 2017

Thanks for bringing this up - curious what's your use case for doing this?


This comment has been minimized.

buzinas commented Jan 27, 2017

@hzoo basically it's because we have a very big application, and we're trying to reduce as most as we can the footprint. We're already injecting only the external helpers we actually use, and minifying them, but we have ~8kb of the word "babelHelpers" in our final JS file.

Of course gzipping helps there, but want to change that to any 2-letters word, and it would be simple if we could customize that. Currently, we copied that plugin internally and hardcoded another namespace, but it would be good if the plugin offered this possibility.


This comment has been minimized.


hzoo commented Feb 8, 2017

So gzip/minify babelHelpers doesn't do anything since it's global?


This comment has been minimized.

buzinas commented Feb 8, 2017

Yeah, that's right. But found a way to use Webpack Provide plugin to inject babelHelpers into each module, and then UglifyJS could rename it :)

Although, since it's a pretty simple change, it could help other people that don't use Webpack.


This comment has been minimized.

rafayepes commented Feb 8, 2017

@buzinas do you have an example setup?

@hzoo hzoo added the area: helpers label Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment