msw: Cannot resolve `debug` on yarn 2.x.x

Describe the bug

Yarn cannot resolve ‘debug’ of msw

✖ 「wdm」: ERROR in ../../.yarn/unplugged/msw-npm-0.33.3-7287fb2021/node_modules/msw/lib/esm/index.js 10:0-31
Module not found: Error: Can't resolve 'debug' in '/Users/a202006041/workspace/toolbox/.yarn/unplugged/msw-npm-0.33.3-7287fb2021/node_modules/msw/lib/esm'
 @ ./src/mock/worker.ts 4:0-40 5:12-21 9:20-37
 @ ./src/mock/index.ts 38:19-37
 @ ./src/index.tsx 10:0-41 12:0-15

Environment

  • msw: 0.29.0
  • nodejs: 14.16.1
  • npm: 6.14.12
  • yarn: 2.4.2
  • webpack: 5.24.3

Please also provide your browser version.

To Reproduce

Steps to reproduce the behavior:

  1. Install msw@0.29.0 above.
  2. Run msw using webpack on yarn@2.x.x above

Expected behavior

When i tried with msw@0.28.2 and yarn@1.x.x each, It was ok. I think module resolver cannot resolve pnp module that debug of msw external.

Additional Information

I tried to install debug and config it to peer dependency on .yarnrc.yml. And then it works.

I did not use rollup well. I think msw should have debug to peer dependency.

// package.json
{
  ...
  devDependencies: {
    ...
    "debug": "^4.3.2",
    "msw": "^0.33.3",
  }
  ...
}

// .yarnrc.yml

packageExtensions:
  'msw@*':
    peerDependencies:
      'debug': '*'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (13 by maintainers)

Most upvoted comments

You’ve raised a valid point, @patrickmcdougle-okta, that some of the dependencies should be treated as external. That’d help with bug-fixes propagation and make the dependency tree more transparent.

As for the other dependencies, I believe some must be bundled. It’d be nice to review the entire dependency tree and decide the pain points to fix. Contributions are always welcome!