From 0d04e00b6e2b584377f51587d8b2c302f99a3943 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 18 Jul 2024 17:15:35 +0200 Subject: [PATCH] fix: resolve module not found error '@storybook/builder-vite' (#724) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### ๐Ÿ”— Linked issue Fixes #720. ### โ“ Type of change - [ ] ๐Ÿ“– Documentation (updates to the documentation or readme) - [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue) - [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality) - [ ] โœจ New feature (a non-breaking change that adds functionality) - [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries) - [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change) ### ๐Ÿ“š Description --- packages/storybook-addon/src/preset.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/storybook-addon/src/preset.ts b/packages/storybook-addon/src/preset.ts index d27f292e..c48a5e5d 100644 --- a/packages/storybook-addon/src/preset.ts +++ b/packages/storybook-addon/src/preset.ts @@ -208,8 +208,8 @@ export const core: PresetProperty<'core', StorybookConfig> = async ( ) => { return { ...config, - builder: '@storybook/builder-vite', - renderer: '@storybook/vue3', + builder: await getPackageDir('@storybook/builder-vite'), + renderer: await getPackageDir('@storybook/vue3'), } } /** @@ -230,7 +230,6 @@ export const viteFinal: StorybookConfig['viteFinal'] = async ( ) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const getStorybookViteConfig = async (c: Record, o: any) => { - // const pkgPath = await getPackageDir('@storybook/vue3-vite') const presetURL = pathToFileURL( join(await getPackageDir('@storybook/vue3-vite'), 'preset.js'), ) @@ -265,8 +264,6 @@ export const viteFinal: StorybookConfig['viteFinal'] = async ( } async function getPackageDir(frameworkPackageName: string) { - // const packageJsonPath = join(frameworkPackageName, 'package.json') - try { const require = createRequire(import.meta.url) const packageDir = dirname( @@ -274,12 +271,10 @@ async function getPackageDir(frameworkPackageName: string) { paths: [process.cwd()], }), ) - return packageDir } catch (e) { - // logger.error(e) + throw new Error(`Cannot find ${frameworkPackageName}`, { cause: e }) } - throw new Error(`Cannot find ${frameworkPackageName},`) } export function getNuxtProxyConfig(nuxt: Nuxt) {