Comments (13)
Thank you, this did solve my problem. I originally planned to use mobx directly without using the decorator.
from craco.
Hi @Strnadj
Have you tried this recipe? https://github.com/sharegate/craco/tree/master/recipes/use-mobx
from craco.
Yes, we have tried that, but it fails with the error message above.
from craco.
There is a few options for the babel decorator plugin: https://babeljs.io/docs/en/next/babel-plugin-proposal-decorators.htm
Have you tryed without the legacy
option?
module.exports = {
babel: {
plugins: [
["@babel/plugin-proposal-decorators"]
]
}
};
from craco.
Ok, if I delete that:
Error: [BABEL] /Users/strnadj/Projects/test/node_modules/react-dev-utils/webpackHotDevClient.js: The decorators plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you want to use the legacy decorators semantics, you can set the 'legacy: true' option. (While processing: "/Users/strnadj/Projects/test/node_modules/@babel/plugin-proposal-decorators/lib/index.js")
at Array.reduce (<anonymous>)
so I have change that to:
module.exports = {
babel: {
plugins: [
["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true } ],
]
}
};
and error:
Failed to compile.
./src/index.tsx
Error: Cannot use the decorators and decorators-legacy plugin together
from craco.
I tryed it on my side and it works fine.
Is there something else in your setup that add the decorators-legacy
plugin?
from craco.
https://github.com/Strnadj/not_working_cra there is repository, what cames in my mind... it seems to "@babel/plugin-proposal-decorators" is not ready yet for @babel 7.1..
warning "@babel/plugin-proposal-decorators > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
not sure if it is a problem, but I was not able to find react-scripts version with @babel 7.0 in dependencies.
from craco.
Maybe it's the problem, if it's the case you should open an issue in the @babel/plugin-proposal-decorators
repository.
For this issue, it doesn't seem to be a problem with craco
.
If you find the right webpack
recipe for inversify
i'll be glad to help you to make it work with CRA
+ craco
.
I will leave the issue open for a few days in case someone have a solution for you.
from craco.
Hi @patricklafrance
I use config
module.exports = {
babel: {
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }]
]
}
};
and it work in craco start and craco build
but when I run craco test
It failed with error
Support for the experimental syntax 'decorators-legacy' isn't currently enabled
What should I change config to fit CRX test ?
from craco.
Hi @duyucongc
It works fine in my sandbox.
My version of the following packages version are:
@babel/[email protected]
@babel/[email protected]
@craco/[email protected]
@[email protected]
With the following craco.config.js file
const path = require("path");
const ConfigWebpackPlugin = require("config-webpack");
const { ESLINT_MODES, POSTCSS_MODES, paths } = require("@craco/craco");
const CSS_MODULE_LOCAL_IDENT_NAME = "[local]___[hash:base64:5]";
module.exports = {
style: {
modules: {
localIdentName: CSS_MODULE_LOCAL_IDENT_NAME
},
css: {
loaderOptions: {
includePaths: ["/css-utils"]
}
},
sass: {
loaderOptions: {
includePaths: ["/sass-utils"]
}
},
postcss: {
mode: POSTCSS_MODES.file
}
},
eslint: {
mode: ESLINT_MODES.file
},
webpack: {
alias: {
"@components": path.resolve(__dirname, `${paths.appSrc}/components/`)
},
plugins: [new ConfigWebpackPlugin()]
},
babel: {
plugins: [
"babel-plugin-jsx-control-statements",
"babel-plugin-react-require",
["babel-plugin-react-css-modules", { generateScopedName: CSS_MODULE_LOCAL_IDENT_NAME, attributeNames: { "activeStyleName": "activeClassName" } }],
["@babel/plugin-proposal-decorators", { legacy: true }]
],
},
jest: {
configure: {
globals: {
"CONFIG": true
},
moduleNameMapper: {
"^@components(.*)$": "<rootDir>/src/components$1"
}
}
},
plugins: [
{
plugin: {
overrideJestConfig: ({ jestConfig }) => {
console.log(JSON.stringify(jestConfig, null, 4));
return jestConfig;
}
}
}
]
};
from craco.
@duyucongc https://www.npmjs.com/package/@craco/craco/v/3.2.2 should fix your problem .
from craco.
I will close this issue since there isn't any new comments for 7 days
from craco.
@patricklafrance thank you it did work for me
from craco.
Related Issues (20)
- Setting SASS quietDeps to true not working HOT 1
- `webpack`: TypeError: Cannot read properties of undefined (reading 'toString') HOT 1
- Add more unit and integration tests
- Craco start failed with `compiler.plugin is not a function` HOT 1
- craco changes the output content of the package file to package the original configuration file and own custom folder
- jest coverage options not used
- run craco start/build, it will exec twice craco.config.js HOT 1
- Development Server not Starting (craco start) HOT 2
- Change webpackConfig.entry as object, it build failed HOT 2
- CRACO build failes because of React Refresh Babel HOT 3
- I hope that the documentation can give an example of typescript configuration.
- Unable to build with Craco 7 due to attempted import error in React library
- Selectively suppress webpack runtime errors? HOT 1
- How can I import a hbs file as a string?
- Suport aliases in npx uninmported
- Depend on babel-jest HOT 3
- CRACO with linaria
- When I use babel to import other project's component, Unexpected behavior occur
- Existing jest tests are failing with upgrade to craco major version 7
- TypeError: Cannot read properties of undefined (reading 'D:\projects\my-project\frontend\craco.config.js')
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craco.