@@ -15,6 +15,7 @@ import type {
15
15
ServiceAccount ,
16
16
App as FirebaseAdminApp ,
17
17
} from 'firebase-admin/app'
18
+ import { markRaw } from 'vue'
18
19
import type { NuxtVueFireAppCheckOptions } from './runtime/app-check'
19
20
20
21
export interface VueFireNuxtModuleOptions {
@@ -94,9 +95,10 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
94
95
new URL ( '../templates' , import . meta. url )
95
96
)
96
97
98
+ // TODO: I don't think the appConfig is the right place to store these as it makes things reactive
97
99
// Let plugins and the user access the firebase config within the app
98
- nuxt . options . appConfig . firebaseConfig = options . config
99
- nuxt . options . appConfig . vuefireOptions = options
100
+ nuxt . options . appConfig . firebaseConfig = markRaw ( options . config )
101
+ nuxt . options . appConfig . vuefireOptions = markRaw ( options )
100
102
101
103
// nuxt.options.build.transpile.push(templatesDir)
102
104
nuxt . options . build . transpile . push ( runtimeDir )
@@ -114,7 +116,7 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
114
116
'[VueFire]: Missing firebase "admin" config. Provide an "admin" option to the VueFire module options. This is necessary to use the auth or app-check module.'
115
117
)
116
118
}
117
- nuxt . options . appConfig . firebaseAdmin = options . admin
119
+ nuxt . options . appConfig . firebaseAdmin = markRaw ( options . admin )
118
120
}
119
121
}
120
122
@@ -127,11 +129,24 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
127
129
128
130
// this allows us to the order of the plugins
129
131
nuxt . hook ( 'modules:done' , ( ) => {
130
- addPlugin ( resolve ( runtimeDir , 'auth/plugin.client' ) )
131
- // must be added after the admin module to use the admin app
132
- addPlugin ( resolve ( runtimeDir , 'auth/plugin.server' ) )
132
+ if ( options . auth ) {
133
+ addPlugin ( resolve ( runtimeDir , 'auth/plugin.client' ) )
134
+ // must be added after the admin module to use the admin app
135
+ addPlugin ( resolve ( runtimeDir , 'auth/plugin.server' ) )
136
+ }
133
137
134
- addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
138
+ if ( options . admin ) {
139
+ if ( ! nuxt . options . ssr ) {
140
+ console . warn (
141
+ '[VueFire]: The "admin" option is only used during SSR. You should reenable ssr to use it.'
142
+ )
143
+ }
144
+ addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
145
+ }
146
+
147
+ if ( options . appCheck ) {
148
+ addPlugin ( resolve ( runtimeDir , 'app-check/plugin' ) )
149
+ }
135
150
136
151
// plugin are added in reverse order
137
152
addPluginTemplate ( {
@@ -142,6 +157,8 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
142
157
ssr : nuxt . options . ssr ,
143
158
} ,
144
159
} )
160
+
161
+ // adds the firebase app to each application
145
162
addPlugin ( resolve ( runtimeDir , 'app/plugin' ) )
146
163
} )
147
164
} ,
@@ -158,6 +175,7 @@ declare module '@nuxt/schema' {
158
175
export interface AppConfig {
159
176
/**
160
177
* Firebase config to initialize the app.
178
+ * @internal
161
179
*/
162
180
firebaseConfig : FirebaseOptions
163
181
@@ -169,6 +187,7 @@ declare module '@nuxt/schema' {
169
187
170
188
/**
171
189
* Firebase Admin options passed to VueFire module. Only available on the server.
190
+ * @internal
172
191
*/
173
192
firebaseAdmin ?: {
174
193
config : Omit < AppOptions , 'credential' >
0 commit comments