mswjs / msw-storybook-addon

Mock API requests in Storybook with Mock Service Worker.
https://msw-sb.vercel.app
MIT License
408 stars 39 forks source link

feat!(msw-addon): fix package exports and generate esm build #138

Closed ChristianMurphy closed 9 months ago

ChristianMurphy commented 9 months ago

this updates conditional exports so that both types and dependencies can be resolved. this also migrates build to generating esm by default for a more standards based packaging approach with strong support in modern tooling like webpack and vite.

resolves #137

This draws from https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution-for-libraries which recommends node16 resolution for libraries, which has the strictest resolution rules, which should work for almost all downstream adopters.

Follows similar ESM conventions to https://github.com/sindresorhus/meta/discussions/15 There are still a few quirks in legacy build tools (mostly webpack 4) https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c those generally should not impact storybook builds

📦 Published PR as canary version: 1.10.1--canary.138.7ca8425.0
:sparkles: Test out this PR locally via: ```bash npm install msw-storybook-addon@1.10.1--canary.138.7ca8425.0 # or yarn add msw-storybook-addon@1.10.1--canary.138.7ca8425.0 ```
vercel[bot] commented 9 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
msw-storybook-addon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2024 7:38pm
yannbf commented 9 months ago

Thanks a lot @ChristianMurphy! Let's update the beta and get feedback from the users with these changes