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

Fix HMR issue in Manager UI #20654

Merged
merged 2 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion code/frameworks/react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@rollup/pluginutils": "^4.2.0",
"@storybook/builder-vite": "7.0.0-beta.29",
"@storybook/react": "7.0.0-beta.29",
"@vitejs/plugin-react": "^3.0.0",
"@vitejs/plugin-react": "^3.0.1",
"ast-types": "^0.14.2",
"magic-string": "^0.26.1",
"react-docgen": "6.0.0-alpha.3"
Expand Down
4 changes: 3 additions & 1 deletion code/lib/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/channel-postmessage": "7.0.0-beta.29",
"@storybook/channel-websocket": "7.0.0-beta.29",
"@storybook/client-logger": "7.0.0-beta.29",
"@storybook/core-common": "7.0.0-beta.29",
"@storybook/csf-plugin": "7.0.0-beta.29",
Expand All @@ -67,7 +69,7 @@
"@types/node": "^16.0.0",
"rollup": "^3.0.0",
"typescript": "~4.9.3",
"vite": "^4.0.0"
"vite": "^4.0.4"
},
"peerDependencies": {
"@preact/preset-vite": "*",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function pluginConfig(options: Options) {
}
},
},
viteExternalsPlugin(globals, { useWindow: false }),
viteExternalsPlugin(globals, { useWindow: false, disableInServe: true }),
] as PluginOption[];

// TODO: framework doesn't exist, should move into framework when/if built
Expand Down
33 changes: 20 additions & 13 deletions code/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import path from 'path';
import pluginTurbosnap from 'vite-plugin-turbosnap';
import { mergeConfig } from 'vite';
import type { StorybookConfig } from '../../frameworks/react-vite';

const isBlocksOnly = process.env.STORYBOOK_BLOCKS_ONLY === 'true';
Expand Down Expand Up @@ -60,19 +62,24 @@ const config: StorybookConfig = {
features: {
interactionsDebugger: true,
},
viteFinal: (viteConfig, { configType }) => ({
...viteConfig,
plugins: [
...(viteConfig.plugins || []),
configType === 'PRODUCTION' ? pluginTurbosnap({ rootDir: viteConfig.root || '' }) : [],
],
optimizeDeps: { ...viteConfig.optimizeDeps, force: true },
build: {
...viteConfig.build,
// disable sourcemaps in CI to not run out of memory
sourcemap: process.env.CI !== 'true',
},
}),
viteFinal: (viteConfig, { configType }) =>
mergeConfig(viteConfig, {
resolve: {
alias: {
...(configType === 'DEVELOPMENT'
? { '@storybook/components': path.resolve(__dirname, '../components/src') }
: {}),
},
},
plugins: [
configType === 'PRODUCTION' ? pluginTurbosnap({ rootDir: viteConfig.root || '' }) : [],
],
optimizeDeps: { force: true },
build: {
// disable sourcemaps in CI to not run out of memory
sourcemap: process.env.CI !== 'true',
},
}),
};

export default config;
10 changes: 6 additions & 4 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6062,6 +6062,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@storybook/builder-vite@workspace:lib/builder-vite"
dependencies:
"@storybook/channel-postmessage": 7.0.0-beta.29
"@storybook/channel-websocket": 7.0.0-beta.29
"@storybook/client-logger": 7.0.0-beta.29
"@storybook/core-common": 7.0.0-beta.29
"@storybook/csf-plugin": 7.0.0-beta.29
Expand All @@ -6082,7 +6084,7 @@ __metadata:
rollup: ^3.0.0
slash: ^3.0.0
typescript: ~4.9.3
vite: ^4.0.0
vite: ^4.0.4
vite-plugin-externals: ^0.5.1
peerDependencies:
"@preact/preset-vite": "*"
Expand Down Expand Up @@ -7193,7 +7195,7 @@ __metadata:
"@storybook/builder-vite": 7.0.0-beta.29
"@storybook/react": 7.0.0-beta.29
"@types/node": ^16.0.0
"@vitejs/plugin-react": ^3.0.0
"@vitejs/plugin-react": ^3.0.1
ast-types: ^0.14.2
magic-string: ^0.26.1
react-docgen: 6.0.0-alpha.3
Expand Down Expand Up @@ -9305,7 +9307,7 @@ __metadata:
languageName: node
linkType: hard

"@vitejs/plugin-react@npm:^3.0.0":
"@vitejs/plugin-react@npm:^3.0.1":
version: 3.0.1
resolution: "@vitejs/plugin-react@npm:3.0.1"
dependencies:
Expand Down Expand Up @@ -29416,7 +29418,7 @@ __metadata:
languageName: node
linkType: hard

"vite@npm:^4.0.0":
"vite@npm:^4.0.0, vite@npm:^4.0.4":
version: 4.0.4
resolution: "vite@npm:4.0.4"
dependencies:
Expand Down