Repository: nuxt/nuxt
File: packages/nuxt/src/core/templates.ts (TypeScript)

Code before:
      '  }',
      '  interface NuxtOptions {',
      ...moduleOptionsInterface({ addJSDocTags: false, unresolved: false }),
      '  }',
      '  interface NuxtConfig {',
      // TypeScript will duplicate the jsdoc tags if we augment it twice
      // So here we only generate tags for `nuxt/schema`
      ...moduleOptionsInterface({ addJSDocTags: false, unresolved: true }),
      '  }',
      '}',
      'declare module \'nuxt/schema\' {',
      '  interface ModuleDependencies {',
      moduleDependencies,
      '  }',
      '  interface NuxtOptions {',
      ...moduleOptionsInterface({ addJSDocTags: true, unresolved: false }),
      '  }',
      '  interface NuxtConfig {',
      ...moduleOptionsInterface({ addJSDocTags: true, unresolved: true }),
      '  }',
      '}',
    ].join('\n')
  },
}

export const disabledModulesTypeTemplate: NuxtTemplate = {
  filename: 'types/disabled-modules.d.ts',
  getContents: ({ nuxt }) => {
    const layerModules = nuxt.options._layerModules || []

    // If no layer modules, just export an empty declaration
    if (layerModules.length === 0) {
      return [
        'export {}',
      ].join('\n')
    }

    // Generate a union type of all layer module names
    const moduleUnion = layerModules.map(m => genString(m)).join(' | ')

    return [
      `type LayerModules = ${moduleUnion}`,
      '',
      'declare module \'@nuxt/schema\' {',
      '  interface NuxtConfig {',
      '    /**',
      '     * Modules to disable from layers.',
      '     */',
      '    disabledModules?: LayerModules[]',
      '  }',
      '}',

Review comment (suggestion):
I don't want to support `disabledModules` as a separate config option. we'll do this simply by supporting e.g. `fonts: false`.

Code after:
      '  }',
      '  interface NuxtOptions {',
      ...moduleOptionsInterface({ addJSDocTags: false, unresolved: false }),
      '  }',
      '  interface NuxtConfig {',
      // TypeScript will duplicate the jsdoc tags if we augment it twice
      // So here we only generate tags for `nuxt/schema`
      ...moduleOptionsInterface({ addJSDocTags: false, unresolved: true }),
      '  }',
      '}',
      'declare module \'nuxt/schema\' {',
      '  interface ModuleDependencies {',
      moduleDependencies,
      '  }',
      '  interface NuxtOptions {',
      ...moduleOptionsInterface({ addJSDocTags: true, unresolved: false }),
      '  }',
      '  interface NuxtConfig {',
      ...moduleOptionsInterface({ addJSDocTags: true, unresolved: true }),
      '  }',
      '}',
    ].join('\n')
  },
}

// Add layouts template
export const layoutTemplate: NuxtTemplate = {
  filename: 'layouts.mjs',
  getContents ({ app }) {
    const layoutsObject = genObjectFromRawEntries(Object.values(app.layouts).map(({ name, file }) => {
      return [name, `defineAsyncComponent(${genDynamicImport(file, { interopDefault: true })})`]
    }))
    return [
      `import { defineAsyncComponent } from 'vue'`,
      `export default ${layoutsObject}`,
    ].join('\n')
  },
}

// Add middleware template
export const middlewareTemplate: NuxtTemplate = {
  filename: 'middleware.mjs',
  getContents ({ app, nuxt }) {
    const globalMiddleware = app.middleware.filter(mw => mw.global)
    const namedMiddleware = app.middleware.filter(mw => !mw.global)
    const alias = nuxt.options.dev ? { ...nuxt?.options.alias || {}, ...strippedAtAliases } : {}
    return [
      ...globalMiddleware.map(mw => genImport(mw.path, genSafeVariableName(mw.name))),
      ...!nuxt.options.dev
        ? [
            `export const globalMiddleware = ${genArrayFromRaw(globalMiddleware.map(mw => genSafeVariableName(mw.name)))}`,