chore(schema): enable linting (#22546)

This commit is contained in:
Damian Głowala 2023-08-08 22:55:29 +02:00 committed by GitHub
parent 5d86580f62
commit 5244555880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 251 additions and 192 deletions

View File

@ -1,5 +1,5 @@
dist dist
node_modules node_modules
schema packages/schema/schema
**/*.tmpl.* **/*.tmpl.*
sw.js sw.js

View File

@ -100,6 +100,21 @@
"definedTags": ["__NO_SIDE_EFFECTS__"] "definedTags": ["__NO_SIDE_EFFECTS__"]
}] }]
}, },
"overrides": [
{
"files": ["packages/schema/**"],
"rules": {
"jsdoc/no-undefined-types": "off",
"jsdoc/valid-types": "off",
"jsdoc/check-tag-names": [
"error",
{
"definedTags": ["experimental"]
}
]
}
}
],
"settings": { "settings": {
"jsdoc": { "jsdoc": {
"ignoreInternal": true, "ignoreInternal": true,

View File

@ -34,6 +34,7 @@ export default defineUntypedSchema({
/** /**
* An array of custom directories that will be auto-imported. * An array of custom directories that will be auto-imported.
* Note that this option will not override the default directories (~/composables, ~/utils). * Note that this option will not override the default directories (~/composables, ~/utils).
*
* @example * @example
* ```js * ```js
* imports: { * imports: {
@ -57,9 +58,8 @@ export default defineUntypedSchema({
* Manually disable nuxt telemetry. * Manually disable nuxt telemetry.
* *
* @see [Nuxt Telemetry](https://github.com/nuxt/telemetry) for more information. * @see [Nuxt Telemetry](https://github.com/nuxt/telemetry) for more information.
*
* @type {boolean | Record<string, any>} * @type {boolean | Record<string, any>}
*/ */
telemetry: undefined, telemetry: undefined,
/** /**

View File

@ -10,6 +10,7 @@ export default defineUntypedSchema({
vue: { vue: {
/** /**
* Options for the Vue compiler that will be passed at build time. * Options for the Vue compiler that will be passed at build time.
*
* @see [documentation](https://vuejs.org/api/application.html#app-config-compileroptions) * @see [documentation](https://vuejs.org/api/application.html#app-config-compileroptions)
* @type {typeof import('@vue/compiler-core').CompilerOptions} * @type {typeof import('@vue/compiler-core').CompilerOptions}
*/ */
@ -19,11 +20,12 @@ export default defineUntypedSchema({
* Include Vue compiler in runtime bundle. * Include Vue compiler in runtime bundle.
*/ */
runtimeCompiler: { runtimeCompiler: {
$resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false, $resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false
}, },
/** /**
* Vue Experimental: Enable reactive destructure for `defineProps` * Vue Experimental: Enable reactive destructure for `defineProps`
*
* @see [Vue RFC#502](https://github.com/vuejs/rfcs/discussions/502) * @see [Vue RFC#502](https://github.com/vuejs/rfcs/discussions/502)
* @type {boolean} * @type {boolean}
*/ */
@ -31,6 +33,7 @@ export default defineUntypedSchema({
/** /**
* Vue Experimental: Enable macro `defineModel` * Vue Experimental: Enable macro `defineModel`
*
* @see [Vue RFC#503](https://github.com/vuejs/rfcs/discussions/503) * @see [Vue RFC#503](https://github.com/vuejs/rfcs/discussions/503)
* @type {boolean} * @type {boolean}
*/ */
@ -45,24 +48,26 @@ export default defineUntypedSchema({
* The base path of your Nuxt application. * The base path of your Nuxt application.
* *
* This can be set at runtime by setting the NUXT_APP_BASE_URL environment variable. * This can be set at runtime by setting the NUXT_APP_BASE_URL environment variable.
*
* @example * @example
* ```bash * ```bash
* NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs * NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs
* ``` * ```
*/ */
baseURL: { baseURL: {
$resolve: async (val) => val || process.env.NUXT_APP_BASE_URL || '/', $resolve: val => val || process.env.NUXT_APP_BASE_URL || '/'
}, },
/** The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime. */ /** The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime. */
buildAssetsDir: { buildAssetsDir: {
$resolve: async (val) => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/', $resolve: val => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/'
}, },
/** /**
* An absolute URL to serve the public folder from (production-only). * An absolute URL to serve the public folder from (production-only).
* *
* This can be set to a different value at runtime by setting the `NUXT_APP_CDN_URL` environment variable. * This can be set to a different value at runtime by setting the `NUXT_APP_CDN_URL` environment variable.
*
* @example * @example
* ```bash * ```bash
* NUXT_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs * NUXT_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs
@ -175,10 +180,11 @@ export default defineUntypedSchema({
* Customize Nuxt root element tag. * Customize Nuxt root element tag.
* *
*/ */
rootTag: 'div', rootTag: 'div'
}, },
/** A path to an HTML file, the contents of which will be inserted into any HTML page /**
* A path to an HTML file, the contents of which will be inserted into any HTML page
* rendered with `ssr: false`. * rendered with `ssr: false`.
* *
* By default Nuxt will look in `~/app/spa-loading-template.html` for this file. * By default Nuxt will look in `~/app/spa-loading-template.html` for this file.
@ -230,7 +236,6 @@ export default defineUntypedSchema({
* } * }
* </style> * </style>
* ``` * ```
*
* @type {string | false} * @type {string | false}
*/ */
spaLoadingTemplate: { spaLoadingTemplate: {
@ -249,9 +254,7 @@ export default defineUntypedSchema({
* @note Plugins are also auto-registered from the `~/plugins` directory * @note Plugins are also auto-registered from the `~/plugins` directory
* and these plugins do not need to be listed in `nuxt.config` unless you * and these plugins do not need to be listed in `nuxt.config` unless you
* need to customize their order. All plugins are deduplicated by their src path. * need to customize their order. All plugins are deduplicated by their src path.
*
* @see https://nuxt.com/docs/guide/directory-structure/plugins * @see https://nuxt.com/docs/guide/directory-structure/plugins
*
* @example * @example
* ```js * ```js
* plugins: [ * plugins: [

View File

@ -16,7 +16,7 @@ export default defineUntypedSchema({
} }
const map: Record<string, string> = { const map: Record<string, string> = {
vite: '@nuxt/vite-builder', vite: '@nuxt/vite-builder',
webpack: '@nuxt/webpack-builder', webpack: '@nuxt/webpack-builder'
} }
return map[val] || val || (await get('vite') === false ? map.webpack : map.vite) return map[val] || val || (await get('vite') === false ? map.webpack : map.vite)
} }
@ -36,7 +36,7 @@ export default defineUntypedSchema({
server: true, server: true,
client: await get('dev') client: await get('dev')
}) })
}, }
}, },
/** /**
@ -96,7 +96,6 @@ export default defineUntypedSchema({
* } * }
* ] * ]
* ``` * ```
*
* @type {typeof import('../src/types/nuxt').NuxtTemplate<any>[]} * @type {typeof import('../src/types/nuxt').NuxtTemplate<any>[]}
*/ */
templates: [], templates: [],
@ -113,7 +112,6 @@ export default defineUntypedSchema({
* } * }
* ``` * ```
* @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options | typeof import('rollup-plugin-visualizer').PluginVisualizerOptions} * @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options | typeof import('rollup-plugin-visualizer').PluginVisualizerOptions}
*
*/ */
analyze: { analyze: {
$resolve: async (val, get) => { $resolve: async (val, get) => {
@ -128,7 +126,7 @@ export default defineUntypedSchema({
filename: join(analyzeDir, '{name}.html') filename: join(analyzeDir, '{name}.html')
} }
} }
}, }
}, },
/** /**
@ -147,13 +145,13 @@ export default defineUntypedSchema({
* @type {Array<{ name: string, source?: string | RegExp, argumentLength: number }>} * @type {Array<{ name: string, source?: string | RegExp, argumentLength: number }>}
*/ */
keyedComposables: { keyedComposables: {
$resolve: (val) => [ $resolve: val => [
{ name: 'defineNuxtComponent', argumentLength: 2 }, { name: 'defineNuxtComponent', argumentLength: 2 },
{ name: 'useState', argumentLength: 2 }, { name: 'useState', argumentLength: 2 },
{ name: 'useFetch', argumentLength: 3 }, { name: 'useFetch', argumentLength: 3 },
{ name: 'useAsyncData', argumentLength: 3 }, { name: 'useAsyncData', argumentLength: 3 },
{ name: 'useLazyAsyncData', argumentLength: 3 }, { name: 'useLazyAsyncData', argumentLength: 3 },
{ name: 'useLazyFetch', argumentLength: 3 }, { name: 'useLazyFetch', argumentLength: 3 }
].concat(val).filter(Boolean) ].concat(val).filter(Boolean)
}, },
@ -172,18 +170,22 @@ export default defineUntypedSchema({
composables: { composables: {
server: { server: {
$resolve: async (val, get) => defu(val || {}, $resolve: async (val, get) => defu(val || {},
await get('dev') ? {} : { await get('dev')
vue: ['onBeforeMount', 'onMounted', 'onBeforeUpdate', 'onRenderTracked', 'onRenderTriggered', 'onActivated', 'onDeactivated', 'onBeforeUnmount'], ? {}
'#app': ['definePayloadReviver', 'definePageMeta'] : {
} vue: ['onBeforeMount', 'onMounted', 'onBeforeUpdate', 'onRenderTracked', 'onRenderTriggered', 'onActivated', 'onDeactivated', 'onBeforeUnmount'],
'#app': ['definePayloadReviver', 'definePageMeta']
}
) )
}, },
client: { client: {
$resolve: async (val, get) => defu(val || {}, $resolve: async (val, get) => defu(val || {},
await get('dev') ? {} : { await get('dev')
vue: ['onServerPrefetch', 'onRenderTracked', 'onRenderTriggered'], ? {}
'#app': ['definePayloadReducer', 'definePageMeta'] : {
} vue: ['onServerPrefetch', 'onRenderTracked', 'onRenderTriggered'],
'#app': ['definePayloadReducer', 'definePageMeta']
}
) )
} }
} }

View File

@ -14,7 +14,6 @@ export default defineUntypedSchema({
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository. * You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
* *
* @type {string|string[]} * @type {string|string[]}
*
*/ */
extends: null, extends: null,
@ -26,7 +25,6 @@ export default defineUntypedSchema({
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository. * You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
* *
* @type {string} * @type {string}
*
*/ */
theme: null, theme: null,
@ -170,7 +168,7 @@ export default defineUntypedSchema({
* *
*/ */
debug: { debug: {
$resolve: async (val, get) => val ?? isDebug $resolve: val => val ?? isDebug
}, },
/** /**
@ -178,7 +176,7 @@ export default defineUntypedSchema({
* If set to `false` generated pages will have no content. * If set to `false` generated pages will have no content.
*/ */
ssr: { ssr: {
$resolve: (val) => val ?? true, $resolve: val => val ?? true
}, },
/** /**
@ -191,7 +189,6 @@ export default defineUntypedSchema({
* (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used. * (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
* *
* @note Modules are executed sequentially so the order is important. * @note Modules are executed sequentially so the order is important.
*
* @example * @example
* ```js * ```js
* modules: [ * modules: [
@ -252,12 +249,12 @@ export default defineUntypedSchema({
* and copied across into your `dist` folder when your app is generated. * and copied across into your `dist` folder when your app is generated.
*/ */
public: { public: {
$resolve: async (val, get) => val || await get('dir.static') || 'public', $resolve: async (val, get) => val || await get('dir.static') || 'public'
}, },
static: { static: {
$schema: { deprecated: 'use `dir.public` option instead' }, $schema: { deprecated: 'use `dir.public` option instead' },
$resolve: async (val, get) => val || await get('dir.public') || 'public', $resolve: async (val, get) => val || await get('dir.public') || 'public'
} }
}, },
@ -274,11 +271,9 @@ export default defineUntypedSchema({
* *
* @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access * @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
* your alias by prefixing it with `~`. * your alias by prefixing it with `~`.
*
* @note These aliases will be automatically added to the generated `.nuxt/tsconfig.json` so you can get full * @note These aliases will be automatically added to the generated `.nuxt/tsconfig.json` so you can get full
* type support and path auto-complete. In case you need to extend options provided by `./.nuxt/tsconfig.json` * type support and path auto-complete. In case you need to extend options provided by `./.nuxt/tsconfig.json`
* further, make sure to add them here or within the `typescript.tsConfig` property in `nuxt.config`. * further, make sure to add them here or within the `typescript.tsConfig` property in `nuxt.config`.
*
* @example * @example
* ```js * ```js
* export default { * export default {
@ -309,7 +304,6 @@ export default defineUntypedSchema({
* } * }
* </style> * </style>
* ``` * ```
*
* @type {Record<string, string>} * @type {Record<string, string>}
*/ */
alias: { alias: {
@ -328,7 +322,6 @@ export default defineUntypedSchema({
* Pass options directly to `node-ignore` (which is used by Nuxt to ignore files). * Pass options directly to `node-ignore` (which is used by Nuxt to ignore files).
* *
* @see [node-ignore](https://github.com/kaelzhang/node-ignore) * @see [node-ignore](https://github.com/kaelzhang/node-ignore)
*
* @example * @example
* ```js * ```js
* ignoreOptions: { * ignoreOptions: {
@ -343,7 +336,7 @@ export default defineUntypedSchema({
* building if its filename starts with the prefix specified by `ignorePrefix`. * building if its filename starts with the prefix specified by `ignorePrefix`.
*/ */
ignorePrefix: { ignorePrefix: {
$resolve: (val) => val ?? '-', $resolve: val => val ?? '-'
}, },
/** /**
@ -372,7 +365,7 @@ export default defineUntypedSchema({
* @type {Array<string | RegExp>} * @type {Array<string | RegExp>}
*/ */
watch: { watch: {
$resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp), $resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp)
}, },
/** /**
@ -385,7 +378,7 @@ export default defineUntypedSchema({
* `watchOptions` to pass directly to webpack. * `watchOptions` to pass directly to webpack.
* *
* @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions). * @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
* */ */
webpack: { webpack: {
aggregateTimeout: 1000 aggregateTimeout: 1000
}, },
@ -464,7 +457,7 @@ export default defineUntypedSchema({
app: { app: {
baseURL: (await get('app')).baseURL, baseURL: (await get('app')).baseURL,
buildAssetsDir: (await get('app')).buildAssetsDir, buildAssetsDir: (await get('app')).buildAssetsDir,
cdnURL: (await get('app')).cdnURL, cdnURL: (await get('app')).cdnURL
} }
}) })
} }

View File

@ -17,10 +17,7 @@ export default defineUntypedSchema({
* } * }
* }) * })
* ``` * ```
*
*
* @type {boolean | { key: string; cert: string }} * @type {boolean | { key: string; cert: string }}
*
*/ */
https: false, https: false,
@ -43,6 +40,6 @@ export default defineUntypedSchema({
* *
* @type {(data: { loading?: string }) => string} * @type {(data: { loading?: string }) => string}
*/ */
loadingTemplate: loadingTemplate loadingTemplate
} }
}) })

View File

@ -6,11 +6,12 @@ export default defineUntypedSchema({
* Set to true to generate an async entry point for the Vue bundle (for module federation support). * Set to true to generate an async entry point for the Vue bundle (for module federation support).
*/ */
asyncEntry: { asyncEntry: {
$resolve: (val) => val ?? false $resolve: val => val ?? false
}, },
/** /**
* Enable Vue's reactivity transform * Enable Vue's reactivity transform
*
* @see https://vuejs.org/guide/extras/reactivity-transform.html * @see https://vuejs.org/guide/extras/reactivity-transform.html
* *
* Warning: Reactivity transform feature has been marked as deprecated in Vue 3.3 and is planned to be * Warning: Reactivity transform feature has been marked as deprecated in Vue 3.3 and is planned to be
@ -23,12 +24,14 @@ export default defineUntypedSchema({
// https://github.com/unjs/nitro/issues/1118 // https://github.com/unjs/nitro/issues/1118
/** /**
* Externalize `vue`, `@vue/*` and `vue-router` when building. * Externalize `vue`, `@vue/*` and `vue-router` when building.
*
* @see https://github.com/nuxt/nuxt/issues/13632 * @see https://github.com/nuxt/nuxt/issues/13632
*/ */
externalVue: true, externalVue: true,
/** /**
* Tree shakes contents of client-only components from server bundle. * Tree shakes contents of client-only components from server bundle.
*
* @see https://github.com/nuxt/framework/pull/5750 * @see https://github.com/nuxt/framework/pull/5750
*/ */
treeshakeClientOnly: true, treeshakeClientOnly: true,
@ -47,7 +50,7 @@ export default defineUntypedSchema({
* @type {false | 'manual' | 'automatic'} * @type {false | 'manual' | 'automatic'}
*/ */
emitRouteChunkError: { emitRouteChunkError: {
$resolve: val => { $resolve: (val) => {
if (val === true) { if (val === true) {
return 'manual' return 'manual'
} }
@ -55,7 +58,7 @@ export default defineUntypedSchema({
return 'automatic' return 'automatic'
} }
return val ?? 'automatic' return val ?? 'automatic'
}, }
}, },
/** /**
@ -113,7 +116,7 @@ export default defineUntypedSchema({
/** /**
* Disable vue server renderer endpoint within nitro. * Disable vue server renderer endpoint within nitro.
*/ */
noVueServer: false, noVueServer: false,
/** /**
@ -148,6 +151,7 @@ export default defineUntypedSchema({
/** /**
* Experimental component islands support with <NuxtIsland> and .island.vue files. * Experimental component islands support with <NuxtIsland> and .island.vue files.
*
* @type {true | 'local' | 'local+remote' | false} * @type {true | 'local' | 'local+remote' | false}
*/ */
componentIslands: { componentIslands: {

View File

@ -14,14 +14,13 @@ export default defineUntypedSchema({
* ```js * ```js
* routes: ['/users/1', '/users/2', '/users/3'] * routes: ['/users/1', '/users/2', '/users/3']
* ``` * ```
*
* @type {string | string[]} * @type {string | string[]}
*/ */
routes: [], routes: [],
/** /**
* This option is no longer used. Instead, use `nitro.prerender.ignore`. * This option is no longer used. Instead, use `nitro.prerender.ignore`.
* *
* @deprecated * @deprecated
*/ */
exclude: [] exclude: []

View File

@ -5,7 +5,6 @@ export default defineUntypedSchema({
* Configuration for Nitro. * Configuration for Nitro.
* *
* @see https://nitro.unjs.io/config/ * @see https://nitro.unjs.io/config/
*
* @type {typeof import('nitropack')['NitroConfig']} * @type {typeof import('nitropack')['NitroConfig']}
*/ */
nitro: { nitro: {
@ -21,9 +20,7 @@ export default defineUntypedSchema({
* Global route options applied to matching server routes. * Global route options applied to matching server routes.
* *
* @experimental This is an experimental feature and API may change in the future. * @experimental This is an experimental feature and API may change in the future.
*
* @see https://nitro.unjs.io/config/#routerules * @see https://nitro.unjs.io/config/#routerules
*
* @type {typeof import('nitropack')['NitroConfig']['routeRules']} * @type {typeof import('nitropack')['NitroConfig']['routeRules']}
*/ */
routeRules: {}, routeRules: {},
@ -39,16 +36,13 @@ export default defineUntypedSchema({
* - lazy: Specifies whether to use lazy loading to import the handler. * - lazy: Specifies whether to use lazy loading to import the handler.
* *
* @see https://nuxt.com/docs/guide/directory-structure/server * @see https://nuxt.com/docs/guide/directory-structure/server
*
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt. * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
*
* @example * @example
* ```js * ```js
* serverHandlers: [ * serverHandlers: [
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' } * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
* ] * ]
* ``` * ```
*
* @type {typeof import('nitropack')['NitroEventHandler'][]} * @type {typeof import('nitropack')['NitroEventHandler'][]}
*/ */
serverHandlers: [], serverHandlers: [],
@ -57,7 +51,6 @@ export default defineUntypedSchema({
* Nitro development-only server handlers. * Nitro development-only server handlers.
* *
* @see https://nitro.unjs.io/guide/routing * @see https://nitro.unjs.io/guide/routing
*
* @type {typeof import('nitropack')['NitroDevEventHandler'][]} * @type {typeof import('nitropack')['NitroDevEventHandler'][]}
*/ */
devServerHandlers: [] devServerHandlers: []

View File

@ -8,6 +8,7 @@ export default defineUntypedSchema({
* Options for configuring PostCSS plugins. * Options for configuring PostCSS plugins.
* *
* https://postcss.org/ * https://postcss.org/
*
* @type {Record<string, any>} * @type {Record<string, any>}
*/ */
plugins: { plugins: {
@ -15,16 +16,18 @@ export default defineUntypedSchema({
* https://github.com/postcss/postcss-import * https://github.com/postcss/postcss-import
*/ */
'postcss-import': { 'postcss-import': {
$resolve: async (val, get) => val !== false ? defu(val || {}, { $resolve: async (val, get) => val !== false
resolve: createResolver({ ? defu(val || {}, {
alias: { ...(await get('alias')) }, resolve: createResolver({
modules: [ alias: { ...(await get('alias')) },
await get('srcDir'), modules: [
await get('rootDir'), await get('srcDir'),
...(await get('modulesDir')) await get('rootDir'),
] ...(await get('modulesDir'))
]
})
}) })
}) : val, : val
}, },
/** /**

View File

@ -11,7 +11,6 @@ export default defineUntypedSchema({
* *
* @see [documentation](https://router.vuejs.org/api/interfaces/routeroptions.html). * @see [documentation](https://router.vuejs.org/api/interfaces/routeroptions.html).
* @type {typeof import('../src/types/router').RouterConfigSerializable} * @type {typeof import('../src/types/router').RouterConfigSerializable}
*
*/ */
options: {} options: {}
} }

View File

@ -24,7 +24,7 @@ export default defineUntypedSchema({
* @type {'vite' | 'webpack' | 'shared' | false | undefined} * @type {'vite' | 'webpack' | 'shared' | false | undefined}
*/ */
builder: { builder: {
$resolve: async (val, get) => val ?? null $resolve: val => val ?? null
}, },
/** /**
@ -39,13 +39,13 @@ export default defineUntypedSchema({
* Requires to install `typescript` and `vue-tsc` as dev dependencies. * Requires to install `typescript` and `vue-tsc` as dev dependencies.
* *
* @see https://nuxt.com/docs/guide/concepts/typescript * @see https://nuxt.com/docs/guide/concepts/typescript
*
* @type {boolean | 'build'} * @type {boolean | 'build'}
*/ */
typeCheck: false, typeCheck: false,
/** /**
* You can extend generated `.nuxt/tsconfig.json` using this option. * You can extend generated `.nuxt/tsconfig.json` using this option.
*
* @type {typeof import('pkg-types')['TSConfig']} * @type {typeof import('pkg-types')['TSConfig']}
*/ */
tsConfig: {}, tsConfig: {},

View File

@ -48,11 +48,11 @@ export default defineUntypedSchema({
}, },
script: { script: {
propsDestructure: { propsDestructure: {
$resolve: async (val, get) => val ?? Boolean((await get('vue')).propsDestructure), $resolve: async (val, get) => val ?? Boolean((await get('vue')).propsDestructure)
}, },
defineModel: { defineModel: {
$resolve: async (val, get) => val ?? Boolean((await get('vue')).defineModel), $resolve: async (val, get) => val ?? Boolean((await get('vue')).defineModel)
}, }
} }
}, },
vueJsx: { vueJsx: {

View File

@ -65,7 +65,6 @@ export default defineUntypedSchema({
* Extracting into multiple CSS files is better for caching and preload isolation. It * Extracting into multiple CSS files is better for caching and preload isolation. It
* can also improve page performance by downloading and resolving only those resources * can also improve page performance by downloading and resolving only those resources
* that are needed. * that are needed.
*
* @example * @example
* ```js * ```js
* export default { * export default {
@ -113,14 +112,12 @@ export default defineUntypedSchema({
* as most browsers will cache the asset and not detect the changes on first load. * as most browsers will cache the asset and not detect the changes on first load.
* *
* This example changes fancy chunk names to numerical ids: * This example changes fancy chunk names to numerical ids:
*
* @example * @example
* ```js * ```js
* filenames: { * filenames: {
* chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js') * chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js')
* } * }
* ``` * ```
*
* @type { * @type {
* Record< * Record<
* string, * string,
@ -140,8 +137,8 @@ export default defineUntypedSchema({
* } * }
*/ */
filenames: { filenames: {
app: ({ isDev }: { isDev: boolean }) => isDev ? `[name].js` : `[contenthash:7].js`, app: ({ isDev }: { isDev: boolean }) => isDev ? '[name].js' : '[contenthash:7].js',
chunk: ({ isDev }: { isDev: boolean }) => isDev ? `[name].js` : `[contenthash:7].js`, chunk: ({ isDev }: { isDev: boolean }) => isDev ? '[name].js' : '[contenthash:7].js',
css: ({ isDev }: { isDev: boolean }) => isDev ? '[name].css' : 'css/[contenthash:7].css', css: ({ isDev }: { isDev: boolean }) => isDev ? '[name].css' : 'css/[contenthash:7].css',
img: ({ isDev }: { isDev: boolean }) => isDev ? '[path][name].[ext]' : 'img/[name].[contenthash:7].[ext]', img: ({ isDev }: { isDev: boolean }) => isDev ? '[path][name].[ext]' : 'img/[name].[contenthash:7].[ext]',
font: ({ isDev }: { isDev: boolean }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:7].[ext]', font: ({ isDev }: { isDev: boolean }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:7].[ext]',
@ -168,14 +165,15 @@ export default defineUntypedSchema({
/** /**
* See https://github.com/esbuild-kit/esbuild-loader * See https://github.com/esbuild-kit/esbuild-loader
*
* @type {Omit<typeof import('esbuild-loader')['LoaderOptions'], 'loader'>} * @type {Omit<typeof import('esbuild-loader')['LoaderOptions'], 'loader'>}
*/ */
esbuild: {}, esbuild: {},
/** /**
* See: https://github.com/webpack-contrib/file-loader#options * See: https://github.com/webpack-contrib/file-loader#options
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
* *
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
* @default * @default
* ```ts * ```ts
* { esModule: false } * { esModule: false }
@ -185,8 +183,8 @@ export default defineUntypedSchema({
/** /**
* See: https://github.com/webpack-contrib/file-loader#options * See: https://github.com/webpack-contrib/file-loader#options
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
* *
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
* @default * @default
* ```ts * ```ts
* { esModule: false, limit: 1000 } * { esModule: false, limit: 1000 }
@ -196,8 +194,8 @@ export default defineUntypedSchema({
/** /**
* See: https://github.com/webpack-contrib/file-loader#options * See: https://github.com/webpack-contrib/file-loader#options
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
* *
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
* @default * @default
* ```ts * ```ts
* { esModule: false, limit: 1000 } * { esModule: false, limit: 1000 }
@ -207,12 +205,14 @@ export default defineUntypedSchema({
/** /**
* See: https://pugjs.org/api/reference.html#options * See: https://pugjs.org/api/reference.html#options
*
* @type {typeof import('pug')['Options']} * @type {typeof import('pug')['Options']}
*/ */
pugPlain: {}, pugPlain: {},
/** /**
* See [vue-loader](https://github.com/vuejs/vue-loader) for available options. * See [vue-loader](https://github.com/vuejs/vue-loader) for available options.
*
* @type {Partial<typeof import('vue-loader')['VueLoaderOptions']>} * @type {Partial<typeof import('vue-loader')['VueLoaderOptions']>}
*/ */
vue: { vue: {
@ -224,13 +224,13 @@ export default defineUntypedSchema({
}, },
compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue.compilerOptions')) }, compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue.compilerOptions')) },
propsDestructure: { $resolve: async (val, get) => val ?? Boolean(await get('vue.propsDestructure')) }, propsDestructure: { $resolve: async (val, get) => val ?? Boolean(await get('vue.propsDestructure')) },
defineModel: { $resolve: async (val, get) => val ?? Boolean(await get('vue.defineModel')) }, defineModel: { $resolve: async (val, get) => val ?? Boolean(await get('vue.defineModel')) }
}, },
css: { css: {
importLoaders: 0, importLoaders: 0,
url: { url: {
filter: (url: string, resourcePath: string) => !url.startsWith('/'), filter: (url: string, _resourcePath: string) => !url.startsWith('/')
}, },
esModule: false esModule: false
}, },
@ -238,7 +238,7 @@ export default defineUntypedSchema({
cssModules: { cssModules: {
importLoaders: 0, importLoaders: 0,
url: { url: {
filter: (url: string, resourcePath: string) => !url.startsWith('/'), filter: (url: string, _resourcePath: string) => !url.startsWith('/')
}, },
esModule: false, esModule: false,
modules: { modules: {
@ -253,8 +253,8 @@ export default defineUntypedSchema({
/** /**
* See: https://github.com/webpack-contrib/sass-loader#options * See: https://github.com/webpack-contrib/sass-loader#options
*
* @type {typeof import('sass-loader')['Options']} * @type {typeof import('sass-loader')['Options']}
*
* @default * @default
* ```ts * ```ts
* { * {
@ -272,6 +272,7 @@ export default defineUntypedSchema({
/** /**
* See: https://github.com/webpack-contrib/sass-loader#options * See: https://github.com/webpack-contrib/sass-loader#options
*
* @type {typeof import('sass-loader')['Options']} * @type {typeof import('sass-loader')['Options']}
*/ */
scss: {}, scss: {},
@ -312,7 +313,6 @@ export default defineUntypedSchema({
* Defaults to true when `extractCSS` is enabled. * Defaults to true when `extractCSS` is enabled.
* *
* @see [css-minimizer-webpack-plugin documentation](https://github.com/webpack-contrib/css-minimizer-webpack-plugin). * @see [css-minimizer-webpack-plugin documentation](https://github.com/webpack-contrib/css-minimizer-webpack-plugin).
*
* @type {false | typeof import('css-minimizer-webpack-plugin').BasePluginOptions & typeof import('css-minimizer-webpack-plugin').DefinedDefaultMinimizerAndOptions<any>} * @type {false | typeof import('css-minimizer-webpack-plugin').BasePluginOptions & typeof import('css-minimizer-webpack-plugin').DefinedDefaultMinimizerAndOptions<any>}
*/ */
optimizeCSS: { optimizeCSS: {
@ -321,6 +321,7 @@ export default defineUntypedSchema({
/** /**
* Configure [webpack optimization](https://webpack.js.org/configuration/optimization/). * Configure [webpack optimization](https://webpack.js.org/configuration/optimization/).
*
* @type {false | typeof import('webpack').Configuration['optimization']} * @type {false | typeof import('webpack').Configuration['optimization']}
*/ */
optimization: { optimization: {
@ -350,11 +351,12 @@ export default defineUntypedSchema({
plugins: { plugins: {
$resolve: async (val, get) => val ?? (await get('postcss.plugins')) $resolve: async (val, get) => val ?? (await get('postcss.plugins'))
} }
}, }
}, },
/** /**
* See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options. * See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options.
*
* @type {typeof import('webpack-dev-middleware').Options<typeof import('http').IncomingMessage, typeof import('http').ServerResponse>} * @type {typeof import('webpack-dev-middleware').Options<typeof import('http').IncomingMessage, typeof import('http').ServerResponse>}
*/ */
devMiddleware: { devMiddleware: {
@ -363,6 +365,7 @@ export default defineUntypedSchema({
/** /**
* See [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) for available options. * See [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) for available options.
*
* @type {typeof import('webpack-hot-middleware').MiddlewareOptions & { client?: typeof import('webpack-hot-middleware').ClientOptions }} * @type {typeof import('webpack-hot-middleware').MiddlewareOptions & { client?: typeof import('webpack-hot-middleware').ClientOptions }}
*/ */
hotMiddleware: {}, hotMiddleware: {},
@ -374,12 +377,14 @@ export default defineUntypedSchema({
/** /**
* Filters to hide build warnings. * Filters to hide build warnings.
*
* @type {Array<(warn: typeof import('webpack').WebpackError) => boolean>} * @type {Array<(warn: typeof import('webpack').WebpackError) => boolean>}
*/ */
warningIgnoreFilters: [], warningIgnoreFilters: [],
/** /**
* Configure [webpack experiments](https://webpack.js.org/configuration/experiments/) * Configure [webpack experiments](https://webpack.js.org/configuration/experiments/)
*
* @type {false | typeof import('webpack').Configuration['experiments']} * @type {false | typeof import('webpack').Configuration['experiments']}
*/ */
experiments: {} experiments: {}

View File

@ -1,4 +1,3 @@
// Types // Types
export * from './types/compatibility' export * from './types/compatibility'
export * from './types/components' export * from './types/components'

View File

@ -3,7 +3,6 @@ export interface NuxtCompatibility {
* Required nuxt version in semver format. * Required nuxt version in semver format.
* *
* @example `^2.14.0` or `>=3.0.0-27219851.6e49637`. * @example `^2.14.0` or `>=3.0.0-27219851.6e49637`.
*
*/ */
nuxt?: string nuxt?: string
@ -12,7 +11,7 @@ export interface NuxtCompatibility {
* *
* - `true`: When using Nuxt 2, using bridge module is required. * - `true`: When using Nuxt 2, using bridge module is required.
* - `false`: When using Nuxt 2, using bridge module is not supported. * - `false`: When using Nuxt 2, using bridge module is not supported.
*/ */
bridge?: boolean bridge?: boolean
} }

View File

@ -1,12 +1,12 @@
import type { KeepAliveProps, TransitionProps } from 'vue' import type { KeepAliveProps, TransitionProps } from 'vue'
import type { ConfigSchema } from '../../schema/config'
import type { ServerOptions as ViteServerOptions, UserConfig as ViteUserConfig } from 'vite' import type { ServerOptions as ViteServerOptions, UserConfig as ViteUserConfig } from 'vite'
import type { Options as VuePluginOptions } from '@vitejs/plugin-vue' import type { Options as VuePluginOptions } from '@vitejs/plugin-vue'
import type { Options as VueJsxPluginOptions } from '@vitejs/plugin-vue-jsx' import type { Options as VueJsxPluginOptions } from '@vitejs/plugin-vue-jsx'
import type { AppHeadMetaObject } from './head'
import type { Nuxt } from './nuxt'
import type { SchemaDefinition } from 'untyped' import type { SchemaDefinition } from 'untyped'
import type { NitroRuntimeConfig, NitroRuntimeConfigApp } from 'nitropack' import type { NitroRuntimeConfig, NitroRuntimeConfigApp } from 'nitropack'
import type { ConfigSchema } from '../../schema/config'
import type { Nuxt } from './nuxt'
import type { AppHeadMetaObject } from './head'
export type { SchemaDefinition } from 'untyped' export type { SchemaDefinition } from 'untyped'
type DeepPartial<T> = T extends Function ? T : T extends Record<string, any> ? { [P in keyof T]?: DeepPartial<T[P]> } : T type DeepPartial<T> = T extends Function ? T : T extends Record<string, any> ? { [P in keyof T]?: DeepPartial<T[P]> } : T
@ -63,22 +63,35 @@ type Overrideable<T extends Record<string, any>, Path extends string = ''> = {
: never : never
} }
/** User configuration in `nuxt.config` file */ // Runtime Config
export interface NuxtConfig extends DeepPartial<Omit<ConfigSchema, 'vite' | 'runtimeConfig'>> {
// Avoid DeepPartial for vite config interface (#4772)
vite?: ConfigSchema['vite']
runtimeConfig?: Overrideable<RuntimeConfig>
webpack?: DeepPartial<ConfigSchema['webpack']> & {
$client?: DeepPartial<ConfigSchema['webpack']>
$server?: DeepPartial<ConfigSchema['webpack']>
}
/** type RuntimeConfigNamespace = Record<string, unknown>
* Experimental custom config schema
* export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
* @see https://github.com/nuxt/nuxt/issues/15592
*/ export interface RuntimeConfig extends RuntimeConfigNamespace {
$schema?: SchemaDefinition app: NitroRuntimeConfigApp
/** Only available on the server. */
nitro?: NitroRuntimeConfig['nitro']
public: PublicRuntimeConfig
}
// User configuration in `nuxt.config` file
export interface NuxtConfig extends DeepPartial<Omit<ConfigSchema, 'vite' | 'runtimeConfig'>> {
// Avoid DeepPartial for vite config interface (#4772)
vite?: ConfigSchema['vite']
runtimeConfig?: Overrideable<RuntimeConfig>
webpack?: DeepPartial<ConfigSchema['webpack']> & {
$client?: DeepPartial<ConfigSchema['webpack']>
$server?: DeepPartial<ConfigSchema['webpack']>
}
/**
* Experimental custom config schema
*
* @see https://github.com/nuxt/nuxt/issues/15592
*/
$schema?: SchemaDefinition
} }
// TODO: Expose ConfigLayer<T> from c12 // TODO: Expose ConfigLayer<T> from c12
@ -92,7 +105,11 @@ export type NuxtConfigLayer = ConfigLayer<NuxtConfig & {
rootDir: ConfigSchema['rootDir'] rootDir: ConfigSchema['rootDir']
}> }>
/** Normalized Nuxt options available as `nuxt.options.*` */ export interface NuxtBuilder {
bundle: (nuxt: Nuxt) => Promise<void>
}
// Normalized Nuxt options available as `nuxt.options.*`
export interface NuxtOptions extends Omit<ConfigSchema, 'builder' | 'webpack'> { export interface NuxtOptions extends Omit<ConfigSchema, 'builder' | 'webpack'> {
sourcemap: Required<Exclude<ConfigSchema['sourcemap'], boolean>> sourcemap: Required<Exclude<ConfigSchema['sourcemap'], boolean>>
builder: '@nuxt/vite-builder' | '@nuxt/webpack-builder' | NuxtBuilder builder: '@nuxt/vite-builder' | '@nuxt/webpack-builder' | NuxtBuilder
@ -104,27 +121,26 @@ export interface NuxtOptions extends Omit<ConfigSchema, 'builder' | 'webpack'> {
$schema: SchemaDefinition $schema: SchemaDefinition
} }
export interface NuxtBuilder {
bundle: (nuxt: Nuxt) => Promise<void>
}
export interface ViteConfig extends Omit<ViteUserConfig, 'publicDir'> { export interface ViteConfig extends Omit<ViteUserConfig, 'publicDir'> {
/** The path to the entrypoint for the Vite build. */ /** The path to the entrypoint for the Vite build. */
entry?: string entry?: string
/** /**
* Options passed to @vitejs/plugin-vue. * Options passed to @vitejs/plugin-vue.
*
* @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue * @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue
*/ */
vue?: VuePluginOptions vue?: VuePluginOptions
/** /**
* Options passed to @vitejs/plugin-vue-jsx. * Options passed to @vitejs/plugin-vue-jsx.
*
* @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx * @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx
*/ */
vueJsx?: VueJsxPluginOptions vueJsx?: VueJsxPluginOptions
/** /**
* Bundler for dev time server-side rendering. * Bundler for dev time server-side rendering.
*
* @default 'vite-node' * @default 'vite-node'
*/ */
devBundler?: 'vite-node' | 'legacy' devBundler?: 'vite-node' | 'legacy'
@ -148,22 +164,7 @@ export interface ViteConfig extends Omit<ViteUserConfig, 'publicDir'> {
publicDir?: never publicDir?: never
} }
// App Config
// -- Runtime Config --
type RuntimeConfigNamespace = Record<string, unknown>
export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
export interface RuntimeConfig extends RuntimeConfigNamespace {
app: NitroRuntimeConfigApp
/** Only available on the server. */
nitro?: NitroRuntimeConfig['nitro']
public: PublicRuntimeConfig
}
// -- App Config --
export interface CustomAppConfig { export interface CustomAppConfig {
[key: string]: unknown [key: string]: unknown
} }

View File

@ -1,17 +1,17 @@
import type { TSConfig } from 'pkg-types'
import type { Server as HttpServer } from 'node:http' import type { Server as HttpServer } from 'node:http'
import type { Server as HttpsServer } from 'node:https' import type { Server as HttpsServer } from 'node:https'
import type { TSConfig } from 'pkg-types'
import type { ViteDevServer } from 'vite' import type { ViteDevServer } from 'vite'
import type { Manifest } from 'vue-bundle-renderer' import type { Manifest } from 'vue-bundle-renderer'
import type { EventHandler } from 'h3' import type { EventHandler } from 'h3'
import type { Import, InlinePreset, Unimport } from 'unimport' import type { Import, InlinePreset, Unimport } from 'unimport'
import type { Compiler, Configuration, Stats } from 'webpack' import type { Compiler, Configuration, Stats } from 'webpack'
import type { Nuxt, NuxtApp, ResolvedNuxtTemplate } from './nuxt'
import type { Nitro, NitroConfig } from 'nitropack' import type { Nitro, NitroConfig } from 'nitropack'
import type { Component, ComponentsOptions } from './components'
import type { NuxtCompatibility, NuxtCompatibilityIssues, ViteConfig } from '..'
import type { Schema, SchemaDefinition } from 'untyped' import type { Schema, SchemaDefinition } from 'untyped'
import type { RouteLocationRaw } from 'vue-router' import type { RouteLocationRaw } from 'vue-router'
import type { NuxtCompatibility, NuxtCompatibilityIssues, ViteConfig } from '..'
import type { Component, ComponentsOptions } from './components'
import type { Nuxt, NuxtApp, ResolvedNuxtTemplate } from './nuxt'
export type HookResult = Promise<void> | void export type HookResult = Promise<void> | void
@ -65,6 +65,7 @@ export interface NuxtHooks {
// Kit // Kit
/** /**
* Allows extending compatibility checks. * Allows extending compatibility checks.
*
* @param compatibility Compatibility object * @param compatibility Compatibility object
* @param issues Issues to be mapped * @param issues Issues to be mapped
* @returns Promise * @returns Promise
@ -74,18 +75,21 @@ export interface NuxtHooks {
// Nuxt // Nuxt
/** /**
* Called after Nuxt initialization, when the Nuxt instance is ready to work. * Called after Nuxt initialization, when the Nuxt instance is ready to work.
*
* @param nuxt The configured Nuxt object * @param nuxt The configured Nuxt object
* @returns Promise * @returns Promise
*/ */
'ready': (nuxt: Nuxt) => HookResult 'ready': (nuxt: Nuxt) => HookResult
/** /**
* Called when Nuxt instance is gracefully closing. * Called when Nuxt instance is gracefully closing.
*
* @param nuxt The configured Nuxt object * @param nuxt The configured Nuxt object
* @returns Promise * @returns Promise
*/ */
'close': (nuxt: Nuxt) => HookResult 'close': (nuxt: Nuxt) => HookResult
/** /**
* Called to restart the current Nuxt instance. * Called to restart the current Nuxt instance.
*
* @returns Promise * @returns Promise
*/ */
'restart': (options?: { 'restart': (options?: {
@ -97,29 +101,34 @@ export interface NuxtHooks {
/** /**
* Called during Nuxt initialization, before installing user modules. * Called during Nuxt initialization, before installing user modules.
*
* @returns Promise * @returns Promise
*/ */
'modules:before': () => HookResult 'modules:before': () => HookResult
/** /**
* Called during Nuxt initialization, after installing user modules. * Called during Nuxt initialization, after installing user modules.
*
* @returns Promise * @returns Promise
*/ */
'modules:done': () => HookResult 'modules:done': () => HookResult
/** /**
* Called after resolving the `app` instance. * Called after resolving the `app` instance.
*
* @param app The resolved `NuxtApp` object * @param app The resolved `NuxtApp` object
* @returns Promise * @returns Promise
*/ */
'app:resolve': (app: NuxtApp) => HookResult 'app:resolve': (app: NuxtApp) => HookResult
/** /**
* Called during `NuxtApp` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`). * Called during `NuxtApp` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
*
* @param app The configured `NuxtApp` object * @param app The configured `NuxtApp` object
* @returns Promise * @returns Promise
*/ */
'app:templates': (app: NuxtApp) => HookResult 'app:templates': (app: NuxtApp) => HookResult
/** /**
* Called after templates are compiled into the [virtual file system](https://nuxt.com/docs/guide/directory-structure/nuxt#virtual-file-system) (vfs). * Called after templates are compiled into the [virtual file system](https://nuxt.com/docs/guide/directory-structure/nuxt#virtual-file-system) (vfs).
*
* @param app The configured `NuxtApp` object * @param app The configured `NuxtApp` object
* @returns Promise * @returns Promise
*/ */
@ -127,16 +136,19 @@ export interface NuxtHooks {
/** /**
* Called before Nuxt bundle builder. * Called before Nuxt bundle builder.
*
* @returns Promise * @returns Promise
*/ */
'build:before': () => HookResult 'build:before': () => HookResult
/** /**
* Called after Nuxt bundle builder is complete. * Called after Nuxt bundle builder is complete.
*
* @returns Promise * @returns Promise
*/ */
'build:done': () => HookResult 'build:done': () => HookResult
/** /**
* Called during the manifest build by Vite and Webpack. This allows customizing the manifest that Nitro will use to render `<script>` and `<link>` tags in the final HTML. * Called during the manifest build by Vite and Webpack. This allows customizing the manifest that Nitro will use to render `<script>` and `<link>` tags in the final HTML.
*
* @param manifest The manifest object to build * @param manifest The manifest object to build
* @returns Promise * @returns Promise
*/ */
@ -144,6 +156,7 @@ export interface NuxtHooks {
/** /**
* Called when `nuxt analyze` is finished * Called when `nuxt analyze` is finished
*
* @param meta the analyze meta object, mutations will be saved to `meta.json` * @param meta the analyze meta object, mutations will be saved to `meta.json`
* @returns Promise * @returns Promise
*/ */
@ -151,12 +164,14 @@ export interface NuxtHooks {
/** /**
* Called before generating the app. * Called before generating the app.
*
* @param options GenerateAppOptions object * @param options GenerateAppOptions object
* @returns Promise * @returns Promise
*/ */
'builder:generateApp': (options?: GenerateAppOptions) => HookResult 'builder:generateApp': (options?: GenerateAppOptions) => HookResult
/** /**
* Called at build time in development when the watcher spots a change to a file or directory in the project. * Called at build time in development when the watcher spots a change to a file or directory in the project.
*
* @param event "add" | "addDir" | "change" | "unlink" | "unlinkDir" * @param event "add" | "addDir" | "change" | "unlink" | "unlinkDir"
* @param path the path to the watched file * @param path the path to the watched file
* @returns Promise * @returns Promise
@ -165,6 +180,7 @@ export interface NuxtHooks {
/** /**
* Called after pages routes are resolved. * Called after pages routes are resolved.
*
* @param pages Array containing resolved pages * @param pages Array containing resolved pages
* @returns Promise * @returns Promise
*/ */
@ -172,6 +188,7 @@ export interface NuxtHooks {
/** /**
* Called when the dev middleware is being registered on the Nitro dev server. * Called when the dev middleware is being registered on the Nitro dev server.
*
* @param handler the Vite or Webpack event handler * @param handler the Vite or Webpack event handler
* @returns Promise * @returns Promise
*/ */
@ -179,24 +196,28 @@ export interface NuxtHooks {
/** /**
* Called at setup allowing modules to extend sources. * Called at setup allowing modules to extend sources.
*
* @param presets Array containing presets objects * @param presets Array containing presets objects
* @returns Promise * @returns Promise
*/ */
'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult 'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult
/** /**
* Called at setup allowing modules to extend imports. * Called at setup allowing modules to extend imports.
*
* @param imports Array containing the imports to extend * @param imports Array containing the imports to extend
* @returns Promise * @returns Promise
*/ */
'imports:extend': (imports: Import[]) => HookResult 'imports:extend': (imports: Import[]) => HookResult
/** /**
* Called when the [unimport](https://github.com/unjs/unimport) context is created. * Called when the [unimport](https://github.com/unjs/unimport) context is created.
*
* @param context The Unimport context * @param context The Unimport context
* @returns Promise * @returns Promise
*/ */
'imports:context': (context: Unimport) => HookResult 'imports:context': (context: Unimport) => HookResult
/** /**
* Allows extending import directories. * Allows extending import directories.
*
* @param dirs Array containing directories as string * @param dirs Array containing directories as string
* @returns Promise * @returns Promise
*/ */
@ -205,12 +226,14 @@ export interface NuxtHooks {
// Components // Components
/** /**
* Called within `app:resolve` allowing to extend the directories that are scanned for auto-importable components. * Called within `app:resolve` allowing to extend the directories that are scanned for auto-importable components.
*
* @param dirs The `dirs` option to push new items * @param dirs The `dirs` option to push new items
* @returns Promise * @returns Promise
*/ */
'components:dirs': (dirs: ComponentsOptions['dirs']) => HookResult 'components:dirs': (dirs: ComponentsOptions['dirs']) => HookResult
/** /**
* Allows extending new components. * Allows extending new components.
*
* @param components The `components` array to push new items * @param components The `components` array to push new items
* @returns Promise * @returns Promise
*/ */
@ -219,30 +242,35 @@ export interface NuxtHooks {
// Nitropack // Nitropack
/** /**
* Called before initializing Nitro, allowing customization of Nitro's configuration. * Called before initializing Nitro, allowing customization of Nitro's configuration.
*
* @param nitroConfig The nitro config to be extended * @param nitroConfig The nitro config to be extended
* @returns Promise * @returns Promise
*/ */
'nitro:config': (nitroConfig: NitroConfig) => HookResult 'nitro:config': (nitroConfig: NitroConfig) => HookResult
/** /**
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro. * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
*
* @param nitro The created nitro object * @param nitro The created nitro object
* @returns Promise * @returns Promise
*/ */
'nitro:init': (nitro: Nitro) => HookResult 'nitro:init': (nitro: Nitro) => HookResult
/** /**
* Called before building the Nitro instance. * Called before building the Nitro instance.
*
* @param nitro The created nitro object * @param nitro The created nitro object
* @returns Promise * @returns Promise
*/ */
'nitro:build:before': (nitro: Nitro) => HookResult 'nitro:build:before': (nitro: Nitro) => HookResult
/** /**
* Called after copying public assets. Allows modifying public assets before Nitro server is built. * Called after copying public assets. Allows modifying public assets before Nitro server is built.
*
* @param nitro The created nitro object * @param nitro The created nitro object
* @returns Promise * @returns Promise
*/ */
'nitro:build:public-assets': (nitro: Nitro) => HookResult 'nitro:build:public-assets': (nitro: Nitro) => HookResult
/** /**
* Allows extending the routes to be pre-rendered. * Allows extending the routes to be pre-rendered.
*
* @param ctx Nuxt context * @param ctx Nuxt context
* @returns Promise * @returns Promise
*/ */
@ -251,18 +279,21 @@ export interface NuxtHooks {
// Nuxi // Nuxi
/** /**
* Called when an error occurs at build time. * Called when an error occurs at build time.
*
* @param error Error object * @param error Error object
* @returns Promise * @returns Promise
*/ */
'build:error': (error: Error) => HookResult 'build:error': (error: Error) => HookResult
/** /**
* Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json` * Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
*
* @param options Objects containing `references`, `declarations`, `tsConfig` * @param options Objects containing `references`, `declarations`, `tsConfig`
* @returns Promise * @returns Promise
*/ */
'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: TSConfig }) => HookResult 'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: TSConfig }) => HookResult
/** /**
* Called when the dev server is loading. * Called when the dev server is loading.
*
* @param listenerServer The HTTP/HTTPS server object * @param listenerServer The HTTP/HTTPS server object
* @param listener The server's listener object * @param listener The server's listener object
* @returns Promise * @returns Promise
@ -272,24 +303,28 @@ export interface NuxtHooks {
// Schema // Schema
/** /**
* Allows extending default schemas. * Allows extending default schemas.
*
* @param schemas Schemas to be extend * @param schemas Schemas to be extend
* @returns void * @returns void
*/ */
'schema:extend': (schemas: SchemaDefinition[]) => void 'schema:extend': (schemas: SchemaDefinition[]) => void
/** /**
* Allows extending resolved schema. * Allows extending resolved schema.
*
* @param schema Schema object * @param schema Schema object
* @returns void * @returns void
*/ */
'schema:resolved': (schema: Schema) => void 'schema:resolved': (schema: Schema) => void
/** /**
* Called before writing the given schema. * Called before writing the given schema.
*
* @param schema Schema object * @param schema Schema object
* @returns void * @returns void
*/ */
'schema:beforeWrite': (schema: Schema) => void 'schema:beforeWrite': (schema: Schema) => void
/** /**
* Called after the schema is written. * Called after the schema is written.
*
* @returns void * @returns void
*/ */
'schema:written': () => void 'schema:written': () => void
@ -297,12 +332,14 @@ export interface NuxtHooks {
// Vite // Vite
/** /**
* Allows to extend Vite default context. * Allows to extend Vite default context.
*
* @param viteBuildContext The vite build context object * @param viteBuildContext The vite build context object
* @returns Promise * @returns Promise
*/ */
'vite:extend': (viteBuildContext: { nuxt: Nuxt, config: ViteConfig }) => HookResult 'vite:extend': (viteBuildContext: { nuxt: Nuxt, config: ViteConfig }) => HookResult
/** /**
* Allows to extend Vite default config. * Allows to extend Vite default config.
*
* @param viteInlineConfig The vite inline config object * @param viteInlineConfig The vite inline config object
* @param env Server or client * @param env Server or client
* @returns Promise * @returns Promise
@ -310,6 +347,7 @@ export interface NuxtHooks {
'vite:extendConfig': (viteInlineConfig: ViteConfig, env: { isClient: boolean, isServer: boolean }) => HookResult 'vite:extendConfig': (viteInlineConfig: ViteConfig, env: { isClient: boolean, isServer: boolean }) => HookResult
/** /**
* Allows to read the resolved Vite config. * Allows to read the resolved Vite config.
*
* @param viteInlineConfig The vite inline config object * @param viteInlineConfig The vite inline config object
* @param env Server or client * @param env Server or client
* @returns Promise * @returns Promise
@ -317,6 +355,7 @@ export interface NuxtHooks {
'vite:configResolved': (viteInlineConfig: Readonly<ViteConfig>, env: { isClient: boolean, isServer: boolean }) => HookResult 'vite:configResolved': (viteInlineConfig: Readonly<ViteConfig>, env: { isClient: boolean, isServer: boolean }) => HookResult
/** /**
* Called when the Vite server is created. * Called when the Vite server is created.
*
* @param viteServer Vite development server * @param viteServer Vite development server
* @param env Server or client * @param env Server or client
* @returns Promise * @returns Promise
@ -324,6 +363,7 @@ export interface NuxtHooks {
'vite:serverCreated': (viteServer: ViteDevServer, env: { isClient: boolean, isServer: boolean }) => HookResult 'vite:serverCreated': (viteServer: ViteDevServer, env: { isClient: boolean, isServer: boolean }) => HookResult
/** /**
* Called after Vite server is compiled. * Called after Vite server is compiled.
*
* @returns Promise * @returns Promise
*/ */
'vite:compiled': () => HookResult 'vite:compiled': () => HookResult
@ -331,24 +371,28 @@ export interface NuxtHooks {
// webpack // webpack
/** /**
* Called before configuring the webpack compiler. * Called before configuring the webpack compiler.
*
* @param webpackConfigs Configs objects to be pushed to the compiler * @param webpackConfigs Configs objects to be pushed to the compiler
* @returns Promise * @returns Promise
*/ */
'webpack:config': (webpackConfigs: Configuration[]) => HookResult 'webpack:config': (webpackConfigs: Configuration[]) => HookResult
/** /**
* Allows to read the resolved webpack config * Allows to read the resolved webpack config
* @param webpackConfigs Configs objects to be pushed to the compiler *
* @returns Promise * @param webpackConfigs Configs objects to be pushed to the compiler
*/ * @returns Promise
*/
'webpack:configResolved': (webpackConfigs: Readonly<Configuration>[]) => HookResult 'webpack:configResolved': (webpackConfigs: Readonly<Configuration>[]) => HookResult
/** /**
* Called right before compilation. * Called right before compilation.
*
* @param options The options to be added * @param options The options to be added
* @returns Promise * @returns Promise
*/ */
'webpack:compile': (options: { name: string, compiler: Compiler }) => HookResult 'webpack:compile': (options: { name: string, compiler: Compiler }) => HookResult
/** /**
* Called after resources are loaded. * Called after resources are loaded.
*
* @param options The compiler options * @param options The compiler options
* @returns Promise * @returns Promise
*/ */
@ -356,22 +400,26 @@ export interface NuxtHooks {
/** /**
* Called on `change` on WebpackBar. * Called on `change` on WebpackBar.
*
* @param shortPath the short path * @param shortPath the short path
* @returns void * @returns void
*/ */
'webpack:change': (shortPath: string) => void 'webpack:change': (shortPath: string) => void
/** /**
* Called on `done` if has errors on WebpackBar. * Called on `done` if has errors on WebpackBar.
*
* @returns void * @returns void
*/ */
'webpack:error': () => void 'webpack:error': () => void
/** /**
* Called on `allDone` on WebpackBar. * Called on `allDone` on WebpackBar.
*
* @returns void * @returns void
*/ */
'webpack:done': () => void 'webpack:done': () => void
/** /**
* Called on `progress` on WebpackBar. * Called on `progress` on WebpackBar.
*
* @param statesArray The array containing the states on progress * @param statesArray The array containing the states on progress
* @returns void * @returns void
*/ */

View File

@ -1,5 +1,5 @@
import type { NuxtHooks } from './hooks' import type { NuxtHooks } from './hooks'
import type { Nuxt } from "./nuxt" import type { Nuxt } from './nuxt'
import type { NuxtCompatibility } from './compatibility' import type { NuxtCompatibility } from './compatibility'
export interface ModuleMeta { export interface ModuleMeta {

View File

@ -4,6 +4,57 @@ import type { NuxtHooks, NuxtLayout, NuxtMiddleware } from './hooks'
import type { Component } from './components' import type { Component } from './components'
import type { NuxtOptions } from './config' import type { NuxtOptions } from './config'
export interface NuxtPlugin {
/** @deprecated use mode */
ssr?: boolean
src: string
mode?: 'all' | 'server' | 'client'
/**
* This allows more granular control over plugin order and should only be used by advanced users.
* Lower numbers run first, and user plugins default to `0`.
*
* Default Nuxt priorities can be seen at [here](https://github.com/nuxt/nuxt/blob/9904849bc87c53dfbd3ea3528140a5684c63c8d8/packages/nuxt/src/core/plugins/plugin-metadata.ts#L15-L34).
*/
order?: number
}
export interface NuxtTemplate<Options = Record<string, any>> {
/** resolved output file path (generated) */
dst?: string
/** The target filename once the template is copied into the Nuxt buildDir */
filename?: string
/** An options object that will be accessible within the template via `<% options %>` */
options?: Options
/** The resolved path to the source file to be template */
src?: string
/** Provided compile option instead of src */
getContents?: (data: Options) => string | Promise<string>
/** Write to filesystem */
write?: boolean
}
export interface ResolvedNuxtTemplate<Options = Record<string, any>> extends NuxtTemplate<Options> {
filename: string
dst: string
}
type _TemplatePlugin<Options> = Omit<NuxtPlugin, 'src'> & NuxtTemplate<Options>
export interface NuxtPluginTemplate<Options = Record<string, any>> extends _TemplatePlugin<Options> { }
export interface NuxtApp {
mainComponent?: string | null
rootComponent?: string | null
errorComponent?: string | null
dir: string
extensions: string[]
plugins: NuxtPlugin[]
components: Component[]
layouts: Record<string, NuxtLayout>
middleware: NuxtMiddleware[]
templates: NuxtTemplate[]
configs: string[]
}
export interface Nuxt { export interface Nuxt {
// Private fields. // Private fields.
_version: string _version: string
@ -26,54 +77,3 @@ export interface Nuxt {
apps: Record<string, NuxtApp> apps: Record<string, NuxtApp>
} }
export interface NuxtTemplate<Options = Record<string, any>> {
/** resolved output file path (generated) */
dst?: string
/** The target filename once the template is copied into the Nuxt buildDir */
filename?: string
/** An options object that will be accessible within the template via `<% options %>` */
options?: Options
/** The resolved path to the source file to be template */
src?: string
/** Provided compile option instead of src */
getContents?: (data: Options) => string | Promise<string>
/** Write to filesystem */
write?: boolean
}
export interface ResolvedNuxtTemplate<Options = Record<string, any>> extends NuxtTemplate<Options> {
filename: string
dst: string
}
export interface NuxtPlugin {
/** @deprecated use mode */
ssr?: boolean
src: string
mode?: 'all' | 'server' | 'client'
/**
* This allows more granular control over plugin order and should only be used by advanced users.
* Lower numbers run first, and user plugins default to `0`.
*
* Default Nuxt priorities can be seen at [here](https://github.com/nuxt/nuxt/blob/9904849bc87c53dfbd3ea3528140a5684c63c8d8/packages/nuxt/src/core/plugins/plugin-metadata.ts#L15-L34).
*/
order?: number
}
export interface NuxtApp {
mainComponent?: string | null
rootComponent?: string | null
errorComponent?: string | null
dir: string
extensions: string[]
plugins: NuxtPlugin[]
components: Component[]
layouts: Record<string, NuxtLayout>
middleware: NuxtMiddleware[]
templates: NuxtTemplate[]
configs: string[]
}
type _TemplatePlugin<Options> = Omit<NuxtPlugin, 'src'> & NuxtTemplate<Options>
export interface NuxtPluginTemplate<Options = Record<string, any>> extends _TemplatePlugin<Options> { }

View File

@ -1,5 +1,4 @@
import type { RouterOptions as _RouterOptions, RouterHistory } from 'vue-router' import type { RouterHistory, RouterOptions as _RouterOptions } from 'vue-router'
export type RouterOptions = Partial<Omit<_RouterOptions, 'history' | 'routes'>> & { export type RouterOptions = Partial<Omit<_RouterOptions, 'history' | 'routes'>> & {
history?: (baseURL?: string) => RouterHistory history?: (baseURL?: string) => RouterHistory