Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Fix issue with inconsistent CSF ordering in sandboxes #20705

Merged
merged 3 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class StoryIndexGenerator {

async initialize() {
// Find all matching paths for each specifier
await Promise.all(
const specifiersAndCaches = await Promise.all(
this.specifiers.map(async (specifier) => {
const pathToSubIndex = {} as SpecifierStoriesCache;

Expand All @@ -132,10 +132,16 @@ export class StoryIndexGenerator {
pathToSubIndex[absolutePath] = false;
});

this.specifierToCache.set(specifier, pathToSubIndex);
return [specifier, pathToSubIndex] as const;
})
);

// We do this in a second step to avoid timing issues with the Promise.all above -- to ensure
// the keys in the `specifierToCache` object are consistent with the order of specifiers.
specifiersAndCaches.forEach(([specifier, cache]) =>
this.specifierToCache.set(specifier, cache)
);

// Extract stories for each file
await this.ensureExtracted();
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ export const addStories: Task['run'] = async (
);

const existingStories = await filterExistsInCodeDir(addonDirs, join('template', 'stories'));
await Promise.all(
existingStories.map(async (packageDir) => linkPackageStories(packageDir, { mainConfig, cwd }))
);
for (const packageDir of existingStories) {
await linkPackageStories(packageDir, { mainConfig, cwd });
}

// Add some extra settings (see above for what these do)
if (template.expected.builder === '@storybook/builder-webpack5')
Expand Down