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

Duplicated packages webpack, css-loader, style-loader #4

Closed
yp opened this issue Dec 14, 2018 · 4 comments
Closed

Duplicated packages webpack, css-loader, style-loader #4

yp opened this issue Dec 14, 2018 · 4 comments

Comments

@yp
Copy link

yp commented Dec 14, 2018

If I install craco-less (either with yarn or npm, then a duplicated version of webpack, css-loader, and style-loader is installed, since the craco-less depends on them but with a different version range than react-scripts.
(I am aware that this is somehow related to #3.)
While apparently it did not cause any bug, I wonder if this could not be a source of obscure bugs in the future.
Are those dependencies only needed to "silence" the warnings reported on StackOverflow? If this is the case, can you consider to drop them?

@ndbroadbent
Copy link
Member

Yes, these dependencies are just to silence the npm/yarn warnings.

I think I didn't realize that css-loader and style-loader were already dependencies of react-scripts, so it makes sense to remove those. After that, the only warning is:

warning " > [email protected]" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".

I've left a comment on a yarn issue. For now I'm just going to leave the webpack dependency, and it shouldn't cause any issues.

@ndbroadbent
Copy link
Member

Hi again, thanks for opening this issue! I've decided to remove css-loader and style-loader from the dependencies. I've kept the webpack dependency, but I've pinned this to the same version as react-scripts, and I've added a script to automate this. So whenever react-scripts changes their webpack version, I'll just run this script to use the same webpack version, and release a new version of craco-less.

I really hate warnings and this seemed to be the only way to fix it, so I think it's a good workaround for now.

@yp
Copy link
Author

yp commented Dec 14, 2018

Thanks for the quick fix (even if it was not causing any real problem).
Do you mind to consider to move craco as a peerDependency? Since it is a plugin for it, I think that it should specified as such (see, for example, the yarn recommendations).

@ndbroadbent
Copy link
Member

ndbroadbent commented Dec 14, 2018

Oh right, yes that's a good idea! I think react-scripts should also be a peerDependency, because that will already be in the app's package.json.

The only problem is that this breaks the tests, because peer dependencies are not installed when you run yarn install in the craco-less repo. So I guess I also need to add them as devDependencies. A bit weird to include them in two places, but I think that's the right way to do it for now. It doesn't look like it's possible to install peerDependencies locally, and I found this issue in the yarn repo.

I also had to do that for the craco-antd package, which depends on craco-less. (Adding @craco/craco and react-scripts to both devDependencies and peerDependencies.)

So this seems to work pretty well and doesn't show any warnings. Thanks!

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