Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue: Properly resolve Vite plugin #29795

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't see a reason for this to be a promise in the first place cc @yannbf ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason. The others were needed because they do dynamic imports, but this one seems simple enough

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()];
};
Loading