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

babel plugins 小全 #7

Open
jindada opened this issue Sep 18, 2017 · 5 comments
Open

babel plugins 小全 #7

jindada opened this issue Sep 18, 2017 · 5 comments
Labels

Comments

@jindada
Copy link
Owner

jindada commented Sep 18, 2017

babel-polyfill

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

@jindada
Copy link
Owner Author

jindada commented Sep 18, 2017

transform-runtime

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

@jindada
Copy link
Owner Author

jindada commented Sep 18, 2017

transform-object-rest-spread

@jindada
Copy link
Owner Author

jindada commented Sep 18, 2017

add-module-exports

@jindada
Copy link
Owner Author

jindada commented Sep 18, 2017

lodash

@jindada
Copy link
Owner Author

jindada commented Sep 19, 2017

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 jindada added the babel label Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant