Open qballer opened 4 years ago
just checked, "@types/react", "@types/react-dom" as dependencies breaks my project. Please force it to be peerDep.
I just found out my project has a direct dependency on React, reflecting this problem to me would have been much more useful than silently correcting my project
@qballer Just that you know, currently without implementation, a peer is the strongest one. so in case you just return something from the compiler as a peer, it will be peer even if the component declare it as regular / dev. so you kind of already have the force to peer. It's not a complete solution since you have to validate the version yourself, and validate it exists yourself, instead of bit validating it and move it to peer if that exists. but it might used as a temporary solution.
Seems to be working ok, but I still need to override the version of dependencies.
When tagging a component, the react-typescript compiler automatically adds react
and react-dom
as peer dependencies.
That is nice and dandy, but it locks version "^16.9.4" and does not allow overriding.
When I install my component in an old project, I get this error:
"@bit/bit.marketing.theme.theme-provider > @bit/bit.marketing.theme.size-definitionmodule@0.0.2"
has incorrect peer dependency "@types/react-dom@16.9.4".
and well, since I am making a lot of components, I get this error a lot.
I tried overriding it like so, but it does not seem to have any effect:
"*": {
"dependencies": {
"react": "-",
"react-dom": "-"
},
"devDependencies": {
"react": "-",
"react-dom": "-",
"chai": "^4.2.0",
"eslint-plugin-chai-friendly": "^0.5.0",
"sinon": "^8.1.1",
"@types/chai": "^4.2.8",
"@types/sinon": "^7.5.1",
"@types/mocha": "^7.0.1"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
"react-dom": "-",
"@types/react": "^15.0.0 || ^16.0.0",
"@types/react-dom": "-"
}
}
bit.envs/compilers/react-typescript@3.1.43
(with CJS override)
Description
If we take the example of a react component. There is a question of to which of the dependency types the react should actually be. Most conventional wisdom says that react should be a peer dependency but bit while detecting a dependency has no way of knowing that. This mean that react would be a regular dependency. When building a component a compiler should adjust the component dependency to the best practice.
Describe the solution you'd like
Typescript compiler should be to force a dependency to a specific type: peer, dev, regular. Default configuration
Describe alternatives you've considered
Let users to configure this by himself using overrides.
related to #36