Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Meta: Polyfills + Babel helpers #248

Closed
3 of 7 tasks
hzoo opened this issue Apr 4, 2017 · 3 comments
Closed
3 of 7 tasks

Meta: Polyfills + Babel helpers #248

hzoo opened this issue Apr 4, 2017 · 3 comments

Comments

@hzoo
Copy link
Member

hzoo commented Apr 4, 2017

Just going to make another issue to talk about the ideal scenario for both polyfills and babel helpers and how we can get there via babel-preset-env.

How can we write ES20xx and ship the smallest amount of code (for a given target environment)?

@Jessidhia
Copy link
Member

I don't think external-helpers should be a thing if you're going to use a module system; transform-runtime with useBuiltIns should already cover everything without adding an extra global to the application.

If you're going to separate things into libraries and apps, I think that libraries should only use helpers and use the built-ins from the environment. It is up to the app to provide the polyfills if the environment you expect to run on is outdated. If, for some reason, you still want to prevent your app from patching your environment, you can do a transform-runtime pass on all files transforming builtins.

@rtsao
Copy link
Contributor

rtsao commented Apr 7, 2017

If you're going to separate things into libraries and apps, I think that libraries should only use helpers and use the built-ins from the environment.

Agreed on polyfills, but I think helpers belong in the libraries themselves. If I'm writing a library that doesn't need polyfills, my library should work out of the box by someone not using Babel (i.e. they should not need to provide the babel helpers).

As mentioned in babel/babel#5601, I propose having a standalone babel-helpers package that allows libraries to import individual babel helpers. Then the application can consume the same babel-helpers package as used in node_modules, so you have full de-duplication of babel helpers. Furthermore, if the babel-helpers package exports an ES Module (via the module field of package.json) any unused babel helpers can be tree-shaken. In this case you have truly minimal babel helpers in the client bundle.

@babel-bot
Copy link

This issue has been moved to babel/babel#6628.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants