我可以导入babel polyfill模块而不是all in吗
Can I import babel-polyfill modules rather than all in?
如何导入babel polyfill的某些特定模块而不是全部导入?它似乎太大了,我无法导入所有的,我只是使用了它的一些功能。
我想要的如下:
import "babel-polyfill/symbol";
在后台,babel-polyfill
使用了一个名为core-js的项目(当然还有一些定制)。它公开了一个CommonJS API,所以假设您正在传输到CommonJS(使用preset-es2015时的默认行为),您可以简单地使用它:
// This pollutes the global namespace. May conflict with
// any real Symbol implementations in the future
import "core-js/es6/symbol";
// Namespace-safe Symbol import
import symbol from "core-js/es6/symbol";
使用这种方法时,使用某种捆绑器(Browserify、Webpack等)是很重要的,因为core-js由许多较小的模块组成,可能会导致大量不必要的HTTP请求。
如果您不希望导入整个babel polyfill以进行优化,则可以直接导入core-js。Core js可以
//import 'babel-polyfill';
//Selective imports in modular pattern
import 'core-js/fn/object/assign';
import 'core-js/fn/promise';
import 'core-js/fn/string/includes';
相关文章:
- Node.js's Buffer.writeFloatBE in Javascript
- Setting default onclick behavior for <img> tag in gene
- Nested Q.all nodejs
- Lucene Search in Alfresco
- Bootstrap Dropdown selection是在*all*下拉菜单上设置选择
- grep in JQuery to C#
- write HTML in JavaScript
- jQuery setTimeOut: in for-loop
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- 当一些承诺失败时,如何继续使用$q.all()
- HTMLInputElement in IE7
- Q.all on NodeList in Node
- 我可以导入babel polyfill模块而不是all in吗
- facebook login API: TypeError in all.js:95
- OnClick or OnHover Event Listen For All IMG in javascript
- 为什么.in获取除for之外的所有属性.dos't get all values
- Facebook Connect IE9 Javascript Error in all.js
- Thenables in Promise.all (ES6 and Bluebird)
- 返回可迭代与 Resolve in Promise.all