Approach for untranspiled code:
- No package ever polyfills.
- Use only functionality at stage 4 or older.
- The entry point does
import "babel-polyfill";for whichenv.useBuiltinsgenerates the imports appropriate for the current targets.- Benefit: the bundle only includes functionality that the target platforms don’t have. Think: custom-tailored
babel-polyfill.
- Benefit: the bundle only includes functionality that the target platforms don’t have. Think: custom-tailored
For Node.js, the untranspiled code would be transpiled via target: { node: "current" }.
- Play it safe, should every package do
import "babel-polyfill";at its entry point?- Note: not as problematic, because bundle size is not a factor on Node.js.
First of all, thanks for this gist!
I have two question, I'd like to clarify. Does
babel-polyfillincluderegeneratorRuntime? And how to deal with a situation, when a library has to support browser and node.js?