Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test "decorator" throw "The 'decorators' plugin requires a 'decoratorsBeforeExport' option" #17

Closed
467057463 opened this issue Oct 26, 2018 · 3 comments

Comments

@467057463
Copy link

hello everyone, in the first thank of your work!
when i run yarn test
then throw below error

The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'.

  at validatePlugins (node_modules/@babel/parser/lib/index.js:10472:13)
  at getParser (node_modules/@babel/parser/lib/index.js:10529:5)
  at parse (node_modules/@babel/parser/lib/index.js:10513:12)

there is my config-overrides.js

const rewireMobX = require('react-app-rewire-mobx');
const rewireSass = require('react-app-rewire-scss');

module.exports = function override(config, env) {
  config = rewireMobX(config, env);
  config = rewireSass(config, env);
  return config;
}

const { override, addDecoratorsLegacy, disableEsLint } = require("customize-cra");

module.exports = override(
  addDecoratorsLegacy(),
  disableEsLint()
);

and there is my package.json

{
  "name": "react-blog",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "mobx": "^5.5.2",
    "mobx-react": "^5.3.5",
    "react": "^16.6.0",
    "react-app-rewire-mobx": "^1.0.9",
    "react-dom": "^16.6.0",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.0.5"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.1.0",
    "@babel/plugin-proposal-decorators": "^7.1.2",
    "customize-cra": "^0.1.1",
    "react-app-rewire-scss": "^1.0.2",
    "react-app-rewired": "^1.6.2"
  }
}

at last this error only throw in run yarn test(when run yarn start will be OK)

@arackaf
Copy link
Owner

arackaf commented Oct 29, 2018

Hm not sure. Your first code snippet has two assignments to module.exports = . That seems wrong, but I'm not sure if that's your problem.

Otherwise, really not sure what the problem is - sorry!

@arackaf arackaf closed this as completed Oct 29, 2018
@arackaf
Copy link
Owner

arackaf commented Oct 29, 2018

Actually - this code

const rewireMobX = require('react-app-rewire-mobx');
const rewireSass = require('react-app-rewire-scss');

module.exports = function override(config, env) {
  config = rewireMobX(config, env);
  config = rewireSass(config, env);
  return config;
}

seems like it's for CRA 1 - I'd recommend just getting rid of it.

@467057463
Copy link
Author

467057463 commented Oct 29, 2018

@arackaf thank you a lot,
i remove CRA 1 config

there is my new config-overrides.js

const { override, addDecoratorsLegacy, disableEsLint } = require("customize-cra");

module.exports = override(
  addDecoratorsLegacy(),
  disableEsLint()
)

The same error as above( yarn test throw error)

I am new to react, i am not suer about is the configuration problem, or other
Can you share your 'config-overrides.js' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants