Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Conversation

@larrifax
Copy link
Contributor

  • I moved the packages I deemed "safe to move" to devDependencies.
  • I guess the packages used by the plugins cannot be moved.
    I therefore added their peerDependencies to dependencies, and supplied of them in peerDependencies so that package managers will prefer the versions that consumers has installed.

Fixes #442

package.json Outdated
"framer-motion": "2.6.13",
"i18next": "19.7.0",
"mime-types": "2.1.26",
"next": "^9.5.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok really it's my fault. next should also be a devDependency the same for all babel stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking that they should be devDependencies, but then I thought that would break consumers trying to use one of the plugins, e.g. cypress-react-unit-test/plugins/next. I guess it will only break them if they haven't installed next by any other means though. So this might not be a problem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's not a problem, next should be an optional peerDependecy and installed only for us as devDependency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving next to dependencies + peerDependencies seems to be ok, as we can assume that consumers of plugins/next already have next in their own dependencies.

Moving the following dependencies used by plugins/* may not be ok, as not everyone is installing those themselves:

 "@babel/plugin-transform-modules-commonjs": "7.10.4", "@cypress/webpack-preprocessor": "5.4.5", "babel-plugin-istanbul": "6.0.0", "find-webpack": "2.1.0", "mime-types": "2.1.26",` 

Since @cypress/webpack-preprocessor lists the following as peerDependencies, I have to add them to either our dependencies or peerDependencies in order for Yarn 2 to be happy:

 "@babel/core": "^7.0.1", "@babel/preset-env": "^7.0.0", "babel-loader": "^8.0.2", "webpack": "^4.18.1" 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the top list has to be in the prod dependencies - since this is what we use to find webpack and instrument code, etc. But the bottom list with babel/core, babel/preset-env, babel-loader, and webpack I think we expect to find these dependencies. What's your situation for using cypress-react-unit-test ? Does Yarn complain that webpack is not listed for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bahmutov Not including the bottom list in dependencies gives the following warnings using Yarn 2:

➤ YN0002: │ cypress-react-unit-test@npm:4.14.1 doesn't provide @babel/core@^7.0.0-0 requested by @babel/plugin-transform-modules-commonjs@npm:7.10.4 ➤ YN0002: │ cypress-react-unit-test@npm:4.14.1 doesn't provide @babel/core@^7.0.1 requested by @cypress/webpack-preprocessor@npm:5.4.5 ➤ YN0002: │ cypress-react-unit-test@npm:4.14.1 doesn't provide @babel/preset-env@^7.0.0 requested by @cypress/webpack-preprocessor@npm:5.4.5 ➤ YN0002: │ cypress-react-unit-test@npm:4.14.1 doesn't provide babel-loader@^8.0.2 requested by @cypress/webpack-preprocessor@npm:5.4.5 ➤ YN0002: │ cypress-react-unit-test@npm:4.14.1 doesn't provide webpack@^4.18.1 requested by @cypress/webpack-preprocessor@npm:5.4.5 

If I'm not mistaken, yarn 2 in PnP mode with the default settings will deny require()-calls from cypress-react-unit-test to the above mentioned packages, unless the warnings are fixed.

We can resolve this by putting them in both devDependencies (using the versions you need) and in peerDependencies while also making them optional by specifying them in peerDependenciesMeta.

I'll push a new version with the suggested changes.

package.json Outdated
"url": "https://github.com/bahmutov/cypress-react-unit-test.git"
},
"dependencies": {
"@babel/core": "7.4.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we include babel and babel-loader as prod dependencies? I assume the React project has them.

"@babel/plugin-transform-modules-commonjs": "7.10.4",
"@cypress/code-coverage": "3.8.1",
"@cypress/webpack-preprocessor": "5.4.5",
"@mdx-js/loader": "^1.6.16",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with next and framer-motion and i18next - these are all for our examples, thus should be dev dependencies

package.json Outdated
"react-i18next": "11.7.2",
"unfetch": "4.1.0"
"unfetch": "4.1.0",
"webpack": "4.44.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disagree about webpack - it should be found in the user's project

package.json Outdated
},
"peerDependencies": {
"cypress": "*",
"next": "*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this will complain about next not found for every project?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put webpack here instead

@dmtrKovalenko
Copy link
Contributor

@larrifax please allow changes from maintainers. I cannot push to your branch using gh pr checkout.

Suggested versions range

 "peerDependencies": { "cypress": "*", "@babel/core": "^=7.x", "@babel/preset-env": "^=7.x", "babel-loader": "^=8.x", "next": "^=8.x", "react": "^=16.x", "react-dom": "^=16.x", "webpack": "^=3.x" },
These packages are peerDependencies of some of the listed dependencies, which means that we have to provide them in our dependencies as well.
…ional peerDependencies This gets rid of the warnings when installing the library into a project using Yarn 2
@larrifax
Copy link
Contributor Author

@larrifax please allow changes from maintainers. I cannot push to your branch using gh pr checkout.

Suggested versions range

 "peerDependencies": { "cypress": "*", "@babel/core": "^=7.x", "@babel/preset-env": "^=7.x", "babel-loader": "^=8.x", "next": "^=8.x", "react": "^=16.x", "react-dom": "^=16.x", "webpack": "^=3.x" },

The Allow edits by maintainers-checkbox was already on. I assume it should have worked then?
Anyway, I added the ranges you suggested and rebased.

Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, looks really good

@bahmutov bahmutov changed the title Fix warnings during yarn install (Yarn 2) fix: move dev dependencies, and specify peer dependencies Sep 24, 2020
@bahmutov bahmutov merged commit 2a0b799 into cypress-io:main Sep 24, 2020
@bahmutov
Copy link
Contributor

🎉 This PR is included in version 4.14.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3 participants