Skip to content
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

Meta: Polyfills + Babel helpers #6628

Closed
3 of 7 tasks
babel-bot opened this issue Apr 4, 2017 · 3 comments
Closed
3 of 7 tasks

Meta: Polyfills + Babel helpers #6628

babel-bot opened this issue Apr 4, 2017 · 3 comments
Labels
i: discussion imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env

Comments

@babel-bot
Copy link
Collaborator

Issue originally reported by @hzoo in babel/babel-preset-env#248

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)?

@babel-bot
Copy link
Collaborator Author

Comment originally made by @Kovensky

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.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @rtsao

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 #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.

@nicolo-ribaudo
Copy link
Member

I'm doing some issues cleanup, all the points in the original issue have been either solved, or are not actionable from Babel (for example, the webpack chunks).

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: discussion imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env
Projects
None yet
Development

No branches or pull requests

2 participants