blog
blog copied to clipboard
babel plugins 小全
babel-polyfill
是对浏览器缺失API的支持。比如浏览器可能没有Array.from() 方法。
transform-runtime
是为了减少重复代码而生的。 babel生成的代码,可能会用到一些_extend(), classCallCheck() 之类的工具函数,默认情况下,这些工具函数的代码会包含在编译后的文件中。如果存在多个文件,那每个文件都有可能含有一份重复的代码。 babel-runtime插件能够将这些工具函数的代码转换成require语句,指向为对babel-runtime的引用,如 require('babel-runtime/helpers/classCallCheck'). 这样, classCallCheck的代码就不需要在每个文件中都存在了。 当然,最终你需要利用webpack之类的打包工具,将runtime代码打包到目标文件中。
transform-object-rest-spread
add-module-exports
babel-plugin-react-require
Babel plugin that adds React import declaration if file contains JSX tags.
This plugin is only about stateless components that doesn't extends React.Component. If you want to use any other React functions then you should import their by yourself.