-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addon Docs not compiling MDX #9598
Comments
Seeing this on build also after the latest update. |
Not seeing this in our monorepo. Can somebody provide a public repro? |
@shilman https://github.com/UnitedIncome/components/tree/storybook-upgrade You'll see the error after running |
Facing the same issue
|
@JamesIves - do you have mdx-loader, I believe by default the docs preset only uses the mdx-loader for .stories.mdx
|
overall, this error should happen because the mdx-loader is not applied - either a webpack configuration file that is not found by storybook (wrong name?) or the name of the mdx files does not comply with the docs preset filter. |
@atanasster I have tried both ways. One by adding the preset and one adding webpack config that matches for .mdx file and mdx loader but still the same issue. |
@vivek12345 ok. I will take a look at your repo |
It seemed to work for |
By default the preset looks for It seems like the issue is something else. I have the presets and |
@JamesIves Also the docs preset is not framework specific in the newer versions - addon-docs/preset instead of addon/docs/react/preset |
Here is my webpack config which I get when I did
|
@atanasster did you get a chance to look into the repo and can you point me in a direction so that I can get it working. |
@vivek12345 , sorry havent looked yet. Will post here |
@vivek12345 - it was the dreaded mdx-js empty space bug. In your mdx story - you have an empty space on an empty line - basically you have to remove any white specs from empty line. Lots of fun .... I took the opportunity to also upgrade your project to the new storybook config files. |
Oh damn that was a crazy bug. Thank you so much @atanasster. Wondering is it documented somewhere that the empty space causes an issue for mdx-js? |
Also I am wondering why did prettier not remove that whitespace? |
Glad to see you unstuck @vivek12345 Not sure if its documented on storybook site. I had filed an issue about it couple of months ago on the mdx-js site. |
Prettier - not sure, you have the vscode fix on save setting? |
I do have it. For some reason it did not remove the whitespace in the mdx doc |
Cool - one down, a few more to go :) |
@JamesIves - same for you, can you please try both the config above and also remove empty spaces and let-us know. Sorry, Its a really annoying issue, just want to make sure what you guys are facing here |
Thanks @atanasster 🙏 |
Will do! I'll report back Monday when I'm in the office. |
Yup I think that fixed it too. I rewrote all my stories and that seemed to fix it. Thanks for the help everyone. |
I've added the mdx-loader, but I'm now seeing the following On build:
After build in the story preview:
Is there some issue with how our mdx files are setup that doesn't play nicely with this new version? https://github.com/UnitedIncome/components/tree/storybook-upgrade/components/organisms-complex/BoxSelectCard |
@JamesIves - |
@JamesIves also make sure to addd a
|
Tried changing the reference in the The |
@JamesIves - nothing comes to my mind off the top of my head. |
We probably need to update the recipe based on what we learn from your use case. @JamesIves you are correct: only use The primary difference between The other key difference is that that the compiler adds snippet of wrapper code around the MDX content: It's possible that you're using a doc block that relies either NOTE: I also see some whitespace in your .mdx file, which I would expect might cause problems: |
Thank you @atanasster ! I was also having issues with the Unexpected token syntax error on line 1 and fixed it by removing line breaks if anyone didn't find any empty spaces and is still having trouble! |
Trimming all white spaces worked for me as well. For those of you that use VS Code, there is a setting to do this for you. In Preferences > Settings search for : |
Make sure Meta/other is free of any semicolons: wrong!
<Meta title="Lab/CopyToClipboard" component={CopyToClipboard} />; ok!
<Meta title="Lab/CopyToClipboard" component={CopyToClipboard} /> |
Also make sure that no self-closing component is left unclosed incorrect!
export const Template = (props) => <SomeComponent {...props} >; correct!
export const Template = (props) => <SomeComponent {...props} />; |
Describe the bug
Addon Docs is not compiling MDX
Module build failed (from ./node_modules/@mdx-js/loader/index.js):
SyntaxError: Unexpected character '#' (3:0)
at Object.raise
main.js
Button.stories.js
Button.stories.mdx
System:
Additional context
The Docs tab on each component is working. However this error comes as soon as I add an MDX file.
The text was updated successfully, but these errors were encountered: