-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Build: Support big metafiles in bundle analyzer #32109
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8845f5f
remove unnecessary postbuild scripts
JReinhold 2c4c53e
fix running postbuild scripts, refactor generate bundle to support me…
JReinhold 31ea1a0
fix adding storybook config dir to vite config allow list
JReinhold d4c135f
make esbuild analyzer local, support any size of metafile
JReinhold 9a0d6b3
disable eslint for raw index.js analyzer file
JReinhold bd72ec7
really fix lint this time
JReinhold 0b2ae49
change metafile output to match pacakge dir name instead of package n…
JReinhold b194e30
bust nx cache
JReinhold 48e931b
Merge branch 'sb10/esm-only' of github.com:storybookjs/storybook into…
JReinhold 0825667
add comment about metafile location and nx
JReinhold 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
This file was deleted.
Oops, something went wrong.
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,81 @@ | ||
| import React from 'react'; | ||
|
|
||
| import type { Meta } from '@storybook/react-vite'; | ||
|
|
||
| import { safeMetafileArg } from '../../../scripts/bench/safe-args'; | ||
|
|
||
| // @ts-expect-error - TS doesn't know about import.meta.glob from Vite | ||
| const allMetafiles = import.meta.glob(['../../bench/esbuild-metafiles/**/*.json'], { | ||
| import: 'default', | ||
| }); | ||
|
|
||
| export default { | ||
| title: 'Bench', | ||
| parameters: { | ||
| layout: 'fullscreen', | ||
| chromatic: { disableSnapshot: true }, | ||
| }, | ||
| args: { | ||
| // default to the core/node.json metafile | ||
| metafile: safeMetafileArg( | ||
| Object.keys(allMetafiles).find((path) => path.includes('/core/node.json'))! | ||
| ), | ||
| }, | ||
| argTypes: { | ||
| metafile: { | ||
| options: Object.keys(allMetafiles).map(safeMetafileArg).sort(), | ||
| mapping: Object.fromEntries( | ||
| Object.keys(allMetafiles).map((path) => [safeMetafileArg(path), path]) | ||
| ), | ||
| control: { | ||
| type: 'select', | ||
| labels: Object.fromEntries( | ||
| Object.keys(allMetafiles).map((path) => { | ||
| const [, dirname, subEntry] = /esbuild-metafiles\/(.+)\/(.+).json/.exec(path)!; | ||
|
|
||
| // most metafile directories are named exactly like their package name within the @storybook scope | ||
| let packageName = '@storybook/' + dirname; | ||
|
|
||
| // but some are not, so we need to map them to the correct package name | ||
| switch (dirname) { | ||
| case 'core': { | ||
| packageName = 'storybook'; | ||
| break; | ||
| } | ||
| case 'eslint-plugin': | ||
| packageName = 'eslint-plugin-storybook'; | ||
| break; | ||
| case 'create-storybook': | ||
| case 'storybook-addon-pseudo-states': | ||
| packageName = dirname; | ||
| } | ||
|
|
||
| return [safeMetafileArg(path), `${packageName} - ${subEntry}`]; | ||
| }) | ||
| ), | ||
| }, | ||
| }, | ||
| }, | ||
| beforeEach: async ({ args }) => { | ||
| if (!args.metafile) { | ||
| globalThis.metafile = undefined; | ||
| return; | ||
| } | ||
| const metafile = await allMetafiles[args.metafile](); | ||
| // this is read by the bundle-analyzer iframe via parent.metafile, in bundle-analyzer/index.js | ||
| globalThis.metafile = JSON.stringify(metafile); | ||
|
JReinhold marked this conversation as resolved.
JReinhold marked this conversation as resolved.
|
||
| }, | ||
| render: (args) => { | ||
| return ( | ||
| <iframe | ||
| src="/bundle-analyzer/index.html" | ||
| style={{ border: 'none', width: '100%', height: '100vh' }} | ||
| key={args.metafile} // force re-render on args change | ||
| /> | ||
| ); | ||
| }, | ||
| } satisfies Meta; | ||
|
|
||
| export const ESBuildAnalyzer = { | ||
| name: 'ESBuild Metafiles', | ||
| }; | ||
Oops, something went wrong.
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.
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.
the diff is annoying because the file was moved, this is the important new part