diff --git a/lib/store/src/processCSFFile.test.ts b/lib/store/src/processCSFFile.test.ts index 921cee2a78e8..e5540f069901 100644 --- a/lib/store/src/processCSFFile.test.ts +++ b/lib/store/src/processCSFFile.test.ts @@ -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' }, @@ -63,10 +63,10 @@ describe('processCSFFile', () => { ); expect(Object.keys(stories)).toEqual([ - 'component--w', 'component--x', - 'component--z', 'component--y', + 'component--z', + 'component--w', ]); }); diff --git a/lib/store/src/processCSFFile.ts b/lib/store/src/processCSFFile.ts index 34e7a5e66794..dbb5e44a4193 100644 --- a/lib/store/src/processCSFFile.ts +++ b/lib/store/src/processCSFFile.ts @@ -39,7 +39,6 @@ export function processCSFFile( title: ComponentTitle ): CSFFile { const { default: defaultExport, __namedExportsOrder, ...namedExports } = moduleExports; - let exports = namedExports; const { id, argTypes } = defaultExport; const meta: NormalizedComponentAnnotations = { @@ -54,22 +53,11 @@ export function processCSFFile( }; 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 = { 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;