From 87bf8f0d5492ce7a25a86b8f69670db85ff49579 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Tue, 13 Feb 2024 23:10:49 +0100 Subject: [PATCH 1/2] use aliases instead of dedupe to deduplicate storybook dependencies in vite --- code/addons/docs/src/preset.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 45c832b5fe42..4980763320fb 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -149,8 +149,14 @@ export const viteFinal = async (config: any, options: Options) => { react, 'react-dom': reactDom, '@mdx-js/react': mdx, + /** + * The following aliases are used to ensure a single instance of these packages are used in situations where they are duplicated + * The packages will be duplicated by the package manager when the user has react installed with another version than 18.2.0 + */ + '@storybook/theming': require.resolve('@storybook/theming'), + '@storybook/components': require.resolve('@storybook/components'), + '@storybook/blocks': require.resolve('@storybook/blocks'), }, - dedupe: ['@storybook/theming', '@storybook/components', '@storybook/blocks'], }, }), }; From c64041e4b66462715eb4c8ca22c4cb1afd0ef956 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Tue, 13 Feb 2024 23:45:41 +0100 Subject: [PATCH 2/2] add missing dirname to require.resolve calls --- code/addons/docs/src/preset.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 4980763320fb..68c7efb39f8b 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -153,9 +153,9 @@ export const viteFinal = async (config: any, options: Options) => { * The following aliases are used to ensure a single instance of these packages are used in situations where they are duplicated * The packages will be duplicated by the package manager when the user has react installed with another version than 18.2.0 */ - '@storybook/theming': require.resolve('@storybook/theming'), - '@storybook/components': require.resolve('@storybook/components'), - '@storybook/blocks': require.resolve('@storybook/blocks'), + '@storybook/theming': dirname(require.resolve('@storybook/theming')), + '@storybook/components': dirname(require.resolve('@storybook/components')), + '@storybook/blocks': dirname(require.resolve('@storybook/blocks')), }, }, }),