File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff 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
7882export type { Options as SentryVitePluginOptions } from "@sentry/bundler-plugin-core" ;
7983export { sentryCliBinaryExists } from "@sentry/bundler-plugin-core" ;
Original file line number Diff line number Diff line change @@ -32,4 +32,17 @@ describe("sentryVitePlugin", () => {
3232 ] )
3333 ) ;
3434 } ) ;
35+
36+ it ( "returns an array of Vite pluginswhen unplugin returns a single plugin" , ( ) => {
37+ const plugins = sentryVitePlugin ( {
38+ authToken : "test-token" ,
39+ org : "test-org" ,
40+ project : "test-project" ,
41+ disable : true , // This causes unplugin to return only the noop plugin
42+ } ) ;
43+
44+ expect ( Array . isArray ( plugins ) ) . toBe ( true ) ;
45+ expect ( plugins . length ) . toBeGreaterThanOrEqual ( 1 ) ;
46+ expect ( plugins [ 0 ] ) . toHaveProperty ( "name" ) ;
47+ } ) ;
3548} ) ;
You can’t perform that action at this time.
0 commit comments