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

[2.0.2] peerDependency warning with the new release #703

Closed
2 tasks done
AviVahl opened this issue Jan 24, 2022 · 4 comments · Fixed by #707
Closed
2 tasks done

[2.0.2] peerDependency warning with the new release #703

AviVahl opened this issue Jan 24, 2022 · 4 comments · Fixed by #707

Comments

@AviVahl
Copy link

AviVahl commented Jan 24, 2022

Checks

Describe the bug (be clear and concise)

Latest version requires @types/express as a peerDependency, printing warnings for non-typescript projects as well.

Step-by-step reproduction instructions

mkdir testproxy
cd testproxy
yarn init -y
yarn add http-proxy-middleware

see message:
`warning " > http-proxy-middleware@2.0.2" has unmet peer dependency "@types/express@^4.17.13".`

Expected behavior (be clear and concise)

No warnings when installing package. Don't require users to install @types packages as if everyone is using typescript.

How is http-proxy-middleware used in your project?

via `webpack-dev-server`, like half the web.

What http-proxy-middleware configuration are you using?

Irrelevant

What OS/version and node/version are you seeing the problem?

Fedora 35; Node 16.13.2; yarn 1.22.17

Additional context (optional)

Regressed by #700

@chimurai
Copy link
Owner

chimurai commented Jan 24, 2022

Hi thanks for your report.

Those types provide a better developer experience in your IDE with autocompletion; Also in non-typescript projects.
With @types/express you'll get autocompletion of express' req and res objects, which was broken as reported here: #692

Perhaps the yarn warning can suppressed by marking as optional:

  "peerDependenciesMeta": {
    "@types/express": {
      "optional": true
    }
  },

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependenciesmeta

Marking a peer dependency as optional ensures npm will not emit a warning if the @types/express package is not installed on the host. This allows you to integrate and interact with a variety of host packages without requiring all of them to be installed.

I have to double check if this will solve the issue.

@AviVahl
Copy link
Author

AviVahl commented Jan 25, 2022

Specifying the peerDependenciesMeta field would indeed solve the warning, AFAIK.

@aholtkamp
Copy link

We are utilizing "http-proxy-middleware" (and "express") in a custom package which is meant to be used by other packages. It only provides a command in its package.json ("bin") which can be executed (no "js" / "typescript" coding involved).

Since the last change we now get the warning for every usage of our custom package. Does it really make sense to require adding "@types/express" to every usage of our package to resolve the warning? Seems contra intuitive to me. We could add "@types/express" to the normal dependencies of our custom package to avoid the warning but this feels weird as types are usually added as "devDependency"...

In addition to this I think it is not the job of "http-proxy-middleware" to enforce / require adding "@types/express". If it is anyones job "express" should do that (but I wouldn't encourage that either)...

Can you please revert this change?

@chimurai
Copy link
Owner

chimurai commented Feb 7, 2022

fixed in v2.0.3

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

Successfully merging a pull request may close this issue.

3 participants