@@ -5,6 +5,7 @@ import { defu } from 'defu'
55import { createPageGenerateHook , createGenerateDoneHook } from './hooks'
66import type { CrawlerPage , CrawlerHooks , CrawlerOptions } from './hooks'
77import { InstantSearchThemes , type ModuleBaseOptions } from './types'
8+ import { resolveModulePath } from 'exsolve'
89
910const MODULE_NAME = '@nuxtjs/algolia'
1011const logger = useLogger ( MODULE_NAME )
@@ -26,7 +27,7 @@ export default defineNuxtModule<ModuleOptions>({
2627 name : '@nuxtjs/algolia' ,
2728 configKey : 'algolia' ,
2829 compatibility : {
29- nuxt : '^ 3.0.0-rc.9 || ^2.16.0' ,
30+ nuxt : '>= 3.0.0-rc.9 || ^2.16.0' ,
3031 bridge : true
3132 }
3233 } ,
@@ -52,12 +53,9 @@ export default defineNuxtModule<ModuleOptions>({
5253
5354 const notRunningInPrepareScript = ! nuxt . options . _prepare
5455
55- if ( ! options . apiKey && notRunningInPrepareScript ) {
56- throwError ( 'Missing `apiKey`' )
57- }
58-
59- if ( ! options . applicationId && notRunningInPrepareScript ) {
60- throwError ( 'Missing `applicationId`' )
56+ if ( notRunningInPrepareScript && ( ! options . apiKey || ! options . applicationId ) ) {
57+ console . warn ( 'Missing `apiKey` or `applicationId` in `nuxt.config.js`' )
58+ return
6159 }
6260
6361 if ( options . crawler ! . apiKey || options . crawler ! . indexName ) {
@@ -76,7 +74,7 @@ export default defineNuxtModule<ModuleOptions>({
7674
7775 if ( isNuxt2 ( nuxt ) ) {
7876 nuxt . addHooks ( {
79- // @ts -expect-error Nuxt 2 only hook
77+ // Nuxt 2 only hook
8078 'generate:page' : createPageGenerateHook ( nuxt , options , pages ) ,
8179 'generate:done' : createGenerateDoneHook ( nuxt , options , pages )
8280 } )
@@ -120,7 +118,7 @@ export default defineNuxtModule<ModuleOptions>({
120118 } )
121119 }
122120 // Nuxt 3
123- // @ts -expect-error TODO: Workaround for rc.14 only
121+ // Workaround for rc.14 only
124122 nuxt . options . runtimeConfig . public = nuxt . options . runtimeConfig . public || { }
125123 // @ts -ignore
126124 nuxt . options . runtimeConfig . public . algolia = defu ( nuxt . options . runtimeConfig . algolia , {
@@ -153,8 +151,7 @@ export default defineNuxtModule<ModuleOptions>({
153151 // Polyfilling server packages for SSR support
154152 nuxt . hook ( 'vite:extendConfig' , ( config , { isClient } ) => {
155153 if ( isClient ) {
156- ( config as any ) . resolve . alias [ '@algolia/requester-node-http' ] =
157- 'unenv/runtime/mock/empty'
154+ ( config as any ) . resolve . alias [ '@algolia/requester-node-http' ] = resolveModulePath ( 'mocked-exports/empty' , { from : import . meta. url } )
158155 }
159156 } )
160157
0 commit comments