Skip to content

Split addons from "ondevice" addons in main.ts #873

@ndelangen

Description

@ndelangen

Removing the addons from the config makes extract succeed.

Current workaround

Customers must manually remove all on-device addons from .rnstorybook/main.ts.

Proposed fix

Introduce a new deviceAddons property in the StorybookConfig type for @storybook/react-native. On-device addons listed there will not be evaluated as presets by Storybook Core, but will still be injected by scripts/generate.js into the generated storybook.requires.ts at runtime.

const main: StorybookConfig = {
  framework: '@storybook/react-native',
  stories: ['../stories/**/*.stories.?(ts|tsx|js|jsx)'],
  deviceAddons: [
    '@storybook/addon-ondevice-controls',
    '@storybook/addon-ondevice-actions',
  ],
};

Implementation tasks

  • Add deviceAddons to StorybookConfig type in @storybook/react-native
  • Update scripts/generate.js to read from both main.addons and main.deviceAddons for register & preview injection into storybook.requires.ts (this is the only file that consumes on-device addons)
  • Write automigration: move any addon with ondevice in its name from addons to deviceAddons
  • Update storybook init for RN to place on-device packages in deviceAddons
  • Verify fix against the reproduction repo

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions