From fd3cce900846bef64dfaf4c814486d56e5f1c22f Mon Sep 17 00:00:00 2001 From: Wei-Cheng Pan Date: Fri, 8 Sep 2023 01:45:55 +0900 Subject: [PATCH] fix svelte-vite detection for NPM workspaces In monorepo, the framework name will be an absolute path. A follow up for storybookjs/storybook#23458. --- code/frameworks/svelte-vite/src/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/frameworks/svelte-vite/src/utils.ts b/code/frameworks/svelte-vite/src/utils.ts index 87f2129aeb9f..e630eeafdba8 100644 --- a/code/frameworks/svelte-vite/src/utils.ts +++ b/code/frameworks/svelte-vite/src/utils.ts @@ -22,8 +22,10 @@ export async function handleSvelteKit(plugins: PluginOption[], options: Options) 'vite-plugin-sveltekit-setup', 'vite-plugin-sveltekit-compile', ]); + // The package name can be either "@storybook/sveltekit" or an absolute path in monorepo. + const packageRegex = /(^|\/node_modules\/)@storybook\/sveltekit$/; - if (hasSvelteKitPlugins && framework !== '@storybook/sveltekit') { + if (hasSvelteKitPlugins && packageRegex.test(framework)) { throw new Error(dedent` We've detected a SvelteKit project using the @storybook/svelte-vite framework, which is not supported in Storybook 7.0 Please use the @storybook/sveltekit framework instead.