mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 16:41:08 +08:00
21 lines
544 B
JavaScript
21 lines
544 B
JavaScript
const global = require('global');
|
|
const fs = require('fs-extra');
|
|
|
|
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
|
|
? await import('@storybook/mdx2-csf')
|
|
: await import('@storybook/mdx1-csf');
|
|
code = await compile(code);
|
|
}
|
|
return lib.loadCsf(code, { ...options, fileName });
|
|
};
|
|
|
|
module.exports = {
|
|
readCsfOrMdx,
|
|
...lib,
|
|
};
|