简体   繁体   中英

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.

It uses return regeneratorRuntime.wrap to replace async. So I have to import babel-polyfill to do it working. I add : import "babel-polyfill"; on my module index.js file

It works well but I have this Ugly error on my app:

 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 ;)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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