babel-polyfill
Babel-Polyfill will simulate an ES2015+environment in the application, so you can use Babel-Polyfill to use built-in objects such as Promise and Weakmap, static methods such as array.from and object.assign. And the Generator function (need to provide Babel-Plugin-Transform-Regnerator plug-in). In general, Polyfill has modified the global scope, under the browser is Window, and the global is under node.
Babel-Polyfill is mainly composed of two parts, Core-JS and Regnerator Runtime.
Core-JS: Provides the simulation implementation of various objects and methods defined in the specifications such as ES5, ES6, ES7.
Regnerator: Provide general support, if the general use of the general and async function in the application code is used.
Introduction to Babel-Polyfill will become very large after full package.
babel-plugin-transform-runtime
Babel-Plugin-Transform-Runtime mainly did three things:
- When you use the Generator/Async function, automatically introduce Babel-Runtime/Regnerator (running with regenerator without polluting the current environment).
- Automatically introduce Babel-Runtime/Core-JS and map ES6 static methods and built-in plug-ins (the function of Polyfill and has no global pollution,but the instance method cannot be used normally, such as “FOOBAR” .inCludes (“FOO”) )。
- Remove the Babel Helper of Neilian and use the module Babel-Runtime/Helpers instead (extract the code of the Babel conversion syntax).
{
"plugins": [
["transform-runtime", {
"helpers": true, // default
"polyfill": true, // default
"regenerator": true, // defalut
"moduleName": "babel-runtime" // default
}]
]
}
No additional configuration is to use the default configuration, so it is possible. So Babel-Plugin-Transform-Runtime does not pollute the global environment, which is generally used in the Node packaged by Webpack. Because of this, Transform-Runtime is widely used in third-party libraries.
Install Babel-Plugin-Transform-Runtime back to install Babel-Runtime by default (all the help functions are in this package).
Reference:
https://babeljs.io/docs/en/babel-plugin-transform-runtime
https://babeljs.io/docs/en/babel-plugin-transform-runtime#technical-detailshttps://www.cnblogs.com/chyingp/archive/2018/06/01/understanding-babel-polyfill.html
https://www.cnblogs.com/JRliu/p/8280055.html