Skip to content

Commit

Permalink
Merge pull request #29795 from tobiasdiez/plugin-promise
Browse files Browse the repository at this point in the history
Vue: Properly resolve Vite plugin
  • Loading branch information
yannbf authored Dec 5, 2024
2 parents a197110 + 517dba5 commit f25b824
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions code/frameworks/vue3-vite/src/plugins/vue-component-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dirname, join, parse, relative, resolve } from 'node:path';

import findPackageJson from 'find-package-json';
import MagicString from 'magic-string';
import type { ModuleNode, PluginOption } from 'vite';
import type { ModuleNode, Plugin } from 'vite';
import {
type ComponentMeta,
type MetaCheckerOptions,
Expand All @@ -21,7 +21,7 @@ type MetaSource = {
} & ComponentMeta &
MetaCheckerOptions['schema'];

export async function vueComponentMeta(tsconfigPath = 'tsconfig.json'): Promise<PluginOption> {
export async function vueComponentMeta(tsconfigPath = 'tsconfig.json'): Promise<Plugin> {
const { createFilter } = await import('vite');

// exclude stories, virtual modules and storybook internals
Expand Down
4 changes: 2 additions & 2 deletions code/frameworks/vue3-vite/src/plugins/vue-docgen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import MagicString from 'magic-string';
import type { PluginOption } from 'vite';
import type { Plugin } from 'vite';
import { parse } from 'vue-docgen-api';

export async function vueDocgen(): Promise<PluginOption> {
export async function vueDocgen(): Promise<Plugin> {
const { createFilter } = await import('vite');

const include = /\.(vue)$/;
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/vue3-vite/src/plugins/vue-template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin } from 'vite';

export async function templateCompilation() {
export async function templateCompilation(): Promise<Plugin> {
return {
name: 'storybook:vue-template-compilation',
config: () => ({
Expand Down
4 changes: 2 additions & 2 deletions code/frameworks/vue3-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { dirname, join } from 'node:path';

import type { PresetProperty } from 'storybook/internal/types';

import type { PluginOption } from 'vite';
import type { Plugin } from 'vite';

import { vueComponentMeta } from './plugins/vue-component-meta';
import { vueDocgen } from './plugins/vue-docgen';
Expand All @@ -18,7 +18,7 @@ export const core: PresetProperty<'core'> = {
};

export const viteFinal: StorybookConfig['viteFinal'] = async (config, options) => {
const plugins: PluginOption[] = [templateCompilation()];
const plugins: Plugin[] = [await templateCompilation()];

const framework = await options.presets.apply('framework');
const frameworkOptions: FrameworkOptions =
Expand Down
4 changes: 3 additions & 1 deletion code/frameworks/vue3-vite/src/vite-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Plugin } from 'vite';

import { templateCompilation } from './plugins/vue-template';

export const storybookVuePlugin = () => {
export const storybookVuePlugin = (): Promise<Plugin>[] => {
return [templateCompilation()];
};

0 comments on commit f25b824

Please sign in to comment.