@nuxt/kit 3.20.1 → 3.21.0

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.
package/README.md CHANGED
@@ -6,32 +6,34 @@
6
6
  <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
7
7
  <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
8
8
  <a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
9
+ <a href="https://nuxt.com/modules"><img src="https://img.shields.io/badge/dynamic/json?url=https://nuxt.com/api/v1/modules&query=$.stats.modules&label=Modules&style=flat&colorA=18181B&colorB=28CF8D" alt="Modules"></a>
9
10
  <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
10
11
  <a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
11
12
  <a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
13
+ <a href="https://deepwiki.com/nuxt/nuxt"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
12
14
  </p>
13
15
 
14
16
  Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
15
17
 
16
18
  It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including:
17
- - Server-side rendering, Static Site Generation, Hybrid Rendering and Edge-Side Rendering
19
+ - Server-side rendering, static site generation, hybrid rendering and edge-side rendering
18
20
  - Automatic routing with code-splitting and pre-fetching
19
21
  - Data fetching and state management
20
- - SEO Optimization and Meta tags definition
22
+ - Search engine optimization and defining meta tags
21
23
  - Auto imports of components, composables and utils
22
24
  - TypeScript with zero configuration
23
- - Go fullstack with our server/ directory
24
- - Extensible with [200+ modules](https://nuxt.com/modules)
25
+ - Go full-stack with our server/ directory
26
+ - Extensible with [300+ modules](https://nuxt.com/modules)
25
27
  - Deployment to a variety of [hosting platforms](https://nuxt.com/deploy)
26
28
  - ...[and much more](https://nuxt.com) 🚀
27
29
 
28
30
  ### Table of Contents
29
31
 
30
32
  - 🚀 [Getting Started](#getting-started)
31
- - 💻 [ Vue Development](#vue-development)
33
+ - 💻 [Vue Development](#vue-development)
32
34
  - 📖 [Documentation](#documentation)
33
35
  - 🧩 [Modules](#modules)
34
- - ❤️ [Contribute](#contribute)
36
+ - ❤️ [Contribute](#contribute)
35
37
  - 🏠 [Local Development](#local-development)
36
38
  - 🛟 [Professional Support](#professional-support)
37
39
  - 🔗 [Follow Us](#follow-us)
package/dist/index.d.mts CHANGED
@@ -1,15 +1,14 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
1
  import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
3
2
  import { LoadConfigOptions } from 'c12';
4
3
  import { Import, InlinePreset } from 'unimport';
5
4
  import { WebpackPluginInstance, Configuration } from 'webpack';
6
5
  import { RspackPluginInstance } from '@rspack/core';
7
6
  import { Plugin, UserConfig } from 'vite';
8
- import * as unctx from 'unctx';
9
- import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
7
+ import { UseContext } from 'unctx';
8
+ import * as NitroV2 from 'nitropack/types';
9
+ import * as NitroV3 from 'nitro/types';
10
10
  import { GlobOptions } from 'tinyglobby';
11
- import * as consola from 'consola';
12
- import { ConsolaOptions } from 'consola';
11
+ import { ConsolaInstance, ConsolaOptions } from 'consola';
13
12
  import { genSafeVariableName } from 'knitwork';
14
13
 
15
14
  /**
@@ -53,7 +52,7 @@ declare const normalizeModuleTranspilePath: (p: string) => string;
53
52
  */
54
53
  declare function hasNuxtModule(moduleName: string, nuxt?: Nuxt): boolean;
55
54
  /**
56
- * Checks if a Nuxt Module is compatible with a given semver version.
55
+ * Checks if a Nuxt module is compatible with a given semver version.
57
56
  */
58
57
  declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverVersion: string, nuxt?: Nuxt): Promise<boolean>;
59
58
  /**
@@ -116,7 +115,7 @@ interface LayerDirectories {
116
115
  * @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
117
116
  * @returns Array of LayerDirectories objects, ordered by priority (user layer first)
118
117
  */
119
- declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
118
+ declare function getLayerDirectories(nuxt?: Nuxt): LayerDirectories[];
120
119
 
121
120
  declare function setGlobalHead(head: NuxtAppConfig['head']): void;
122
121
 
@@ -137,6 +136,8 @@ declare function useRuntimeConfig(): Record<string, any>;
137
136
  */
138
137
  declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
139
138
 
139
+ type Arrayable<T> = T | T[];
140
+ type Thenable<T> = T | Promise<T>;
140
141
  interface ExtendConfigOptions {
141
142
  /**
142
143
  * Install plugin on dev
@@ -183,40 +184,41 @@ interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | '
183
184
  */
184
185
  client?: boolean;
185
186
  }
187
+ type ExtendWebpacklikeConfig = (fn: (config: Configuration) => void, options?: ExtendWebpackConfigOptions) => void;
186
188
  /**
187
189
  * Extend webpack config
188
190
  *
189
191
  * The fallback function might be called multiple times
190
192
  * when applying to both client and server builds.
191
193
  */
192
- declare const extendWebpackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
194
+ declare const extendWebpackConfig: ExtendWebpacklikeConfig;
193
195
  /**
194
196
  * Extend rspack config
195
197
  *
196
198
  * The fallback function might be called multiple times
197
199
  * when applying to both client and server builds.
198
200
  */
199
- declare const extendRspackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
201
+ declare const extendRspackConfig: ExtendWebpacklikeConfig;
200
202
  /**
201
203
  * Extend Vite config
202
204
  */
203
- declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
205
+ declare function extendViteConfig(fn: ((config: UserConfig) => Thenable<void>), options?: ExtendViteConfigOptions): (() => void) | undefined;
204
206
  /**
205
207
  * Append webpack plugin to the config.
206
208
  */
207
- declare function addWebpackPlugin(pluginOrGetter: WebpackPluginInstance | WebpackPluginInstance[] | (() => WebpackPluginInstance | WebpackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
209
+ declare function addWebpackPlugin(pluginOrGetter: Arrayable<WebpackPluginInstance> | (() => Thenable<Arrayable<WebpackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
208
210
  /**
209
211
  * Append rspack plugin to the config.
210
212
  */
211
- declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPluginInstance[] | (() => RspackPluginInstance | RspackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
213
+ declare function addRspackPlugin(pluginOrGetter: Arrayable<RspackPluginInstance> | (() => Thenable<Arrayable<RspackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
212
214
  /**
213
215
  * Append Vite plugin to the config.
214
216
  */
215
- declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
217
+ declare function addVitePlugin(pluginOrGetter: Arrayable<Plugin> | (() => Thenable<Arrayable<Plugin>>), options?: ExtendConfigOptions): void;
216
218
  interface AddBuildPluginFactory {
217
- vite?: () => Plugin | Plugin[];
218
- webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
219
- rspack?: () => RspackPluginInstance | RspackPluginInstance[];
219
+ vite?: () => Thenable<Arrayable<Plugin>>;
220
+ webpack?: () => Thenable<Arrayable<WebpackPluginInstance>>;
221
+ rspack?: () => Thenable<Arrayable<RspackPluginInstance>>;
220
222
  }
221
223
  declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
222
224
 
@@ -233,10 +235,11 @@ declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?:
233
235
  * Check version constraints and return true if passed, otherwise returns false
234
236
  */
235
237
  declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
238
+ type NuxtMajorVersion = 2 | 3 | 4;
236
239
  /**
237
240
  * Check if current Nuxt instance is of specified major version
238
241
  */
239
- declare function isNuxtMajorVersion(majorVersion: 2 | 3 | 4, nuxt?: Nuxt): boolean;
242
+ declare function isNuxtMajorVersion(majorVersion: NuxtMajorVersion, nuxt?: Nuxt): boolean;
240
243
  /**
241
244
  * @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
242
245
  */
@@ -279,7 +282,7 @@ declare function addComponent(opts: AddComponentOptions): void;
279
282
  * Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
280
283
  * @deprecated Use `getNuxtCtx` instead
281
284
  */
282
- declare const nuxtCtx: unctx.UseContext<Nuxt>;
285
+ declare const nuxtCtx: UseContext<Nuxt>;
283
286
  /** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
284
287
  declare const getNuxtCtx: () => Nuxt | null;
285
288
  /**
@@ -307,15 +310,22 @@ declare function useNuxt(): Nuxt;
307
310
  declare function tryUseNuxt(): Nuxt | null;
308
311
  declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
309
312
 
310
- declare function createIsIgnored(nuxt?: _nuxt_schema.Nuxt | null): (pathname: string, stats?: unknown) => boolean;
313
+ declare function createIsIgnored(nuxt?: Nuxt | null | undefined): (pathname: string, stats?: unknown) => boolean;
311
314
  /**
312
315
  * Return a filter function to filter an array of paths
313
316
  */
314
- declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: _nuxt_schema.Nuxt | null): boolean;
317
+ declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: Nuxt | null | undefined): boolean;
315
318
  declare function resolveIgnorePatterns(relativePath?: string): string[];
316
319
 
317
320
  declare function addLayout(this: any, template: NuxtTemplate | string, name?: string): void;
318
321
 
322
+ type isNitroV2 = 'options' extends keyof NitroV2.Nitro ? '___INVALID' extends keyof NitroV2.Nitro ? false : true : false;
323
+ type isNitroV3 = 'options' extends keyof NitroV3.Nitro ? '___INVALID' extends keyof NitroV3.Nitro ? false : true : false;
324
+ type Nitro = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.Nitro | NitroV3.Nitro : NitroV2.Nitro : NitroV3.Nitro;
325
+ type NitroDevEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroDevEventHandler | NitroV3.NitroDevEventHandler : NitroV2.NitroDevEventHandler : NitroV3.NitroDevEventHandler;
326
+ type NitroEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroEventHandler | NitroV3.NitroEventHandler : NitroV2.NitroEventHandler : NitroV3.NitroEventHandler;
327
+ type NitroRouteConfig = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroRouteConfig | NitroV3.NitroRouteConfig : NitroV2.NitroRouteConfig : NitroV3.NitroRouteConfig;
328
+
319
329
  declare function extendPages(cb: NuxtHooks['pages:extend']): void;
320
330
  interface ExtendRouteRulesOptions {
321
331
  /**
@@ -516,11 +526,11 @@ declare function normalizeTemplate<T>(template: NuxtTemplate<T> | string, buildD
516
526
  */
517
527
  declare function updateTemplates(options?: {
518
528
  filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
519
- }): Promise<any>;
529
+ }): Promise<void>;
520
530
  declare function writeTypes(nuxt: Nuxt): Promise<void>;
521
531
 
522
- declare const logger: consola.ConsolaInstance;
523
- declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): consola.ConsolaInstance;
532
+ declare const logger: ConsolaInstance;
533
+ declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance;
524
534
 
525
535
  interface ResolveModuleOptions {
526
536
  /** @deprecated use `url` with URLs pointing at a file - never a directory */
@@ -567,4 +577,4 @@ declare const templateUtils: {
567
577
  };
568
578
 
569
579
  export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
570
- export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
580
+ export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, NuxtMajorVersion, ResolveModuleOptions, ResolvePathOptions, Resolver };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,14 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
1
  import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
3
2
  import { LoadConfigOptions } from 'c12';
4
3
  import { Import, InlinePreset } from 'unimport';
5
4
  import { WebpackPluginInstance, Configuration } from 'webpack';
6
5
  import { RspackPluginInstance } from '@rspack/core';
7
6
  import { Plugin, UserConfig } from 'vite';
8
- import * as unctx from 'unctx';
9
- import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
7
+ import { UseContext } from 'unctx';
8
+ import * as NitroV2 from 'nitropack/types';
9
+ import * as NitroV3 from 'nitro/types';
10
10
  import { GlobOptions } from 'tinyglobby';
11
- import * as consola from 'consola';
12
- import { ConsolaOptions } from 'consola';
11
+ import { ConsolaInstance, ConsolaOptions } from 'consola';
13
12
  import { genSafeVariableName } from 'knitwork';
14
13
 
15
14
  /**
@@ -53,7 +52,7 @@ declare const normalizeModuleTranspilePath: (p: string) => string;
53
52
  */
54
53
  declare function hasNuxtModule(moduleName: string, nuxt?: Nuxt): boolean;
55
54
  /**
56
- * Checks if a Nuxt Module is compatible with a given semver version.
55
+ * Checks if a Nuxt module is compatible with a given semver version.
57
56
  */
58
57
  declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverVersion: string, nuxt?: Nuxt): Promise<boolean>;
59
58
  /**
@@ -116,7 +115,7 @@ interface LayerDirectories {
116
115
  * @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
117
116
  * @returns Array of LayerDirectories objects, ordered by priority (user layer first)
118
117
  */
119
- declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
118
+ declare function getLayerDirectories(nuxt?: Nuxt): LayerDirectories[];
120
119
 
121
120
  declare function setGlobalHead(head: NuxtAppConfig['head']): void;
122
121
 
@@ -137,6 +136,8 @@ declare function useRuntimeConfig(): Record<string, any>;
137
136
  */
138
137
  declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
139
138
 
139
+ type Arrayable<T> = T | T[];
140
+ type Thenable<T> = T | Promise<T>;
140
141
  interface ExtendConfigOptions {
141
142
  /**
142
143
  * Install plugin on dev
@@ -183,40 +184,41 @@ interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | '
183
184
  */
184
185
  client?: boolean;
185
186
  }
187
+ type ExtendWebpacklikeConfig = (fn: (config: Configuration) => void, options?: ExtendWebpackConfigOptions) => void;
186
188
  /**
187
189
  * Extend webpack config
188
190
  *
189
191
  * The fallback function might be called multiple times
190
192
  * when applying to both client and server builds.
191
193
  */
192
- declare const extendWebpackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
194
+ declare const extendWebpackConfig: ExtendWebpacklikeConfig;
193
195
  /**
194
196
  * Extend rspack config
195
197
  *
196
198
  * The fallback function might be called multiple times
197
199
  * when applying to both client and server builds.
198
200
  */
199
- declare const extendRspackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
201
+ declare const extendRspackConfig: ExtendWebpacklikeConfig;
200
202
  /**
201
203
  * Extend Vite config
202
204
  */
203
- declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
205
+ declare function extendViteConfig(fn: ((config: UserConfig) => Thenable<void>), options?: ExtendViteConfigOptions): (() => void) | undefined;
204
206
  /**
205
207
  * Append webpack plugin to the config.
206
208
  */
207
- declare function addWebpackPlugin(pluginOrGetter: WebpackPluginInstance | WebpackPluginInstance[] | (() => WebpackPluginInstance | WebpackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
209
+ declare function addWebpackPlugin(pluginOrGetter: Arrayable<WebpackPluginInstance> | (() => Thenable<Arrayable<WebpackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
208
210
  /**
209
211
  * Append rspack plugin to the config.
210
212
  */
211
- declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPluginInstance[] | (() => RspackPluginInstance | RspackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
213
+ declare function addRspackPlugin(pluginOrGetter: Arrayable<RspackPluginInstance> | (() => Thenable<Arrayable<RspackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
212
214
  /**
213
215
  * Append Vite plugin to the config.
214
216
  */
215
- declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
217
+ declare function addVitePlugin(pluginOrGetter: Arrayable<Plugin> | (() => Thenable<Arrayable<Plugin>>), options?: ExtendConfigOptions): void;
216
218
  interface AddBuildPluginFactory {
217
- vite?: () => Plugin | Plugin[];
218
- webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
219
- rspack?: () => RspackPluginInstance | RspackPluginInstance[];
219
+ vite?: () => Thenable<Arrayable<Plugin>>;
220
+ webpack?: () => Thenable<Arrayable<WebpackPluginInstance>>;
221
+ rspack?: () => Thenable<Arrayable<RspackPluginInstance>>;
220
222
  }
221
223
  declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
222
224
 
@@ -233,10 +235,11 @@ declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?:
233
235
  * Check version constraints and return true if passed, otherwise returns false
234
236
  */
235
237
  declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
238
+ type NuxtMajorVersion = 2 | 3 | 4;
236
239
  /**
237
240
  * Check if current Nuxt instance is of specified major version
238
241
  */
239
- declare function isNuxtMajorVersion(majorVersion: 2 | 3 | 4, nuxt?: Nuxt): boolean;
242
+ declare function isNuxtMajorVersion(majorVersion: NuxtMajorVersion, nuxt?: Nuxt): boolean;
240
243
  /**
241
244
  * @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
242
245
  */
@@ -279,7 +282,7 @@ declare function addComponent(opts: AddComponentOptions): void;
279
282
  * Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
280
283
  * @deprecated Use `getNuxtCtx` instead
281
284
  */
282
- declare const nuxtCtx: unctx.UseContext<Nuxt>;
285
+ declare const nuxtCtx: UseContext<Nuxt>;
283
286
  /** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
284
287
  declare const getNuxtCtx: () => Nuxt | null;
285
288
  /**
@@ -307,15 +310,22 @@ declare function useNuxt(): Nuxt;
307
310
  declare function tryUseNuxt(): Nuxt | null;
308
311
  declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
309
312
 
310
- declare function createIsIgnored(nuxt?: _nuxt_schema.Nuxt | null): (pathname: string, stats?: unknown) => boolean;
313
+ declare function createIsIgnored(nuxt?: Nuxt | null | undefined): (pathname: string, stats?: unknown) => boolean;
311
314
  /**
312
315
  * Return a filter function to filter an array of paths
313
316
  */
314
- declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: _nuxt_schema.Nuxt | null): boolean;
317
+ declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: Nuxt | null | undefined): boolean;
315
318
  declare function resolveIgnorePatterns(relativePath?: string): string[];
316
319
 
317
320
  declare function addLayout(this: any, template: NuxtTemplate | string, name?: string): void;
318
321
 
322
+ type isNitroV2 = 'options' extends keyof NitroV2.Nitro ? '___INVALID' extends keyof NitroV2.Nitro ? false : true : false;
323
+ type isNitroV3 = 'options' extends keyof NitroV3.Nitro ? '___INVALID' extends keyof NitroV3.Nitro ? false : true : false;
324
+ type Nitro = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.Nitro | NitroV3.Nitro : NitroV2.Nitro : NitroV3.Nitro;
325
+ type NitroDevEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroDevEventHandler | NitroV3.NitroDevEventHandler : NitroV2.NitroDevEventHandler : NitroV3.NitroDevEventHandler;
326
+ type NitroEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroEventHandler | NitroV3.NitroEventHandler : NitroV2.NitroEventHandler : NitroV3.NitroEventHandler;
327
+ type NitroRouteConfig = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroRouteConfig | NitroV3.NitroRouteConfig : NitroV2.NitroRouteConfig : NitroV3.NitroRouteConfig;
328
+
319
329
  declare function extendPages(cb: NuxtHooks['pages:extend']): void;
320
330
  interface ExtendRouteRulesOptions {
321
331
  /**
@@ -516,11 +526,11 @@ declare function normalizeTemplate<T>(template: NuxtTemplate<T> | string, buildD
516
526
  */
517
527
  declare function updateTemplates(options?: {
518
528
  filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
519
- }): Promise<any>;
529
+ }): Promise<void>;
520
530
  declare function writeTypes(nuxt: Nuxt): Promise<void>;
521
531
 
522
- declare const logger: consola.ConsolaInstance;
523
- declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): consola.ConsolaInstance;
532
+ declare const logger: ConsolaInstance;
533
+ declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance;
524
534
 
525
535
  interface ResolveModuleOptions {
526
536
  /** @deprecated use `url` with URLs pointing at a file - never a directory */
@@ -567,4 +577,4 @@ declare const templateUtils: {
567
577
  };
568
578
 
569
579
  export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
570
- export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
580
+ export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, NuxtMajorVersion, ResolveModuleOptions, ResolvePathOptions, Resolver };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { promises, existsSync, readFileSync, lstatSync } from 'node:fs';
2
2
  import { performance } from 'node:perf_hooks';
3
- import defu$1, { defu } from 'defu';
3
+ import { defu } from 'defu';
4
4
  import { applyDefaults } from 'untyped';
5
5
  import { dirname, resolve, relative, join, normalize, isAbsolute, basename, parse } from 'pathe';
6
6
  import { consola } from 'consola';
@@ -11,9 +11,9 @@ import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
11
11
  import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
12
12
  import { fileURLToPath, pathToFileURL } from 'node:url';
13
13
  import { createJiti } from 'jiti';
14
- import { parseNodeModulePath, interopDefault, resolveModuleExportNames } from 'mlly';
14
+ import { parseNodeModulePath, interopDefault, lookupNodeModuleSubpath, resolveModuleExportNames } from 'mlly';
15
15
  import { resolveModulePath, resolveModuleURL } from 'exsolve';
16
- import { isRelative, withTrailingSlash as withTrailingSlash$2 } from 'ufo';
16
+ import { isRelative, withTrailingSlash as withTrailingSlash$2, withoutTrailingSlash } from 'ufo';
17
17
  import { read, update } from 'rc9';
18
18
  import semver, { gte } from 'semver';
19
19
  import { captureStackTrace } from 'errx';
@@ -2565,6 +2565,7 @@ function tryRequireModule(id, opts) {
2565
2565
  }
2566
2566
 
2567
2567
  const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
2568
+ const ignoredConfigKeys = /* @__PURE__ */ new Set(["components", "imports", "pages", "devtools", "telemetry"]);
2568
2569
  async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useNuxt()) {
2569
2570
  const localLayerModuleDirs = [];
2570
2571
  for (const l of nuxt.options._layers) {
@@ -2573,7 +2574,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2573
2574
  localLayerModuleDirs.push(resolve(srcDir, l.config?.dir?.modules || "modules").replace(/\/?$/, "/"));
2574
2575
  }
2575
2576
  }
2576
- const optionsFunctions = /* @__PURE__ */ new Map();
2577
+ nuxt._moduleOptionsFunctions ||= /* @__PURE__ */ new Map();
2577
2578
  const resolvedModules = [];
2578
2579
  const inlineConfigKeys = new Set(
2579
2580
  await Promise.all([...modulesToInstall].map(([mod]) => typeof mod !== "string" && Promise.resolve(mod.getMeta?.())?.then((r) => r?.configKey)))
@@ -2587,7 +2588,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2587
2588
  }
2588
2589
  throw err;
2589
2590
  });
2590
- const dependencyMeta = res.nuxtModule.getModuleDependencies?.(nuxt) || {};
2591
+ const dependencyMeta = await res.nuxtModule.getModuleDependencies?.(nuxt) || {};
2591
2592
  for (const [name, value] of Object.entries(dependencyMeta)) {
2592
2593
  if (!value.overrides && !value.defaults && !value.version && value.optional) {
2593
2594
  continue;
@@ -2608,8 +2609,8 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2608
2609
  }
2609
2610
  }
2610
2611
  if (value.overrides || value.defaults) {
2611
- const currentFns = optionsFunctions.get(resolvedModule.module) || [];
2612
- optionsFunctions.set(resolvedModule.module, [
2612
+ const currentFns = nuxt._moduleOptionsFunctions.get(resolvedModule.module) || [];
2613
+ nuxt._moduleOptionsFunctions.set(resolvedModule.module, [
2613
2614
  ...currentFns,
2614
2615
  () => ({ defaults: value.defaults, overrides: value.overrides })
2615
2616
  ]);
@@ -2642,29 +2643,41 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2642
2643
  if (error) {
2643
2644
  throw error;
2644
2645
  }
2645
- for (const { nuxtModule, meta, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions } of resolvedModules) {
2646
- const configKey = meta?.configKey;
2647
- if (configKey) {
2648
- const optionsFns = [
2649
- ...optionsFunctions.get(moduleToInstall) || [],
2650
- ...optionsFunctions.get(configKey) || []
2651
- ];
2652
- if (optionsFns.length > 0) {
2653
- const overrides = [];
2654
- const defaults = [];
2655
- for (const fn of optionsFns) {
2656
- const options = fn();
2657
- overrides.push(options.overrides);
2658
- defaults.push(options.defaults);
2659
- }
2646
+ for (const { nuxtModule, meta = {}, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions: inlineOptions2 } of resolvedModules) {
2647
+ const configKey = meta.configKey;
2648
+ const optionsFns = [
2649
+ ...nuxt._moduleOptionsFunctions.get(moduleToInstall) || [],
2650
+ ...meta?.name ? nuxt._moduleOptionsFunctions.get(meta.name) || [] : [],
2651
+ // TODO: consider dropping options functions keyed by config key
2652
+ ...configKey ? nuxt._moduleOptionsFunctions.get(configKey) || [] : []
2653
+ ];
2654
+ if (optionsFns.length > 0) {
2655
+ const overrides = [];
2656
+ const defaults = [];
2657
+ for (const fn of optionsFns) {
2658
+ const options = fn();
2659
+ overrides.push(options.overrides);
2660
+ defaults.push(options.defaults);
2661
+ }
2662
+ if (configKey) {
2660
2663
  nuxt.options[configKey] = defu(...overrides, nuxt.options[configKey], ...defaults);
2661
2664
  }
2662
2665
  }
2663
- await callLifecycleHooks(nuxtModule, meta, inlineOptions, nuxt);
2664
- await callModule(nuxtModule, meta, inlineOptions, resolvedModulePath, moduleToInstall, localLayerModuleDirs, buildTimeModuleMeta, nuxt);
2666
+ const isDisabled = configKey && !ignoredConfigKeys.has(configKey) && nuxt.options[configKey] === false;
2667
+ if (!isDisabled) {
2668
+ await callLifecycleHooks(nuxtModule, meta, inlineOptions2, nuxt);
2669
+ }
2670
+ const path = typeof moduleToInstall === "string" ? moduleToInstall : void 0;
2671
+ await callModule(nuxt, nuxtModule, inlineOptions2, {
2672
+ meta: defu({ disabled: isDisabled }, meta, buildTimeModuleMeta),
2673
+ nameOrPath: path,
2674
+ modulePath: resolvedModulePath || path,
2675
+ localLayerModuleDirs
2676
+ });
2665
2677
  }
2678
+ delete nuxt._moduleOptionsFunctions;
2666
2679
  }
2667
- async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2680
+ async function installModule(moduleToInstall, inlineOptions2, nuxt = useNuxt()) {
2668
2681
  const { nuxtModule, buildTimeModuleMeta, resolvedModulePath } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
2669
2682
  const localLayerModuleDirs = [];
2670
2683
  for (const dirs of getLayerDirectories(nuxt)) {
@@ -2673,8 +2686,36 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2673
2686
  }
2674
2687
  }
2675
2688
  const meta = await nuxtModule.getMeta?.();
2676
- await callLifecycleHooks(nuxtModule, meta, inlineOptions, nuxt);
2677
- await callModule(nuxtModule, meta, inlineOptions, resolvedModulePath, moduleToInstall, localLayerModuleDirs, buildTimeModuleMeta, nuxt);
2689
+ let mergedOptions = inlineOptions2;
2690
+ const configKey = meta?.configKey;
2691
+ if (configKey && nuxt._moduleOptionsFunctions) {
2692
+ const optionsFns = [
2693
+ ...nuxt._moduleOptionsFunctions.get(moduleToInstall) || [],
2694
+ ...nuxt._moduleOptionsFunctions.get(configKey) || []
2695
+ ];
2696
+ if (optionsFns.length > 0) {
2697
+ const overrides = [];
2698
+ const defaults = [];
2699
+ for (const fn of optionsFns) {
2700
+ const options = fn();
2701
+ overrides.push(options.overrides);
2702
+ defaults.push(options.defaults);
2703
+ }
2704
+ mergedOptions = defu(inlineOptions2, ...overrides, nuxt.options[configKey], ...defaults);
2705
+ nuxt.options[configKey] = mergedOptions;
2706
+ }
2707
+ }
2708
+ const isDisabled = configKey && !ignoredConfigKeys.has(configKey) && nuxt.options[configKey] === false;
2709
+ if (!isDisabled) {
2710
+ await callLifecycleHooks(nuxtModule, meta, mergedOptions, nuxt);
2711
+ }
2712
+ const path = typeof moduleToInstall === "string" ? moduleToInstall : void 0;
2713
+ await callModule(nuxt, nuxtModule, mergedOptions, {
2714
+ meta: defu({ disabled: isDisabled }, meta, buildTimeModuleMeta),
2715
+ nameOrPath: path,
2716
+ modulePath: resolvedModulePath || path,
2717
+ localLayerModuleDirs
2718
+ });
2678
2719
  }
2679
2720
  function resolveModuleWithOptions(definition, nuxt) {
2680
2721
  const [module, options = {}] = Array.isArray(definition) ? definition : [definition, {}];
@@ -2757,7 +2798,7 @@ const normalizeModuleTranspilePath = (p) => {
2757
2798
  return getDirectory(p).split("node_modules/").pop();
2758
2799
  };
2759
2800
  const MissingModuleMatcher = /Cannot find module\s+['"]?([^'")\s]+)['"]?/i;
2760
- async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions, nuxt = useNuxt()) {
2801
+ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions2, nuxt = useNuxt()) {
2761
2802
  if (!meta.name || !meta.version) {
2762
2803
  return;
2763
2804
  }
@@ -2770,7 +2811,7 @@ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions, nuxt = u
2770
2811
  if (!previousVersion) {
2771
2812
  await nuxtModule.onInstall?.(nuxt);
2772
2813
  } else if (semver.gt(meta.version, previousVersion)) {
2773
- await nuxtModule.onUpgrade?.(inlineOptions, nuxt, previousVersion);
2814
+ await nuxtModule.onUpgrade?.(nuxt, inlineOptions2, previousVersion);
2774
2815
  }
2775
2816
  if (previousVersion !== meta.version) {
2776
2817
  update(
@@ -2784,30 +2825,39 @@ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions, nuxt = u
2784
2825
  );
2785
2826
  }
2786
2827
  }
2787
- async function callModule(nuxtModule, meta = {}, inlineOptions, resolvedModulePath, moduleToInstall, localLayerModuleDirs, buildTimeModuleMeta, nuxt = useNuxt()) {
2788
- const res = (isNuxtMajorVersion(2, nuxt) ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : nuxt.options.experimental?.debugModuleMutation && nuxt._asyncLocalStorageModule ? await nuxt._asyncLocalStorageModule.run(nuxtModule, () => nuxtModule(inlineOptions || {}, nuxt)) : await nuxtModule(inlineOptions || {}, nuxt)) ?? {};
2789
- if (res === false) {
2790
- return;
2791
- }
2792
- const modulePath = resolvedModulePath || moduleToInstall;
2828
+ async function callModule(nuxt, nuxtModule, moduleOptions = {}, options) {
2829
+ const modulePath = options.modulePath;
2830
+ const nameOrPath = options.nameOrPath;
2831
+ const localLayerModuleDirs = options.localLayerModuleDirs;
2832
+ const fn = () => isNuxtMajorVersion(2, nuxt) ? nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : nuxt.options.experimental?.debugModuleMutation && nuxt._asyncLocalStorageModule ? nuxt._asyncLocalStorageModule.run(nuxtModule, () => nuxtModule(moduleOptions, nuxt)) : nuxtModule(moduleOptions, nuxt);
2833
+ const res = options.meta.disabled ? false : await fn();
2834
+ let entryPath;
2793
2835
  if (typeof modulePath === "string") {
2794
2836
  const parsed = parseNodeModulePath(modulePath);
2795
- const moduleRoot = parsed.dir ? parsed.dir + parsed.name : await resolvePackageJSON(modulePath, { try: true }).then((r) => r ? dirname(r) : modulePath);
2796
- nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleRoot));
2797
- const directory = moduleRoot.replace(/\/?$/, "/");
2798
- if (moduleRoot !== moduleToInstall && !localLayerModuleDirs.some((dir) => directory.startsWith(dir))) {
2799
- nuxt.options.modulesDir.push(join(moduleRoot, "node_modules"));
2837
+ if (parsed.name) {
2838
+ const subpath = await lookupNodeModuleSubpath(modulePath) || ".";
2839
+ entryPath = join(parsed.name, subpath === "./" ? "." : subpath);
2840
+ }
2841
+ if (res !== false) {
2842
+ const moduleRoot = parsed.dir ? parsed.dir + parsed.name : await resolvePackageJSON(modulePath, { try: true }).then((r) => r ? dirname(r) : modulePath);
2843
+ nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleRoot));
2844
+ const directory = moduleRoot.replace(/\/?$/, "/");
2845
+ if (moduleRoot !== nameOrPath && !localLayerModuleDirs.some((dir) => directory.startsWith(dir))) {
2846
+ nuxt.options.modulesDir.push(join(moduleRoot, "node_modules"));
2847
+ }
2800
2848
  }
2801
2849
  }
2802
- nuxt.options._installedModules ||= [];
2803
- const entryPath = typeof moduleToInstall === "string" ? resolveAlias(moduleToInstall, nuxt.options.alias) : void 0;
2804
- if (typeof moduleToInstall === "string" && entryPath !== moduleToInstall) {
2805
- buildTimeModuleMeta.rawPath = moduleToInstall;
2850
+ if (nameOrPath) {
2851
+ entryPath ||= resolveAlias(nameOrPath, nuxt.options.alias);
2852
+ if (entryPath !== nameOrPath) {
2853
+ options.meta.rawPath = nameOrPath;
2854
+ }
2806
2855
  }
2856
+ nuxt.options._installedModules ||= [];
2807
2857
  nuxt.options._installedModules.push({
2808
- meta: defu(meta, buildTimeModuleMeta),
2858
+ meta: options.meta,
2809
2859
  module: nuxtModule,
2810
- timings: res.timings,
2860
+ timings: (res || {}).timings,
2811
2861
  entryPath
2812
2862
  });
2813
2863
  }
@@ -2858,8 +2908,8 @@ async function loadNuxtConfig(opts) {
2858
2908
  const localLayers = (await glob("layers/*", {
2859
2909
  onlyDirectories: true,
2860
2910
  cwd: opts.cwd || process.cwd()
2861
- })).map((d) => d.endsWith("/") ? d.substring(0, d.length - 1) : d).sort((a, b) => b.localeCompare(a));
2862
- opts.overrides = defu$1(opts.overrides, { _extends: localLayers });
2911
+ })).map((d) => withTrailingSlash$2(d)).sort((a, b) => b.localeCompare(a));
2912
+ opts.overrides = defu(opts.overrides, { _extends: localLayers });
2863
2913
  const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await withDefineNuxtConfig(
2864
2914
  () => loadConfig({
2865
2915
  name: "nuxt",
@@ -2894,14 +2944,17 @@ async function loadNuxtConfig(opts) {
2894
2944
  }
2895
2945
  const _layers = [];
2896
2946
  const processedLayers = /* @__PURE__ */ new Set();
2897
- const localRelativePaths = new Set(localLayers);
2947
+ const localRelativePaths = new Set(localLayers.map((layer) => withoutTrailingSlash(layer)));
2898
2948
  for (const layer of layers) {
2899
- layer.config ||= {};
2900
- layer.config.rootDir ??= layer.cwd;
2901
- if (processedLayers.has(layer.config.rootDir)) {
2949
+ const resolvedRootDir = layer.config?.rootDir ?? layer.cwd;
2950
+ layer.config = {
2951
+ ...layer.config || {},
2952
+ rootDir: resolvedRootDir
2953
+ };
2954
+ if (processedLayers.has(resolvedRootDir)) {
2902
2955
  continue;
2903
2956
  }
2904
- processedLayers.add(layer.config.rootDir);
2957
+ processedLayers.add(resolvedRootDir);
2905
2958
  layer.config = await applyDefaults(layerSchema, layer.config);
2906
2959
  if (!layer.configFile || layer.configFile.endsWith(".nuxtrc")) {
2907
2960
  continue;
@@ -3045,7 +3098,7 @@ const HANDLER_METHOD_RE = /\.(get|head|patch|post|put|delete|connect|options|tra
3045
3098
  function normalizeHandlerMethod(handler) {
3046
3099
  const [, method = void 0] = handler.handler.match(HANDLER_METHOD_RE) || [];
3047
3100
  return {
3048
- method,
3101
+ method: method?.toUpperCase(),
3049
3102
  ...handler,
3050
3103
  handler: normalize(handler.handler)
3051
3104
  };
@@ -3118,7 +3171,7 @@ function useRuntimeConfig() {
3118
3171
  }
3119
3172
  function updateRuntimeConfig(runtimeConfig) {
3120
3173
  const nuxt = useNuxt();
3121
- Object.assign(nuxt.options.nitro.runtimeConfig, defu$1(runtimeConfig, nuxt.options.nitro.runtimeConfig));
3174
+ Object.assign(nuxt.options.nitro.runtimeConfig, defu(runtimeConfig, nuxt.options.nitro.runtimeConfig));
3122
3175
  try {
3123
3176
  return useNitro().updateConfig({ runtimeConfig });
3124
3177
  } catch {
@@ -3170,17 +3223,17 @@ const extendWebpackCompatibleConfig = (builder) => (fn, options = {}) => {
3170
3223
  if (options.build === false && nuxt.options.build) {
3171
3224
  return;
3172
3225
  }
3173
- nuxt.hook(`${builder}:config`, (configs) => {
3226
+ nuxt.hook(`${builder}:config`, async (configs) => {
3174
3227
  if (options.server !== false) {
3175
3228
  const config = configs.find((i) => i.name === "server");
3176
3229
  if (config) {
3177
- fn(config);
3230
+ await fn(config);
3178
3231
  }
3179
3232
  }
3180
3233
  if (options.client !== false) {
3181
3234
  const config = configs.find((i) => i.name === "client");
3182
3235
  if (config) {
3183
- fn(config);
3236
+ await fn(config);
3184
3237
  }
3185
3238
  }
3186
3239
  });
@@ -3204,17 +3257,17 @@ function extendViteConfig(fn, options = {}) {
3204
3257
  return nuxt.hook("vite:extend", ({ config }) => fn(config));
3205
3258
  }
3206
3259
  function addWebpackPlugin(pluginOrGetter, options) {
3207
- extendWebpackConfig((config) => {
3260
+ extendWebpackConfig(async (config) => {
3208
3261
  const method = options?.prepend ? "unshift" : "push";
3209
- const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
3262
+ const plugin = typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter;
3210
3263
  config.plugins ||= [];
3211
3264
  config.plugins[method](...toArray(plugin));
3212
3265
  }, options);
3213
3266
  }
3214
3267
  function addRspackPlugin(pluginOrGetter, options) {
3215
- extendRspackConfig((config) => {
3268
+ extendRspackConfig(async (config) => {
3216
3269
  const method = options?.prepend ? "unshift" : "push";
3217
- const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
3270
+ const plugin = typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter;
3218
3271
  config.plugins ||= [];
3219
3272
  config.plugins[method](...toArray(plugin));
3220
3273
  }, options);
@@ -3228,9 +3281,9 @@ function addVitePlugin(pluginOrGetter, options = {}) {
3228
3281
  return;
3229
3282
  }
3230
3283
  let needsEnvInjection = false;
3231
- nuxt.hook("vite:extend", ({ config }) => {
3284
+ nuxt.hook("vite:extend", async ({ config }) => {
3232
3285
  config.plugins ||= [];
3233
- const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
3286
+ const plugin = toArray(typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter);
3234
3287
  if (options.server !== false && options.client !== false) {
3235
3288
  const method = options?.prepend ? "unshift" : "push";
3236
3289
  config.plugins[method](...plugin);
@@ -3252,11 +3305,11 @@ function addVitePlugin(pluginOrGetter, options = {}) {
3252
3305
  }
3253
3306
  });
3254
3307
  });
3255
- nuxt.hook("vite:extendConfig", (config, env) => {
3308
+ nuxt.hook("vite:extendConfig", async (config, env) => {
3256
3309
  if (!needsEnvInjection) {
3257
3310
  return;
3258
3311
  }
3259
- const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
3312
+ const plugin = toArray(typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter);
3260
3313
  const method = options?.prepend ? "unshift" : "push";
3261
3314
  if (env.isClient && options.server === false) {
3262
3315
  config.plugins[method](...plugin);
@@ -3320,7 +3373,7 @@ function addComponents(addedComponents) {
3320
3373
  const existingPriority = existingComponent.priority ?? 0;
3321
3374
  const newPriority = component.priority ?? 0;
3322
3375
  if (newPriority < existingPriority) {
3323
- return;
3376
+ continue;
3324
3377
  }
3325
3378
  if (newPriority === existingPriority) {
3326
3379
  const name = existingComponent.pascalName || existingComponent.kebabName;
@@ -3509,6 +3562,7 @@ async function _generateTypes(nuxt) {
3509
3562
  moduleDetection: "force",
3510
3563
  isolatedModules: true,
3511
3564
  verbatimModuleSyntax: true,
3565
+ allowArbitraryExtensions: true,
3512
3566
  /* Strictness */
3513
3567
  strict: nuxt.options.typescript?.strict ?? true,
3514
3568
  noUncheckedIndexedAccess: isV4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.20.1",
3
+ "version": "3.21.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -23,16 +23,16 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "c12": "^3.3.1",
26
+ "c12": "^3.3.3",
27
27
  "consola": "^3.4.2",
28
28
  "defu": "^6.1.4",
29
29
  "destr": "^2.0.5",
30
30
  "errx": "^0.1.0",
31
- "exsolve": "^1.0.7",
31
+ "exsolve": "^1.0.8",
32
32
  "ignore": "^7.0.5",
33
33
  "jiti": "^2.6.1",
34
34
  "klona": "^2.0.6",
35
- "knitwork": "^1.2.0",
35
+ "knitwork": "^1.3.0",
36
36
  "mlly": "^1.8.0",
37
37
  "ohash": "^2.0.11",
38
38
  "pathe": "^2.0.3",
@@ -41,28 +41,30 @@
41
41
  "scule": "^1.3.0",
42
42
  "semver": "^7.7.3",
43
43
  "tinyglobby": "^0.2.15",
44
- "ufo": "^1.6.1",
45
- "unctx": "^2.4.1",
44
+ "ufo": "^1.6.3",
45
+ "unctx": "^2.5.0",
46
46
  "untyped": "^2.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@rspack/core": "1.6.1",
49
+ "@rspack/core": "1.7.2",
50
50
  "@types/lodash-es": "4.17.12",
51
51
  "@types/semver": "7.7.1",
52
52
  "hookable": "5.5.3",
53
- "lodash-es": "4.17.21",
54
- "nitropack": "2.12.9",
53
+ "lodash-es": "4.17.22",
54
+ "nitro": "3.0.1-alpha.1",
55
+ "nitropack": "2.13.1",
55
56
  "unbuild": "3.6.1",
56
- "unimport": "5.5.0",
57
- "vite": "7.2.1",
57
+ "unimport": "5.6.0",
58
+ "vite": "7.3.1",
58
59
  "vitest": "3.2.4",
59
- "webpack": "5.102.1",
60
- "@nuxt/schema": "3.20.1"
60
+ "webpack": "5.104.1",
61
+ "@nuxt/schema": "3.21.0"
61
62
  },
62
63
  "engines": {
63
64
  "node": ">=18.12.0"
64
65
  },
65
66
  "scripts": {
67
+ "build:stub": "unbuild --stub",
66
68
  "test:attw": "attw --pack"
67
69
  }
68
70
  }