Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Allow .mjs extension for CSF stories #23125

Merged

Conversation

idesigncode
Copy link
Contributor

@idesigncode idesigncode commented Jun 19, 2023

Closes #23078

What I did

  • lib/core-common
    • Added "mjs" to normalizeStoriesEntry default files glob pattern
    • Updated relevant inline snapshots
  • lib/core-server
    • Updated the regex test for the csfIndexer to allow ESM .mjs type story files.
    • Added mock data for existing StoryIndexGenerator & stories-json tests
    • Updated relevant inline snapshots & expected test values
  • lib/cli
    • Added "mjs" to the configureMain extensions
    • Updated relevant inline snapshots
  • ui
    • Added "mjs" to blocksOnlyStories glob patterns
  • Updated stories file extensions lists in docs

How to test

  1. Run storybook with yarn start
  2. Run yarn test
  3. Ensure the following tests pass:
  • lib/core-common/src/utils/__tests__/normalize-stories.test.ts
  • lib/core-server/src/utils/StoryIndexGenerator.test.ts
  • lib/core-server/src/utils/stories-json.test.ts
  • lib/cli/src/automigrate/fixes/bare-mdx-stories-glob.test.ts
  • lib/cli/src/generators/configure.test.ts

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@idesigncode idesigncode changed the title Fix: Allow ESM .mjs files for CSF stories Allow ESM .mjs files for CSF stories Jun 19, 2023
@shilman
Copy link
Member

shilman commented Jun 19, 2023

Thanks for this @idesigncode ! I think you missed this one though

const DEFAULT_FILES = '**/*.@(mdx|stories.@(tsx|ts|jsx|js))';

@shilman shilman added maintenance User-facing maintenance tasks core csf labels Jun 19, 2023
@ndelangen ndelangen self-requested a review June 21, 2023 07:49
@ndelangen ndelangen changed the title Allow ESM .mjs files for CSF stories Core: Allow .mjs extension for CSF stories Jun 21, 2023
@ndelangen ndelangen merged commit 4311d33 into storybookjs:next Jun 21, 2023
@github-actions github-actions bot mentioned this pull request Jun 21, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core csf maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Allow ESM .mjs files for CSF stories
4 participants