Skip to content

Commit

Permalink
Merge pull request #20917 from storybookjs/fix/detect-mdx2-errors
Browse files Browse the repository at this point in the history
Core: Detect mdx2 errors and provide guidance to fix them
  • Loading branch information
yannbf authored Feb 9, 2023
2 parents 3d8a74f + 81ec9f0 commit 8c6592f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import chalk from 'chalk';
import fs from 'fs-extra';
import glob from 'globby';
import slash from 'slash';
Expand Down Expand Up @@ -369,7 +370,14 @@ export class StoryIndexGenerator {
};
return docsEntry;
} catch (err) {
logger.warn(`🚨 Extraction error on ${relativePath}: ${err}`);
logger.warn(`🚨 Extraction error on ${chalk.blue(relativePath)}: ${err}`);
if (err.source?.match(/mdast-util-mdx-jsx/g)) {
logger.warn(
`💡 This seems to be an MDX2 syntax error. Please refer to the MDX section in the following resource for assistance on how to fix this: ${chalk.yellow(
'https://storybook.js.org/migration-guides/7.0'
)}`
);
}
throw err;
}
}
Expand Down

0 comments on commit 8c6592f

Please sign in to comment.