@@ -51,64 +51,68 @@ export default defineNuxtModule<ModuleOptions>({
5151 // avoid unwanted behavior with different package managers
5252 const schemaOrgPath = dirname ( await resolvePath ( Pkg ) )
5353
54- const moduleRuntime = resolve ( './runtime' )
55- nuxt . options . build . transpile . push ( ...[ moduleRuntime , RuntimeDir ] )
54+ const moduleRuntimeDir = resolve ( './runtime' )
55+ nuxt . options . build . transpile . push ( ...[ moduleRuntimeDir , RuntimeDir ] )
5656
5757 if ( typeof moduleOptions . client === 'undefined' )
5858 moduleOptions . client = ! ! nuxt . options . dev
5959
6060 // fallback clears schema on route change
6161 if ( ! moduleOptions . client )
62- addPlugin ( resolve ( moduleRuntime , 'plugin-fallback.client' ) )
62+ addPlugin ( resolve ( moduleRuntimeDir , 'plugin-fallback.client' ) )
6363
6464 addPlugin ( {
65- src : resolve ( moduleRuntime , 'plugin' ) ,
65+ src : resolve ( moduleRuntimeDir , 'plugin' ) ,
6666 mode : moduleOptions . client ? 'all' : 'server' ,
6767 } )
6868
69- // might need this again
70- nuxt . options . alias [ Pkg ] = schemaOrgPath
71- // set the alias for the types
72- nuxt . options . alias [ '#vueuse/schema-org/provider' ] = await resolvePath ( `${ schemaOrgPath } /providers/full` )
73- nuxt . options . alias [ '#vueuse/schema-org/runtime' ] = await resolvePath ( `${ schemaOrgPath } /runtime` )
74-
75- nuxt . hook ( 'vite:extendConfig' , ( config , { isClient } ) => {
76- config . optimizeDeps = config . optimizeDeps || { }
77- config . optimizeDeps . exclude = config . optimizeDeps . exclude || [ ]
78- config . optimizeDeps . exclude . push ( ...[ `${ schemaOrgPath } /runtime` , Pkg ] )
79-
80- config . plugins = config . plugins || [ ]
81- config . plugins . push ( SchemaOrgVitePlugin ( {
82- mock : ! moduleOptions . client && isClient ,
83- full : moduleOptions . full ,
84- } ) )
85- } )
69+ const nuxtSchemaComposablesRuntime = `${ moduleRuntimeDir } /composables`
8670
8771 addTemplate ( {
8872 filename : 'nuxt-schema-org-config.mjs' ,
8973 getContents : ( ) => `export default ${ JSON . stringify ( moduleOptions ) } ` ,
9074 } )
9175
76+ const componentPath = await resolvePath ( '@vueuse/schema-org/components' )
77+ for ( const component of schemaOrgComponents ) {
78+ await addComponent ( {
79+ name : component ,
80+ export : component ,
81+ chunkName : 'schema-org-components' ,
82+ filePath : componentPath ,
83+ } )
84+ }
85+
9286 nuxt . hooks . hook ( 'autoImports:sources' , ( autoImports ) => {
9387 autoImports . unshift ( {
94- from : ` ${ moduleRuntime } /schema-org-runtime` ,
88+ from : nuxtSchemaComposablesRuntime ,
9589 imports : [
9690 'injectSchemaOrg' ,
9791 'useSchemaOrg' ,
92+ ] ,
93+ } )
94+
95+ autoImports . unshift ( {
96+ from : '#vueuse/schema-org/provider' ,
97+ imports : [
9898 ...RootSchemas
9999 . map ( schema => [ `define${ schema } ` ] )
100100 . flat ( ) ,
101101 ] ,
102102 } )
103103 } )
104104
105- schemaOrgComponents . forEach ( ( component ) => {
106- addComponent ( {
107- name : component ,
108- export : component ,
109- chunkName : 'schema-org-components' ,
110- filePath : '#vueuse/schema-org/runtime' ,
111- } )
105+ nuxt . hooks . hook ( 'vite:extendConfig' , ( config , { isClient } ) => {
106+ config . optimizeDeps = config . optimizeDeps || { }
107+ config . optimizeDeps . exclude = config . optimizeDeps . exclude || [ ]
108+ config . optimizeDeps . exclude . push ( ...[ `${ schemaOrgPath } /runtime` , Pkg ] )
109+
110+ config . plugins = config . plugins || [ ]
111+ config . plugins . push ( SchemaOrgVitePlugin ( {
112+ mock : ! moduleOptions . client && isClient ,
113+ full : moduleOptions . full ,
114+ runtimePath : nuxtSchemaComposablesRuntime ,
115+ } ) )
112116 } )
113117 } ,
114118} ) as NuxtModule < ModuleOptions >
0 commit comments