literalpie / storybook-framework-qwik

Add Qwik support to storybook
28 stars 6 forks source link

MDX/docs #17

Closed literalpie closed 1 year ago

literalpie commented 1 year ago

I get this error if MDX is included in the storybook configuration (which it is by default)

10:41:05 AM [vite] Internal server error: Cannot read properties of undefined (reading 'length')
      at memoizedBinarySearch (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:9948:25)
      at traceSegmentInternal (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:10055:17)
      at originalPositionFor$1 (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:10041:23)
      at formatError (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:40037:54)
      at TransformContext.error (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:39971:19)
      at Object.transform (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:40231:25)
      at async loadAndTransform (file:///Users/benjaminkindle/Documents/dev/temp/open-standup/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:36615:29) (x2)
literalpie commented 1 year ago

The cause of this is that QwikCity and Storybook both try to do things to MDX.

as a stop-gap, I think I'll go with the first approach. I'd rather have docs working even if it means overwriting config.

Even once I got docs working with that workaround, I don't understand storybook docs. I need to learn more about how it's supposed to work.

One important thing to know is that storybook doesn't even try to support other frameworks in the stories mdx files. The only way to run Qwik components in story mdx files will be through stories (or making our own React wrappers for qwik components.)

literalpie commented 1 year ago

See the linked commit. I was able to find a solution a little more fine-grained than the comment above suggests. I only take out the transform part of the Vite plugin, which is where only md/mdx transformation stuff is. I think this is a pretty good solution without compromise (user-defined non-mdx config still happens)