Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

context.story is not stable enough to be used as the export name #12

Open
ling1726 opened this issue Nov 5, 2021 · 0 comments
Open

Comments

@ling1726
Copy link
Member

ling1726 commented Nov 5, 2021

Previously the addon used context.story as the name of the export for
codoesandbox. However the below example shows how this value can be
incorrect

export const MyStory = () => {/* story */}
MyStory.storyName = 'My custom story name'

This will break the export as the index.ts will include the following

import * as ReactDOM from 'react-dom';
import { FluentProvider, webLightTheme } from '@fluentui/react-components';
import { My custom story as Example } from './example';
//
// You can edit this example in "example.tsx".
//
ReactDOM.render(
    <FluentProvider theme={webLightTheme}>
        <Example />
    </FluentProvider>,
    document.getElementById('root'),
);

The solution should be to use a babel transform to find the actual name of the exported function and make it available as a parameter for the addon to consume. This can simply be added as another plugin similary to the modifyImports plugin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant