Ошибка: файлы плагинов / пресетов не позволяют экспортировать объекты, только функции - Babel jest - PullRequest
0 голосов
/ 20 сентября 2019

Я настраиваю вавилонскую шутку в своем проекте Vue.Обновление babel дает мне эту ошибку.

Ошибка: файлы плагинов / предустановок не позволяют экспортировать объекты, только функции - в babel-preset-stage2

Вот мой package.json:

{
  "name": "JOM",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "build": "node build/build.js",
    "lint": "vue-cli-service lint",
    "test:e2e": "node test/e2e/runner.js",
    "test": "npm run unit",
    "pa11y": "pa11y-ci --config pa11y-config.json -j > pa11y-results.json",
    "unit": "jest --config jest.config.js",
    "serve": "vue-cli-service serve"
  },
  "dependencies": {
    "@sentry/browser": "^5.6.3",
    "@sentry/integrations": "^5.6.1",
    "@tinymce/tinymce-vue": "^2.0.0",
    "axios": "^0.18.0",
    "babel-preset-es2015": "^6.24.1",
    "cookie": "^0.4.0",
    "core-js": "^2.6.5",
    "file-saver": "^2.0.2",
    "lodash.debounce": "^4.0.8",
    "moment": "^2.24.0",
    "register-service-worker": "^1.6.2",
    "serve": "^11.0.0",
    "tinymce": "^5.0.15",
    "vue": "^2.6.10",
    "vue-fineuploader": "^2.0.0-rc.9",
    "vue-router": "^3.1.3",
    "vuetify": "^1.5.18",
    "vuetify-loader": "^1.3.0",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.1.6",
    "@babel/preset-env": "^7.6.0",
    "@babel/preset-react": "^7.0.0",
    "@babel/preset-stage-2": "^7.0.0",
    "@vue/cli-plugin-babel": "^3.7.0",
    "@vue/cli-plugin-e2e-nightwatch": "^3.9.0",
    "@vue/cli-plugin-eslint": "^3.7.0",
    "@vue/cli-plugin-pwa": "^3.7.0",
    "@vue/cli-plugin-unit-jest": "^3.9.0",
    "@vue/cli-service": "^3.7.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/test-utils": "^1.0.0-beta.29",
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-eslint": "^8.2.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-jest": "^21.2.0",
    "babel-loader": "^8.0.4",
    "babel-plugin-dynamic-import-node": "^1.2.0",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-plugin-transform-vue-jsx": "^3.7.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.24.1",
    "babel-register": "^6.22.0",
    "chalk": "^2.4.2",
    "chromedriver": "^2.27.2",
    "copy-webpack-plugin": "^4.0.1",
    "cross-spawn": "^5.0.1",
    "css-loader": "^0.28.0",
    "eslint": "^4.15.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-node": "^5.2.0",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^3.0.1",
    "eslint-plugin-vue": "^4.0.0",
    "file-loader": "^1.1.4",
    "jest": "^22.4.4",
    "jest-serializer-vue": "^0.3.0",
    "lint-staged": "^8.1.5",
    "pa11y": "^5.2.0",
    "pa11y-ci": "^2.3.0",
    "sinon": "^7.4.2",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "vue-jest": "^1.4.0",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^4.25.1",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.2.2"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,vue}": [
      "vue-cli-service lint",
      "git add"
    ]
  }
}

Конфигурация Babel: .babelrc

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-vue-jsx", "transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "@babel/preset-stage-2"],
      "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
    }
  }
}

jest.config.js

module.exports = {
  moduleFileExtensions: [
    'js',
    'jsx',
    'json',
    'vue'
  ],
  transform: {
    '^.+\\.vue$': '<rootDir>/node_modules/vue-jest',
    '^.+\\.jsx?$': 'babel-jest'
  },
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1'
  },
  snapshotSerializers: [
    'jest-serializer-vue'
  ],
  setupFiles: ['<rootDir>/tests/jest-setup'],
  testMatch: [
    '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
  ],
  mapCoverage: true,
  testURL: 'http://localhost/'
}

Может кто-нибудь помочь мне с решением?Похоже, проблема с версией Babel.Это происходит после того, как я обновляю свою бабел шутку

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...