mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 06:21:23 +08:00
Merge pull request #17659 from storybookjs/fix/sorted-exports-bug
This commit is contained in:
commit
4741f54110
@ -47,13 +47,3 @@ CSF2StoryWithPlay.play = () => {
|
|||||||
console.log('play!!');
|
console.log('play!!');
|
||||||
userEvent.click(screen.getByRole('button'));
|
userEvent.click(screen.getByRole('button'));
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line no-underscore-dangle
|
|
||||||
export const __namedExportsOrder = [
|
|
||||||
'Basic',
|
|
||||||
'WithArgs',
|
|
||||||
'StoryObject',
|
|
||||||
'StoryNoRender',
|
|
||||||
'StoryWithPlay',
|
|
||||||
'CSF2StoryWithPlay',
|
|
||||||
];
|
|
||||||
|
@ -388,8 +388,18 @@ export class CsfFile {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (self._namedExportsOrder) {
|
if (self._namedExportsOrder) {
|
||||||
|
const unsortedExports = Object.keys(self._storyExports);
|
||||||
self._storyExports = sortExports(self._storyExports, self._namedExportsOrder);
|
self._storyExports = sortExports(self._storyExports, self._namedExportsOrder);
|
||||||
self._stories = sortExports(self._stories, self._namedExportsOrder);
|
self._stories = sortExports(self._stories, self._namedExportsOrder);
|
||||||
|
|
||||||
|
const sortedExports = Object.keys(self._storyExports);
|
||||||
|
if (unsortedExports.length !== sortedExports.length) {
|
||||||
|
throw new Error(
|
||||||
|
`Missing exports after sort: ${unsortedExports.filter(
|
||||||
|
(key) => !sortedExports.includes(key)
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user