Skip to content

Commit 6385def

Browse files
committed
normalize vite plugin to always return an array of plugins
1 parent 4728fc1 commit 6385def

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/vite-plugin/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ const sentryUnplugin = sentryUnpluginFactory({
7373
bundleSizeOptimizationsPlugin: viteBundleSizeOptimizationsPlugin,
7474
});
7575

76-
export const sentryVitePlugin: (options?: Options) => VitePlugin[] = sentryUnplugin.vite;
76+
export const sentryVitePlugin = (options?: Options): VitePlugin[] => {
77+
const result = sentryUnplugin.vite(options);
78+
// unplugin returns a single plugin instead of an array when only one plugin is created, so we normalize this here.
79+
return Array.isArray(result) ? result : [result];
80+
};
7781

7882
export type { Options as SentryVitePluginOptions } from "@sentry/bundler-plugin-core";
7983
export { sentryCliBinaryExists } from "@sentry/bundler-plugin-core";

0 commit comments

Comments
 (0)