From 28144a7da0b2b1316adb18b840d8fd097a4aa6fb Mon Sep 17 00:00:00 2001 From: Mateusz Kadlubowski Date: Sat, 7 Dec 2024 18:09:54 +0800 Subject: [PATCH] remove enforcement of `post` for transform plugin & rename --- src/compiler/plugins.ts | 5 ++--- src/preset.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compiler/plugins.ts b/src/compiler/plugins.ts index e717ea8..503dd69 100644 --- a/src/compiler/plugins.ts +++ b/src/compiler/plugins.ts @@ -57,7 +57,7 @@ export async function preTransformPlugin(): Promise { }; } -export async function postTransformPlugin(): Promise { +export async function transformPlugin(): Promise { const [{ createFilter }, { loadSvelteConfig }] = await Promise.all([ import('vite'), import('@sveltejs/vite-plugin-svelte'), @@ -68,8 +68,7 @@ export async function postTransformPlugin(): Promise { const filter = createFilter(include); return { - name: 'storybook:addon-svelte-csf-plugin-post', - enforce: 'post', + name: 'storybook:addon-svelte-csf', async transform(compiledCode, id) { if (!filter(id)) return undefined; diff --git a/src/preset.ts b/src/preset.ts index fe6d511..6260e9b 100644 --- a/src/preset.ts +++ b/src/preset.ts @@ -1,7 +1,7 @@ import type { StorybookConfig } from '@storybook/svelte-vite'; import type { Options } from '@storybook/types'; -import { postTransformPlugin, preTransformPlugin } from '#compiler/plugins'; +import { transformPlugin, preTransformPlugin } from '#compiler/plugins'; import { createIndexer } from '#indexer/index'; export interface StorybookAddonSvelteCsFOptions extends Options { @@ -28,7 +28,7 @@ export const viteFinal: StorybookConfig['viteFinal'] = async ( if (legacyTemplate) { plugins.unshift(await preTransformPlugin()); } - plugins.push(await postTransformPlugin()); + plugins.push(await transformPlugin()); return { ...restConfig,