-
Notifications
You must be signed in to change notification settings - Fork 407
refactor: [M3-8184] - Improve local Storybook performance #10762
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
Merged
hana-akamai
merged 9 commits into
linode:develop
from
hana-akamai:M3-8184-improve-local-storybook-perf
Aug 27, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
81d4b71
add optimizeDeps for storybook vite config
hana-akamai 7bc6a08
only compile typescript files needed for stories
hana-akamai e09b4a3
Added changeset: Improve local Storybook performance
hana-akamai 792fc7d
include all features
hana-akamai a187c10
disable allowSyntheticDefaultImports and esModuleInterop
hana-akamai 83e5970
only run react-docgen-typescript for files that have stories
hana-akamai 6ba8b21
address feedback
hana-akamai bec46bd
remove vite optimizeDeps
hana-akamai 56f4008
update comment
hana-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10762-tech-stories-1723134446106.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/manager": Tech Stories | ||
| --- | ||
|
|
||
| Improve local Storybook performance ([#10762](https://github.com/linode/manager/pull/10762)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { getReactDocgenTSFileGlobs } from './utils'; | ||
|
|
||
| describe('getReactDocgenTSFileGlobs', () => { | ||
| const typeScriptFileGlobs = getReactDocgenTSFileGlobs(); | ||
| it('should return component and feature globs for storybook files', () => { | ||
| expect( | ||
| typeScriptFileGlobs.some( | ||
| (file) => file === 'src/components/Button/**/*.{ts,tsx}' | ||
| ) | ||
| ).toBe(true); | ||
| expect( | ||
| typeScriptFileGlobs.some( | ||
| (file) => file === 'src/components/Paper.{ts,tsx}' | ||
| ) | ||
| ).toBe(true); | ||
| expect( | ||
| typeScriptFileGlobs.some( | ||
| (file) => file === 'src/features/TopMenu/**/*.{ts,tsx}' | ||
| ) | ||
| ).toBe(true); | ||
| expect( | ||
| typeScriptFileGlobs.some( | ||
| (file) => file === 'src/features/Longview/**/*.{ts,tsx}' | ||
| ) | ||
| ).toBe(false); | ||
| }); | ||
|
hana-akamai marked this conversation as resolved.
|
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import globby from 'globby'; | ||
|
|
||
| const PATTERN = 'src/**/*.stories.tsx'; | ||
|
|
||
| /** | ||
| * Find all storybook files, then return the glob containing the parent component/feature. | ||
| * To be used in main.ts to tell react-docgen-typescript which files to compile. | ||
| * https://github.com/linode/manager/pull/10762 | ||
| * | ||
| * Example: src/components/Button/Button.stories.tsx -> src/components/Button/**\/*.{ts,tsx} | ||
| */ | ||
| export const getReactDocgenTSFileGlobs = () => { | ||
| const filesWithStories = globby.sync(PATTERN); | ||
| const files: string[] = []; | ||
|
|
||
| filesWithStories.forEach((file) => { | ||
| const execArr = /(src\/(components|features)\/[a-zA-Z]*(.|\/))/.exec(file); | ||
| if (execArr) { | ||
| const isDirectory = execArr[3] === '/'; | ||
| const fileBlob = `${execArr[0]}${isDirectory ? '**/*.' : ''}{ts,tsx}`; | ||
| if (!files.includes(fileBlob)) { | ||
|
hana-akamai marked this conversation as resolved.
|
||
| files.push(fileBlob); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| return files; | ||
| }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found this upon further investigation storybookjs/storybook#24943 (comment)