dynamic-import.js 782 B

12345678910111213141516
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.transformDynamicImport = transformDynamicImport;
  6. var _core = require("@babel/core");
  7. var _helperModuleTransforms = require("@babel/helper-module-transforms");
  8. const requireNoInterop = source => _core.template.expression.ast`require(${source})`;
  9. const requireInterop = (source, file) => _core.types.callExpression(file.addHelper("interopRequireWildcard"), [requireNoInterop(source)]);
  10. function transformDynamicImport(path, noInterop, file) {
  11. const buildRequire = noInterop ? requireNoInterop : requireInterop;
  12. path.replaceWith((0, _helperModuleTransforms.buildDynamicImport)(path.node, true, false, specifier => buildRequire(specifier, file)));
  13. }
  14. //# sourceMappingURL=dynamic-import.js.map