msw-storybook-addon icon indicating copy to clipboard operation
msw-storybook-addon copied to clipboard

Breaks on building Storybook

Open XiNiHa opened this issue 6 months ago • 15 comments

While building the Storybook, the bundler (Vite) emits an error like this:

[commonjs--resolver] No known conditions for "./native" specifier in "msw" package

This is because of the code here. While it'll work without any problem when not built, this will break on browser builds because...

  • The bundler doesn't know whether IS_REACT_NATIVE is true or false at build time, therefore it should try to bundle both versions.
  • However, since the bundler is building for browsers and that enables the browser export condition, the entry resolves to null and it errors.

This problem should be fixed by adding separate entries for each browser and native.

XiNiHa avatar Dec 18 '23 20:12 XiNiHa