mswjs / msw

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

fix: keep `graphql` import as require in cjs #2258

Closed kettanaito closed 2 months ago

kettanaito commented 2 months ago

Build results

// parseGraphQLRequest.js
async function parseQuery(query) {
  const { parse } = require("graphql");
// parseGraphQLRequest.mjs
async function parseQuery(query) {
  const { parse } = await import("graphql").catch((error) => {
    console.error('[MSW] Failed to parse a GraphQL query: cannot import the "graphql" module. Please make sure you install it if you wish to intercept GraphQL requests. See the original import error below.');
    throw error;
  });
kettanaito commented 2 months ago

Released: v2.4.2 🎉

This has been released in v2.4.2!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.