-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Module not found: Error: Can't resolve mdx file #13144
Comments
Do you have a repro repo you can share? If not can you share main.js file? |
this is my main.js file const merge = require("webpack-merge");
module.exports = {
stories: ["../stories/**/*.stories.@(tsx|mdx)"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-knobs",
"@storybook/addon-notes",
"@storybook/addon-viewport",
"storybook-addon-intl",
{
name: "@storybook/addon-docs",
options: {
configureJSX: true,
},
},
],
webpackFinal: async (storybookBaseConfig, { configType }) => {
// Remove the existing css rule
// 참고: https://github.com/storybookjs/storybook/issues/6083
// https://github.com/storybookjs/storybook/issues/6319#issuecomment-477852640
storybookBaseConfig.module.rules = storybookBaseConfig.module.rules.filter(
(f) => f.test.toString() !== "/\\.css$/"
);
const styleLoaderConfig = {
loader: "style-loader",
options: {
insert: "#style-loader-heaven",
},
};
const cssLoaderConfig = {
loader: "css-loader",
options: {
modules: {
mode: "global",
localIdentName: "__[path][name]__[local]--[hash:base64:5]",
},
},
};
storybookBaseConfig.module.rules[2] = {
test: /\.css$/,
use: [styleLoaderConfig, cssLoaderConfig],
};
storybookBaseConfig.module.rules[3].exclude = [/\.icon\.(png|gif|svg)$/];
storybookBaseConfig.module.rules.push({
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
babelrc: true,
extends: require.resolve("@plasma-fe/common-config/.babelrc"),
},
},
{
loader: "ts-loader",
},
],
});
storybookBaseConfig.module.rules.push({
test: /\.scss$/,
exclude: [/\.module\.scss$/, /global\.scss$/],
use: [
styleLoaderConfig,
cssLoaderConfig,
{
loader: "sass-loader",
},
],
});
storybookBaseConfig.module.rules.push({
test: /\.module\.scss$/,
use: [
styleLoaderConfig,
{
loader: "css-loader",
options: {
modules: {
mode: "local",
localIdentName: "__[path][name]__[local]--[hash:base64:5]",
},
},
},
{
loader: "sass-loader",
},
],
});
storybookBaseConfig.module.rules.push({
test: /global\.scss$/,
use: [
{
loader: "style-loader",
options: {
// injectType: 'lazyStyleTag',
insert: "#scoped-global-css-heaven",
},
},
{
loader: "css-loader",
},
{
loader: "sass-loader",
},
],
});
storybookBaseConfig.module.rules.push({
test: /\.icon\.(png|gif|svg)$/,
use: [
{
loader: require.resolve("url-loader"),
},
],
});
storybookBaseConfig.resolve.extensions.push(".ts", ".tsx");
storybookBaseConfig = merge.smart(
storybookBaseConfig,
require("../webpack.sprites.config")
);
// Return the altered config
return storybookBaseConfig;
},
}; Please help me... |
What happens when you remove this:
|
Same,
even though I remove declare module mdx. |
Oh, I see what's going on. Take a look at these recipes: You're mixing up "CSF Stories with MDX Docs" and "CSF Stories with arbitrary MDX". I'd suggest just following the first recipe. |
@shilman
|
@shilman |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
I have this issue attempting to use the CSF Stories with arbitrary MDX recipe. My main.js is more out-of-the-box, with simply: module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials"
]
} My Button.mdx file is: import { Story } from '@storybook/addon-docs/blocks';
# Button
I can embed a story (but not define one, since this file should not contain a `Meta`):
<Story id="example-button--primary" />
And I can also embed arbitrary markdown & JSX in this file. ...and my Button.stories.ts file begins with: import { Story, Meta } from '@storybook/angular';
import Button from './button.component';
import mdx from './Button.mdx'
export default {
title: 'Example/Button',
component: Button,
argTypes: { backgroundColor: { control: 'color' } },
parameters: { actions: { argTypesRegex: 'clicked' }, docs: { page: mdx} }
} as Meta; I don't have a global.d.ts file but I did try to see what happens when I declare mdx in one...the warning hint disappears in the editor but compilation still fails. I'm assuming this recipe just is not possible using Typescript, as there is an open issue for it to support .mdx file extensions.. Indeed, I tried changing the .mdx extension to .jsx and added If this is the case, can I submit a PR that simply states this limitation in the documentation? |
@marvhen I wonder if one of our typescript wizards can offer a suggestion here. @gaetanmaisse @ndelangen @yannbf @tooppaaa ? ☝️ i'm guessing the workaround for this should be something pretty standard? |
Which version of Storybook are you using @marvhen? Because I think it has been fixed in 6.2 Repo: https://github.com/gaetanmaisse/storybook-angular-mdx Maybe I missed something in the commit adding the mdx file? |
I am using SB 6.2.2 but after comparing my project to yours it turns out that I need the I guess the reason it didn't work when I first tried it was I had it in the root of the project and it needed to be in the Thanks for the help! |
@jiheapark can you give it a try with SB 6.2 too and let me know if you're still facing the issue? |
There are a lot of nuances that are left out of this documentation to actually get things working with storybook and angular: https://storybook.js.org/docs/angular/writing-docs/introduction @gaetanmaisse @shilman we should probably get the docs updated. On top of this, the docs dont mention anything about compodoc setup either. Took me a good bit of Github issue digging and Googling to figure out |
@sir-captainmorgan21 thank you, PRs are very welcome! https://storybook.js.org/docs/react/contribute/documentation-updates |
@gaetanmaisse I am still facing this issue with globals.d.ts in the src of the lib and it being listed under include in the tsconfig. Can we get the minimum requirements to get this working? If so Ill open a PR to get this into the docs |
I got this error
With
Button.stories.tsx
Button.stories.mdx
How can I add
Button.stories.mdx
file as docs.I declared mdx at
global.d.ts
The text was updated successfully, but these errors were encountered: