zspecza / common-tags

🔖 Useful template literal tags for dealing with strings in ES2015+
Other
1.99k stars 61 forks source link

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

Closed laszbalo closed 6 years ago

fatfisz commented 6 years ago

What is the motivation?

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

wickedest commented 6 years ago

I came here looking for this very issue. It's mentioned here https://hackernoon.com/whats-really-wrong-with-node-modules-and-why-this-is-your-fault-8ac9fa893823

fatfisz commented 6 years ago

@wickedest What do you suggest as an alternative?

wickedest commented 6 years ago

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.

fatfisz commented 6 years ago

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.

searls commented 6 years ago

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.

searls commented 6 years ago

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

fatfisz commented 6 years ago

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

searls commented 6 years ago

Woot! Thanks, @fatfisz!