fix regenerator import (#68)
This commit is contained in:
parent
b8f03ee09d
commit
44c40cf7ab
@ -10,7 +10,7 @@ const whitelist = [
|
||||
|
||||
export default function ({ types: t }) {
|
||||
function createImportDeclaration(polyfill) {
|
||||
let declar = t.importDeclaration([], t.stringLiteral(`core-js/modules/${polyfill}`));
|
||||
let declar = t.importDeclaration([], t.stringLiteral(polyfill));
|
||||
declar._blockHoist = 3;
|
||||
return declar;
|
||||
}
|
||||
@ -20,7 +20,7 @@ export default function ({ types: t }) {
|
||||
t.callExpression(
|
||||
t.identifier("require"),
|
||||
[
|
||||
t.stringLiteral(`core-js/modules/${polyfill}`)
|
||||
t.stringLiteral(polyfill)
|
||||
]
|
||||
)
|
||||
);
|
||||
@ -36,7 +36,11 @@ export default function ({ types: t }) {
|
||||
isPolyfillSource(path.node.expression.arguments[0].value);
|
||||
}
|
||||
|
||||
function createImport(polyfill, requireType) {
|
||||
function createImport(polyfill, requireType, core) {
|
||||
if (core) {
|
||||
polyfill = `core-js/modules/${polyfill}`;
|
||||
}
|
||||
|
||||
if (requireType === "import") {
|
||||
return createImportDeclaration(polyfill);
|
||||
} else {
|
||||
@ -47,7 +51,7 @@ export default function ({ types: t }) {
|
||||
function createImports(polyfills, requireType, regenerator) {
|
||||
let imports = polyfills
|
||||
.filter((el, i, arr) => arr.indexOf(el) === i)
|
||||
.map((polyfill) => createImport(polyfill, requireType));
|
||||
.map((polyfill) => createImport(polyfill, requireType, true));
|
||||
|
||||
return [
|
||||
...imports,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import "core-js/modules/web.timers";
|
||||
import "core-js/modules/web.immediate";
|
||||
import "core-js/modules/web.dom.iterable";
|
||||
import "core-js/modules/regenerator-runtime/runtime";
|
||||
import "regenerator-runtime/runtime";
|
||||
|
||||
@ -32,6 +32,6 @@ import "core-js/modules/es7.string.pad-end";
|
||||
import "core-js/modules/web.timers";
|
||||
import "core-js/modules/web.immediate";
|
||||
import "core-js/modules/web.dom.iterable";
|
||||
import "core-js/modules/regenerator-runtime/runtime";
|
||||
import "regenerator-runtime/runtime";
|
||||
|
||||
Math.pow(1, 2);
|
||||
Math.pow(1, 2);
|
||||
|
||||
@ -18,6 +18,6 @@ import "core-js/modules/es7.string.pad-end";
|
||||
import "core-js/modules/web.timers";
|
||||
import "core-js/modules/web.immediate";
|
||||
import "core-js/modules/web.dom.iterable";
|
||||
import "core-js/modules/regenerator-runtime/runtime";
|
||||
import "regenerator-runtime/runtime";
|
||||
|
||||
Math.pow(1, 2);
|
||||
Math.pow(1, 2);
|
||||
|
||||
@ -84,6 +84,6 @@ import "core-js/modules/es7.string.pad-end";
|
||||
import "core-js/modules/web.timers";
|
||||
import "core-js/modules/web.immediate";
|
||||
import "core-js/modules/web.dom.iterable";
|
||||
import "core-js/modules/regenerator-runtime/runtime";
|
||||
import "regenerator-runtime/runtime";
|
||||
|
||||
Math.pow(1, 2);
|
||||
Math.pow(1, 2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user