Skip to content

bug: babel-preset-storybook-full-source overwrites inline CSF3 story parameters #36660

Description

Package and environment

  • Package: @fluentui/babel-preset-storybook-full-source@0.1.3
  • Storybook: 10.5.5

Configuration

The plugin is configured as:

[fullSourcePlugin, { importMappings: {}, storyGranularity: "story" }]

Reproduction

import type { Meta, StoryObj } from "@storybook/react";

const meta = { title: "Example" } satisfies Meta;
export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
  render: () => <div>Example</div>,
  parameters: {
    docs: { description: { story: "Description" } },
  },
};

The relevant Storybook configuration includes:

import fullSourcePlugin from "@fluentui/babel-preset-storybook-full-source";

export default {
  babel: async (config: any) => ({
    ...config,
    plugins: [
      ...(config.plugins ?? []),
      [fullSourcePlugin, { importMappings: {}, storyGranularity: "story" }],
    ],
  }),
};

Expected behavior

The inline parameters.docs.description.story description survives, and parameters.fullSource is added.

Actual behavior

The description disappears, while parameters.fullSource remains.

Root cause

Verified from the package implementation: parameter detection only tracks assignment expressions such as Story.parameters = ...; it does not recognize the inline parameters property inside export const Story = { ... }. At Program exit it considers parameters missing and appends Story.parameters = {}, overwriting all inline parameters, then assigns Story.parameters.fullSource.

Proposed fix

Recognize inline CSF3 object parameters, or initialize with Story.parameters ??= {} rather than unconditionally replacing the object.

A locally verified workaround is to post-transform Story.parameters = {} into:

Story.parameters = Story.parameters ?? {};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions