"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = _default;

function _react() {
  const data = _interopRequireDefault(require("react"));

  _react = function _react() {
    return data;
  };

  return data;
}

function _path() {
  const data = require("path");

  _path = function _path() {
    return data;
  };

  return data;
}

function _umiUtils() {
  const data = require("umi-utils");

  _umiUtils = function _umiUtils() {
    return data;
  };

  return data;
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const coreJSPath = (0, _path().dirname)(require.resolve('core-js/package.json'));

function _default() {
  return {
    visitor: {
      ImportDeclaration(path, state) {
        const filename = (0, _umiUtils().winPath)(state.filename);

        if (filename.endsWith('.umi/polyfills.js') || filename.endsWith('.umi-production/polyfills.js')) {
          const node = path.node;

          if (node.source.value.startsWith('core-js/')) {
            node.source.value = node.source.value.replace('core-js/', `${coreJSPath}/`);
          }
        }
      }

    }
  };
}