zspecza / common-tags

🔖 Useful template literal tags for dealing with strings in ES2015+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can we get rid of the babel-runtime as a dependency?

laszbalo opened this issue · comments

Can we get rid of the babel-runtime as a dependency?

What is the motivation?

babel-runtime is used so that babel helpers will not be repeated multiple times in the build.

@wickedest What do you suggest as an alternative?

After reading the article, I was only superficially curious as to what he was talking about so I had a quick look. The issue in the article is with @angular/cli using 3 methods from common-tags, but the outlaying issue is babel-runtime is a heavy dependency. If your project positively needs it, then keep it. If there is a way you can drop the dependency, then maybe you should consider.

We are considering dropping Babel and replacing it with TypeScript, which would inline all the needed stuff. We care about browser compatibility, which is what Babel is used for, and TypeScript is handling that well (even as far as ES3).

On the other hand I'm worried about the said article, because it clearly blames the lib authors for the situation without providing any sensible solutions. That's in part because it says that the situation "is bad" (which is highly subjective), but does not look into the "why". If we know the "why" (in this case browser compatibility), then we can look for other solutions, indeed.

Worry not, we are looking into that - I'm just curious if the community has some ideas about what would be "good". After all, if our next solution won't please the community, we are in for another Medium article about the lib not being good enough.

Cloned the repo just now when I was surprised to see the addition of babel-runtime to my package-lock.json after installing common-tags. Followed the above medium link to find this comment by @declandewet and have a lot of empathy for this situation.

Is it possible this can be safely dropped since Node 4 LTS is EOL tomorrow and anybody else will likely be compiling/bundling their dependencies? If not, I'd love to pitch in and help out if there are specific areas using features requiring the presence of the polyfill.

Just an FYI for anyone in this thread that can't use common-tags because of this dependency, I just published an alternative stripIndent implementation called theredoc that might be suitable for some folks interested in common-tags for only that functionality

Heads up: the upcoming version will have the babel-runtime dependency removed.

Woot! Thanks, @fatfisz!