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:
parent
d6dcbdad48
commit
0bb71caad3
1
packages/babel-polyfill/noConflict.js
Normal file
1
packages/babel-polyfill/noConflict.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
require("./lib/noConflict");
|
||||||
@ -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;
|
||||||
|
|||||||
2
packages/babel-polyfill/src/noConflict.js
Normal file
2
packages/babel-polyfill/src/noConflict.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import "core-js/shim";
|
||||||
|
import "regenerator-runtime/runtime";
|
||||||
Loading…
x
Reference in New Issue
Block a user