diff --git a/lib/csf-tools/index.cjs b/lib/csf-tools/index.cjs index cf2e71760c1..82deacac930 100644 --- a/lib/csf-tools/index.cjs +++ b/lib/csf-tools/index.cjs @@ -6,7 +6,7 @@ const lib = require('./dist/cjs/index'); const readCsfOrMdx = async (fileName, options) => { let code = (await fs.readFile(fileName, 'utf-8')).toString(); if (fileName.endsWith('.mdx')) { - const { compile } = global.FEATURES?.previewMdx2 + const { compile } = global.FEATURES && global.FEATURES.previewMdx2 ? await import('@storybook/mdx2-csf') : await import('@storybook/mdx1-csf'); code = await compile(code);