Skip to content

Commit

Permalink
Remove __namedExportsOrder handling from store
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Nov 8, 2021
1 parent 605c952 commit 0787dfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/store/src/processCSFFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('processCSFFile', () => {
});
});

it('adds stories in the right order if __namedExportsOrder is supplied', () => {
it('ignores __namedExportsOrder', () => {
const { stories } = processCSFFile(
{
default: { title: 'Component' },
Expand All @@ -63,10 +63,10 @@ describe('processCSFFile', () => {
);

expect(Object.keys(stories)).toEqual([
'component--w',
'component--x',
'component--z',
'component--y',
'component--z',
'component--w',
]);
});

Expand Down
16 changes: 2 additions & 14 deletions lib/store/src/processCSFFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function processCSFFile<TFramework extends AnyFramework>(
title: ComponentTitle
): CSFFile<TFramework> {
const { default: defaultExport, __namedExportsOrder, ...namedExports } = moduleExports;
let exports = namedExports;

const { id, argTypes } = defaultExport;
const meta: NormalizedComponentAnnotations<TFramework> = {
Expand All @@ -54,22 +53,11 @@ export function processCSFFile<TFramework extends AnyFramework>(
};
checkDisallowedParameters(meta.parameters);

// prefer a user/loader provided `__namedExportsOrder` array if supplied
// we do this as es module exports are always ordered alphabetically
// see https://github.com/storybookjs/storybook/issues/9136
if (Array.isArray(__namedExportsOrder)) {
exports = {};
__namedExportsOrder.forEach((name) => {
const namedExport = namedExports[name];
if (namedExport) exports[name] = namedExport;
});
}

const csfFile: CSFFile<TFramework> = { meta, stories: {} };

Object.keys(exports).forEach((key) => {
Object.keys(namedExports).forEach((key) => {
if (isExportStory(key, meta)) {
const storyMeta = normalizeStory(key, exports[key], meta);
const storyMeta = normalizeStory(key, namedExports[key], meta);
checkDisallowedParameters(storyMeta.parameters);

csfFile.stories[storyMeta.id] = storyMeta;
Expand Down

0 comments on commit 0787dfc

Please sign in to comment.