@@ -32,7 +32,7 @@ const EXTERNAL_PACKAGES = [
3232 / ^ r e m o t i o n / ,
3333 ] ,
3434 NPM_BUNDLES = [ define ( { dev : true } ) , define ( { dev : false } ) ] ,
35- TYPES_BUNDLES = [ defineTypes ( ) ] ;
35+ TYPES_BUNDLES = defineTypes ( ) ;
3636
3737// Styles
3838if ( ! MODE_TYPES ) {
@@ -53,38 +53,60 @@ export default defineConfig(
5353) ;
5454
5555/**
56- * @returns {import('rollup').RollupOptions }
56+ * @returns {import('rollup').RollupOptions[] }
5757 * */
5858function defineTypes ( ) {
59- return {
60- input : {
61- index : 'types/react/src/index.d.ts' ,
62- icons : 'types/react/src/icons.d.ts' ,
63- 'player/remotion' : 'types/react/src/providers/remotion/index.d.ts' ,
64- 'player/layouts/default' : 'types/react/src/components/layouts/default/index.d.ts' ,
65- } ,
66- output : {
67- dir : '.' ,
68- chunkFileNames : 'dist/types/[name].d.ts' ,
69- manualChunks ( id ) {
70- if ( id . includes ( 'react/src' ) ) return 'vidstack-react' ;
71- if ( id . includes ( 'maverick' ) ) return 'vidstack-framework' ;
72- if ( id . includes ( 'vidstack' ) ) return 'vidstack' ;
59+ return [
60+ {
61+ input : {
62+ index : 'types/react/src/index.d.ts' ,
63+ icons : 'types/react/src/icons.d.ts' ,
64+ 'player/remotion' : 'types/react/src/providers/remotion/index.d.ts' ,
65+ 'player/layouts/default' : 'types/react/src/components/layouts/default/index.d.ts' ,
7366 } ,
74- } ,
75- external : EXTERNAL_PACKAGES ,
76- plugins : [
77- {
78- name : 'resolve-vidstack-types' ,
79- resolveId ( id ) {
80- if ( id === 'vidstack' ) {
81- return 'types/vidstack/src/index.d.ts' ;
82- }
67+ output : {
68+ dir : '.' ,
69+ chunkFileNames : 'dist/types/[name].d.ts' ,
70+ manualChunks ( id ) {
71+ if ( id . includes ( 'react/src' ) ) return 'vidstack-react' ;
72+ if ( id . includes ( 'maverick' ) ) return 'vidstack-framework' ;
73+ if ( id . includes ( 'vidstack' ) ) return 'vidstack' ;
8374 } ,
8475 } ,
85- dts ( { respectExternal : true } ) ,
86- ] ,
87- } ;
76+ external : EXTERNAL_PACKAGES ,
77+ plugins : [
78+ {
79+ name : 'resolve-vidstack-types' ,
80+ resolveId ( id ) {
81+ if ( id === 'vidstack' ) {
82+ return 'types/vidstack/src/index.d.ts' ;
83+ }
84+ } ,
85+ } ,
86+ dts ( {
87+ respectExternal : true ,
88+ } ) ,
89+ {
90+ name : 'globals' ,
91+ generateBundle ( _ , bundle ) {
92+ const indexFile = Object . values ( bundle ) . find ( ( file ) => file . fileName === 'index.d.ts' ) ,
93+ globalFiles = [ 'dom.d.ts' , 'google-cast.d.ts' ] ,
94+ references = globalFiles
95+ . map ( ( path ) => `/// <reference path="./${ path } " />` )
96+ . join ( '\n' ) ;
97+
98+ for ( const file of globalFiles ) {
99+ fs . copyFileSync ( path . resolve ( `../vidstack/${ file } ` ) , file ) ;
100+ }
101+
102+ if ( indexFile ?. type === 'chunk' ) {
103+ indexFile . code = references + `\n\n${ indexFile . code } ` ;
104+ }
105+ } ,
106+ } ,
107+ ] ,
108+ } ,
109+ ] ;
88110}
89111
90112/**
0 commit comments