blog icon indicating copy to clipboard operation
blog copied to clipboard

babel plugins 小全

Open jindada opened this issue 8 years ago • 5 comments

babel-polyfill

是对浏览器缺失API的支持。比如浏览器可能没有Array.from() 方法。

jindada avatar Sep 18 '17 06:09 jindada

transform-runtime

是为了减少重复代码而生的。 babel生成的代码,可能会用到一些_extend(), classCallCheck() 之类的工具函数,默认情况下,这些工具函数的代码会包含在编译后的文件中。如果存在多个文件,那每个文件都有可能含有一份重复的代码。 babel-runtime插件能够将这些工具函数的代码转换成require语句,指向为对babel-runtime的引用,如 require('babel-runtime/helpers/classCallCheck'). 这样, classCallCheck的代码就不需要在每个文件中都存在了。 当然,最终你需要利用webpack之类的打包工具,将runtime代码打包到目标文件中。

jindada avatar Sep 18 '17 06:09 jindada

transform-object-rest-spread

jindada avatar Sep 18 '17 06:09 jindada

add-module-exports

jindada avatar Sep 18 '17 06:09 jindada

lodash

jindada avatar Sep 18 '17 08:09 jindada

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.

jindada avatar Sep 19 '17 02:09 jindada