-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Vite: Support Vite 5 #24395
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
Vite: Support Vite 5 #24395
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1a75c1c
Add Vite 5 to peer dependencies
IanVS 12448d8
Install vite beta in sandboxes
IanVS 77cd89c
Update @joshwooding/vite-plugin-react-docgen-typescript
IanVS cc10c62
Update yarn lock
IanVS f262b63
Use dynamic import of Vite functions
IanVS 954c76c
Use Vite 5 beta in devDependencies
IanVS 619f838
Use dynamic import of slash
IanVS a7bff76
Try to use ESM mocks for jest test
IanVS 73a8e8f
Revert "Try to use ESM mocks for jest test"
IanVS df43854
Revert "Use Vite 5 beta in devDependencies"
IanVS cf03660
Revert "Use dynamic import of slash"
IanVS d138cf6
Add missing await
IanVS 4fa2fa5
Merge branch 'next' into vite-5
IanVS 779c899
Update code/frameworks/react-vite/package.json
IanVS 2aacb58
Update yarn.lock
IanVS 7a34d99
Stick with @joshwooding/vite-plugin-react-docgen-typescript: "0.3.0"
IanVS 4e3fc89
Merge branch 'next' into vite-5
IanVS 77336f2
Merge branch 'next' into vite-5
IanVS c083802
Merge branch 'next' into vite-5
IanVS 8b0ffb0
Merge branch 'next' into vite-5
IanVS 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 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
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
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
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
55 changes: 29 additions & 26 deletions
55
code/builders/builder-vite/src/plugins/inject-export-order-plugin.ts
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 |
|---|---|---|
| @@ -1,32 +1,35 @@ | ||
| import { parse } from 'es-module-lexer'; | ||
| import MagicString from 'magic-string'; | ||
| import { createFilter } from 'vite'; | ||
|
|
||
| const include = [/\.stories\.([tj])sx?$/, /(stories|story).mdx$/]; | ||
| const filter = createFilter(include); | ||
| export async function injectExportOrderPlugin() { | ||
| const { createFilter } = await import('vite'); | ||
|
|
||
| export const injectExportOrderPlugin = { | ||
| name: 'storybook:inject-export-order-plugin', | ||
| // This should only run after the typescript has been transpiled | ||
| enforce: 'post', | ||
| async transform(code: string, id: string) { | ||
| if (!filter(id)) return undefined; | ||
| const include = [/\.stories\.([tj])sx?$/, /(stories|story).mdx$/]; | ||
| const filter = createFilter(include); | ||
|
|
||
| // TODO: Maybe convert `injectExportOrderPlugin` to function that returns object, | ||
| // and run `await init;` once and then call `parse()` without `await`, | ||
| // instead of calling `await parse()` every time. | ||
| const [, exports] = await parse(code); | ||
| return { | ||
| name: 'storybook:inject-export-order-plugin', | ||
| // This should only run after the typescript has been transpiled | ||
| enforce: 'post', | ||
| async transform(code: string, id: string) { | ||
| if (!filter(id)) return undefined; | ||
|
|
||
| if (exports.includes('__namedExportsOrder')) { | ||
| // user has defined named exports already | ||
| return undefined; | ||
| } | ||
| const s = new MagicString(code); | ||
| const orderedExports = exports.filter((e) => e !== 'default'); | ||
| s.append(`;export const __namedExportsOrder = ${JSON.stringify(orderedExports)};`); | ||
| return { | ||
| code: s.toString(), | ||
| map: s.generateMap({ hires: true, source: id }), | ||
| }; | ||
| }, | ||
| }; | ||
| // TODO: Maybe convert `injectExportOrderPlugin` to function that returns object, | ||
| // and run `await init;` once and then call `parse()` without `await`, | ||
| // instead of calling `await parse()` every time. | ||
| const [, exports] = await parse(code); | ||
|
|
||
| if (exports.includes('__namedExportsOrder')) { | ||
| // user has defined named exports already | ||
| return undefined; | ||
| } | ||
| const s = new MagicString(code); | ||
| const orderedExports = exports.filter((e) => e !== 'default'); | ||
| s.append(`;export const __namedExportsOrder = ${JSON.stringify(orderedExports)};`); | ||
| return { | ||
| code: s.toString(), | ||
| map: s.generateMap({ hires: true, source: id }), | ||
| }; | ||
| }, | ||
| }; | ||
| } |
5 changes: 3 additions & 2 deletions
5
code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.