Add noConflict entry mode to @babel/polyfill + change error to warning (#6371)

* feat: add noConflict polyfill entry
* use a warning
This commit is contained in:
Evan Scott 2018-04-22 19:11:50 -04:00 committed by Henry Zhu
parent d6dcbdad48
commit 0bb71caad3
3 changed files with 14 additions and 5 deletions

View File

@ -0,0 +1 @@
require("./lib/noConflict");

View File

@ -1,7 +1,13 @@
if (global._babelPolyfill) {
throw new Error("only one instance of @babel/polyfill is allowed");
}
global._babelPolyfill = true;
import "core-js/shim"; import "core-js/shim";
import "regenerator-runtime/runtime"; import "regenerator-runtime/runtime";
if (global._babelPolyfill && typeof console !== "undefined" && console.warn) {
console.warn(
"@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended " +
"and may have consequences if different versions of the polyfills are applied sequentially. " +
"If you do need to load the polyfill more than once, use @babel/polyfill/noConflict " +
"instead to bypass the warning.",
);
}
global._babelPolyfill = true;

View File

@ -0,0 +1,2 @@
import "core-js/shim";
import "regenerator-runtime/runtime";