fix(nuxt): ignore falsy modules (#19684)

This commit is contained in:
Anthony Fu 2023-03-20 00:16:13 +01:00 committed by GitHub
parent 53d902ad5e
commit ce575b49e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 5 deletions

View File

@ -132,7 +132,7 @@ export const schemaTemplate: NuxtTemplate<TemplateContext> = {
...modules.map(([configKey, importName]) =>
` [${configKey}]?: typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
),
modules.length > 0 ? ` modules?: (NuxtModule | string | [NuxtModule | string, Record<string, any>] | ${modules.map(([configKey, importName]) => `[${genString(importName)}, Exclude<NuxtConfig[${configKey}], boolean>]`).join(' | ')})[],` : '',
modules.length > 0 ? ` modules?: (undefined | null | false | NuxtModule | string | [NuxtModule | string, Record<string, any>] | ${modules.map(([configKey, importName]) => `[${genString(importName)}, Exclude<NuxtConfig[${configKey}], boolean>]`).join(' | ')})[],` : '',
' }',
generateTypes(await resolveSchema(Object.fromEntries(Object.entries(nuxt.options.runtimeConfig).filter(([key]) => key !== 'public'))),
{

View File

@ -194,9 +194,11 @@ export default defineUntypedSchema({
* function () {}
* ]
* ```
* @type {(typeof import('../src/types/module').NuxtModule | string | [typeof import('../src/types/module').NuxtModule | string, Record<string, any>])[]}
* @type {(typeof import('../src/types/module').NuxtModule | string | [typeof import('../src/types/module').NuxtModule | string, Record<string, any>] | undefined | null | false)[]}
*/
modules: [],
modules: {
$resolve: val => [].concat(val).filter(Boolean)
},
/**
* Customize default directory structure used by Nuxt.

View File

@ -1 +1,3 @@
export default defineNuxtConfig({})
export default defineNuxtConfig({
modules: [undefined]
})

View File

@ -135,7 +135,9 @@ export default defineNuxtConfig({
function (_, nuxt) {
nuxt.options.optimization.treeShake.composables.server[nuxt.options.rootDir] = ['useClientOnlyComposable', 'setTitleToPink']
nuxt.options.optimization.treeShake.composables.client[nuxt.options.rootDir] = ['useServerOnlyComposable']
}
},
// To test falsy module values
undefined
],
vite: {
logLevel: 'silent'