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

Move all @types CLI dependencies from prod to dev list #3371

Closed
bahmutov opened this issue Feb 7, 2019 · 8 comments · Fixed by #3425
Closed

Move all @types CLI dependencies from prod to dev list #3371

bahmutov opened this issue Feb 7, 2019 · 8 comments · Fixed by #3425
Assignees
Labels
process: build Related to our internal build process topic: typescript type: chore Work is required w/ no deliverable to end user

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Feb 7, 2019

Problem

When we ship Cypress NPM package we include several @types prod dependencies because we want to reference them in our types index.d.ts file.

in cli/package.json

{
  "dependencies": {
    "@types/blob-util": "1.3.3",
    "@types/bluebird": "3.5.18",
    "@types/chai": "4.0.8",
    "@types/chai-jquery": "1.1.35",
    "@types/jquery": "3.3.6",
    "@types/lodash": "4.14.87",
    "@types/minimatch": "3.0.3",
    "@types/mocha": "2.2.44",
    "@types/sinon": "7.0.0",
    "@types/sinon-chai": "3.2.2"
  }
}

and in our index.d.ts file we reference these dependencies (and a few local files)

/// <reference path="./blob-util.d.ts" />
/// <reference path="./bluebird.d.ts" />
/// <reference path="./minimatch.d.ts" />
/// <reference path="./moment.d.ts" />

/// <reference types="chai" />
/// <reference types="chai-jquery" />
/// <reference types="jquery" />
/// <reference types="lodash" />
/// <reference types="mocha" />
/// <reference types="moment" />
/// <reference types="sinon" />
/// <reference types="sinon-chai" />

We need these type files because they provide types and documentation for things like Lodash Cypress._ object, but there are a couple of problems

  1. We have duplicates: for example, we depend on @types/blob-util but also have a local file blob-util.d.ts
  2. type dependencies in prod can conflict with user's type dependencies, which seems to the issue in Cypress breaks webpack compiling when installed as an npm package #1227
  3. usually @types is considered a dev dependency, should not be prod

Proposal

We can move all necessary @types packages from dev to prod dependencies. During building we can copy any necessary files and include them with our CLI code, just like we do for types/blob-util.d.ts

Our distributed index.d.ts thus will only refer to local paths to bring it all together, and all conflicts with the user's @types would be avoided (fingers crossed)

@cypress-bot cypress-bot bot added the stage: needs information Not enough info to reproduce the issue label Feb 7, 2019
@bahmutov bahmutov self-assigned this Feb 7, 2019
@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: needs information Not enough info to reproduce the issue labels Feb 7, 2019
@jennifer-shehane jennifer-shehane added the type: chore Work is required w/ no deliverable to end user label Feb 7, 2019
@bahmutov bahmutov added the process: build Related to our internal build process label Feb 7, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Feb 11, 2019
@jcreamer898
Copy link

It would be great to get this merged. We're seeing very similar issues in our mono-repo where we use Jest already. Simply installing cypress causes all kinds of mayhem...

Would be glad to help test new releases after this is merged!

@jennifer-shehane
Copy link
Member

@jcreamer898 Thanks! Feel free to pull down this branch and try it out also #3425

@jcreamer898
Copy link

Oh sweet, will do.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Mar 5, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 5, 2019

The code for this is done in cypress-io/cypress#3425, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@avahe-kellenberger
Copy link

According to the proposal, was cypress not intended to install types packages in node_modules/@types?
I saw this which seemed to suggest otherwise, and having @types/chai-jquery installed from cypress is causing conflicts with other types in my project

@bahmutov
Copy link
Contributor Author

bahmutov commented Mar 8, 2019

@avahe-kellenberger I am not sure what you are referring to. The CLI package still installs these packages as dev dependencies in this repository, but when it builds NPM package for Cypress users then it will NOT install them. Thus they will no longer conflict with your types. This has been merged into develop branch but has not been released yet.

@avahe-kellenberger
Copy link

Oh, I missed that it hasn't been released - Thanks for the info.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 15, 2019

Released in 3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process: build Related to our internal build process topic: typescript type: chore Work is required w/ no deliverable to end user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants