Description
Been trying to implement what is described here:
https://developers.figma.com/docs/code-connect/storybook/ with react components.
Was stuck for a while trying to get it to work. Found that when using the Code Connect Storybook integration, the CLI fails to discover Storybook files that use the .jsx or .js extension (e.g., index.stories.jsx, index.stories.js).
Even when explicitly configuring the include array in figma.config.json to match .jsx or .js files, the CLI reports No Code Connect files found.
To Reproduce
Steps to reproduce the behavior:
- Create a React project with a Storybook setup.
- Create a story file using the
.jsx extension: Button.stories.jsx.
- Add the
figma design parameters to the story default export.
- Configure
figma.config.json to look for .jsx files:
{
"codeConnect": {
"parser": "react",
"language": "jsx",
"include": ["**/*.stories.jsx"]
}
}
- Run
npx figma connect publish --verbose.
- See the error:
No Code Connect files found in [directory] - Make sure you have configured include and exclude...
Expected behavior
The CLI should respect the include glob pattern defined in figma.config.json and parse .jsx Storybook files successfully.
Additional context
Looking into the source code (dist/storybook/convert.js), it appears the glob pattern is hardcoded to **/*.stories.tsx instead of reading from the user configuration or supporting .jsx / .js as a fallback:
// dist/storybook/convert.js
export async function convertStorybookFiles({
projectInfo,
storiesGlob = '**/*.stories.tsx',
isForMigration = false,
}) {
// ...
const storyFiles = files.filter((file) => minimatch(file, storiesGlob, { matchBase: true }))
// ...
}
The storiesGlob parameter defaults to **/*.stories.tsx and it doesn't look like it's being passed the include glob from figma.config.json.
Renaming the files to .tsx and updating figma.config.json to include: ["**/*.stories.tsx"] resolves the issue and allows the CLI to publish successfully. However, native support for .jsx or respecting the config would be highly appreciated.
Description
Been trying to implement what is described here:
https://developers.figma.com/docs/code-connect/storybook/ with react components.
Was stuck for a while trying to get it to work. Found that when using the Code Connect Storybook integration, the CLI fails to discover Storybook files that use the
.jsxor.jsextension (e.g.,index.stories.jsx,index.stories.js).Even when explicitly configuring the
includearray infigma.config.jsonto match.jsxor.jsfiles, the CLI reportsNo Code Connect files found.To Reproduce
Steps to reproduce the behavior:
.jsxextension:Button.stories.jsx.figmadesign parameters to the story default export.figma.config.jsonto look for.jsxfiles:{ "codeConnect": { "parser": "react", "language": "jsx", "include": ["**/*.stories.jsx"] } }npx figma connect publish --verbose.No Code Connect files found in [directory] - Make sure you have configured include and exclude...Expected behavior
The CLI should respect the
includeglob pattern defined infigma.config.jsonand parse.jsxStorybook files successfully.Additional context
Looking into the source code (
dist/storybook/convert.js), it appears the glob pattern is hardcoded to**/*.stories.tsxinstead of reading from the user configuration or supporting.jsx/.jsas a fallback:The
storiesGlobparameter defaults to**/*.stories.tsxand it doesn't look like it's being passed theincludeglob fromfigma.config.json.Renaming the files to
.tsxand updatingfigma.config.jsontoinclude: ["**/*.stories.tsx"]resolves the issue and allows the CLI to publish successfully. However, native support for.jsxor respecting the config would be highly appreciated.