@nuxt/docs-nightly 5.0.0-29846154.7802b2c2 → 5.0.0-29847385.3fde4d62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -124,9 +124,38 @@ export default defineNuxtModule({
|
|
|
124
124
|
})
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
### Other Variants
|
|
128
|
+
|
|
129
|
+
For anything else that points at server code, such as an alias, a type template or an app plugin that reads the server event, you can use `resolveServerVariant` to resolve the variant that is appropriate for this version of Nuxt, or `undefined` if it runs none of them.
|
|
130
|
+
|
|
131
|
+
`addServerImports` accepts the same variants in `from`.
|
|
132
|
+
|
|
133
|
+
```ts [module.ts]
|
|
134
|
+
import { addServerImports, createResolver, defineNuxtModule, resolveServerVariant } from '@nuxt/kit'
|
|
135
|
+
|
|
136
|
+
export default defineNuxtModule({
|
|
137
|
+
meta: { name: 'my-module' },
|
|
138
|
+
setup (_options, nuxt) {
|
|
139
|
+
const { resolve } = createResolver(import.meta.url)
|
|
140
|
+
|
|
141
|
+
const someServerFile = resolveServerVariant({
|
|
142
|
+
nuxt: resolve('./runtime/server'),
|
|
143
|
+
nitro2: resolve('./runtime/server.legacy'),
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
if (someServerFile) {
|
|
147
|
+
nuxt.options.alias['#my-module/server'] = someServerFile
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
addServerImports({
|
|
151
|
+
name: 'verifyToken',
|
|
152
|
+
from: { nuxt: resolve('./runtime/verify'), nitro2: resolve('./runtime/verify.legacy') },
|
|
153
|
+
})
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If running with `nitropack` v2, `nitro2` will always be preferred over `nuxt`, and if running with `nitro` v3, `nitro3` will always be preferred over `nuxt`. So, if you need to test the `nuxt` variant, set `server.builder` in your test fixture to a builder that is not Nitro, such as `@nuxt/vite-server`.
|
|
130
159
|
|
|
131
160
|
### Declaring What You Cannot Infer
|
|
132
161
|
|