简体   繁体   English

如何仅一次导入babel-polyfill

[英]How to import babel-polyfill only one time

I done a react library that I share between a react web app and a react native app. 我完成了我在React Web应用程序和React Native应用程序之间共享的React库。

It uses return regeneratorRuntime.wrap to replace async. 它使用return regeneratorRuntime.wrap替换异步。 So I have to import babel-polyfill to do it working. 因此,我必须导入babel-polyfill才能使其正常工作。 I add : import "babel-polyfill"; 我添加:导入“ babel-polyfill”; on my module index.js file 在我的模块index.js文件上

It works well but I have this Ugly error on my app: 它运作良好,但我的应用程式出现这个Ugly错误:

 Uncaught Error: only one instance of babel-polyfill is allowed
        at Object.<anonymous> (index.es.js:6646)
        at Object.<anonymous> (main.4c81c635.js:11811)
        at t (bootstrap c8114fe78af615bb02e2:19)
        at Object.<anonymous> (main.4c81c635.js:19203)
        at t (bootstrap c8114fe78af615bb02e2:19)
        at Object.<anonymous> (main.4c81c635.js:15866)
        at t (bootstrap c8114fe78af615bb02e2:19)
        at Object.<anonymous> (main.4c81c635.js:18400)
        at t (bootstrap c8114fe78af615bb02e2:19)
        at Object.<anonymous> (main.4c81c635.js:17848)

Dow you know how to manage it? 您知道如何管理吗?

I changed my babel.rc to that and it works now ;) 我将babel.rc更改为该名称,现在可以正常使用了;)

 {
      "presets": [
        "react-app"
      ],
      "plugins": [
        "external-helpers"
      ]
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM