mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.85k stars 515 forks source link

Install mws without graphql #1166

Closed Flui closed 2 years ago

Flui commented 2 years ago

Scope

Adds a new behavior

Compatibility

Feature description

Is your feature request related to a problem? Please describe.

Currently I am working on an Project with react-scripts@4.0.3 and typescript@3.8.3. After installing latest version of msw I get the following typescript error: "Package 'graphql' support only TS versions that are >=4.1.0" As I am consuming a rest api via fetch, there is no need for me here to even install graphql.

Describe the solution you'd like

So I would like to install msw with the minimal required dependencies to use it for rest apis.

Describe alternatives you've considered

If somebody has a workaround without updating typescript I would appreciate that as well.

kettanaito commented 2 years ago

Hey, @Flui.

While I understand your concern, MSW is a devtool, and its dependencies are bound to the goals it accomplishes. I understand you may not use GraphQL mocking in your project. Yet the price you pay for installing an extra package is rather small.

In a similar fashion, we're installing packages to manage cookies, which you may not mock. There's no agreed way to modularize libraries in Node.js, so you will end up installing more than you may potentially use and it's fine.

If you get a warning from a tool you're not using, you can just ignore that warning. The one you're getting is interesting though, because it suggests you're using TypeScript < 4.1.0. MSW requires TypeScript 4.3 to run, so you have to update TypeScript if you want to use MSW without issues.

We are working on communicating the required TypeScript version more clearly in #985.