modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.21k stars 281 forks source link

fix(storybook-builder): fix providerImportSource extension when using @storybook/addon-essentials #2703

Closed bashmish closed 5 months ago

bashmish commented 5 months ago

What I did

  1. Fixed issue when an MDX file is compiled with a wrong module path ("./../../../node_modules/@storybook/addon-docs/dist/shims/mdx-react-shim") without an extension, which is coming from @storybook/addon-essentials https://github.com/storybookjs/storybook/blob/v7.6.17/code/addons/essentials/src/docs/preset.ts#L10
/*@jsxRuntime automatic @jsxImportSource react*/
import {Fragment as _Fragment, jsxDEV as _jsxDEV} from "./../../../node_modules/.prebundled_modules/react/jsx-dev-runtime.mjs";

import {
  useMDXComponents as _provideComponents
} from "./../../../node_modules/@storybook/addon-docs/dist/shims/mdx-react-shim"; // this is a bug

function _createMdxContent(props) {
  const _components = Object.assign({
    h1: "h1",
    p: "p",
    code: "code",
    pre: "pre"
  }, _provideComponents(), props.components);

I didn't catch this bug here, because wds-outside-root happens to add an extension when I run tests in a monorepo. But it doesn't happen in simple repos where wds-outside-root is not used. Not sure how to improve tests in such a way that it happens here, the risk is if I do more like in a simple repo, then the monorepo setup won't be tested. So I'll keep things as is, especially given it's such a weird and rare bug.

I'll try to fix it in the Storybook too, but it takes time, older version should work too since we start to migraate users and I'm not sure it's gonna be backported to Storybook 7 which we need to support for now: https://github.com/storybookjs/storybook/pull/26868

changeset-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: 7b1106447ff5b1756e5c1a20f7b55b5d8339fa0d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------------- | ----- | | @web/storybook-builder | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR