From 81ec9f0ce27054228afe1f25aabf79172f0084cc Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 9 Feb 2023 12:46:25 +0100 Subject: [PATCH] detect mdx2 errors and provide guidance to fix them --- code/lib/core-server/src/utils/StoryIndexGenerator.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 67aedf38ec06..9e3348d3498c 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -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'; @@ -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; } }