@nuxt/kit 3.20.2 → 3.21.1
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 +5 -3
- package/dist/index.d.mts +35 -25
- package/dist/index.d.ts +35 -25
- package/dist/index.mjs +94 -66
- package/package.json +16 -14
package/README.md
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
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.
|
|
@@ -21,14 +23,14 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
|
|
|
21
23
|
- Auto imports of components, composables and utils
|
|
22
24
|
- TypeScript with zero configuration
|
|
23
25
|
- Go full-stack with our server/ directory
|
|
24
|
-
- Extensible with [
|
|
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
|
-
- 💻 [
|
|
33
|
+
- 💻 [Vue Development](#vue-development)
|
|
32
34
|
- 📖 [Documentation](#documentation)
|
|
33
35
|
- 🧩 [Modules](#modules)
|
|
34
36
|
- ❤️ [Contribute](#contribute)
|
|
@@ -109,7 +111,7 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
|
|
|
109
111
|
## <a name="follow-us">🔗 Follow Us</a>
|
|
110
112
|
|
|
111
113
|
<p valign="center">
|
|
112
|
-
<a href="https://go.nuxt.com/discord"><img width="
|
|
114
|
+
<a href="https://go.nuxt.com/discord"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a> <a href="https://go.nuxt.com/x"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a> <a href="https://go.nuxt.com/github"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a> <a href="https://go.nuxt.com/bluesky"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
|
|
113
115
|
</p>
|
|
114
116
|
|
|
115
117
|
## <a name="license">⚖️ License</a>
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
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';
|
|
1
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, ResolvedNuxtTemplate, 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
|
|
9
|
-
import
|
|
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
|
|
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
|
|
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?:
|
|
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:
|
|
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:
|
|
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 |
|
|
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 |
|
|
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 |
|
|
217
|
+
declare function addVitePlugin(pluginOrGetter: Arrayable<Plugin> | (() => Thenable<Arrayable<Plugin>>), options?: ExtendConfigOptions): void;
|
|
216
218
|
interface AddBuildPluginFactory {
|
|
217
|
-
vite?: () => Plugin
|
|
218
|
-
webpack?: () => WebpackPluginInstance
|
|
219
|
-
rspack?: () => 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:
|
|
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:
|
|
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?:
|
|
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?:
|
|
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<
|
|
529
|
+
}): Promise<void>;
|
|
520
530
|
declare function writeTypes(nuxt: Nuxt): Promise<void>;
|
|
521
531
|
|
|
522
|
-
declare const logger:
|
|
523
|
-
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>):
|
|
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
|
|
2
|
-
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';
|
|
1
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, ResolvedNuxtTemplate, 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
|
|
9
|
-
import
|
|
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
|
|
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
|
|
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?:
|
|
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:
|
|
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:
|
|
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 |
|
|
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 |
|
|
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 |
|
|
217
|
+
declare function addVitePlugin(pluginOrGetter: Arrayable<Plugin> | (() => Thenable<Arrayable<Plugin>>), options?: ExtendConfigOptions): void;
|
|
216
218
|
interface AddBuildPluginFactory {
|
|
217
|
-
vite?: () => Plugin
|
|
218
|
-
webpack?: () => WebpackPluginInstance
|
|
219
|
-
rspack?: () => 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:
|
|
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:
|
|
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?:
|
|
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?:
|
|
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<
|
|
529
|
+
}): Promise<void>;
|
|
520
530
|
declare function writeTypes(nuxt: Nuxt): Promise<void>;
|
|
521
531
|
|
|
522
|
-
declare const logger:
|
|
523
|
-
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>):
|
|
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
|
|
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';
|
|
@@ -13,7 +13,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
13
13
|
import { createJiti } from 'jiti';
|
|
14
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) {
|
|
@@ -2575,8 +2576,23 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
|
|
|
2575
2576
|
}
|
|
2576
2577
|
nuxt._moduleOptionsFunctions ||= /* @__PURE__ */ new Map();
|
|
2577
2578
|
const resolvedModules = [];
|
|
2579
|
+
const modulesByMetaName = /* @__PURE__ */ new Map();
|
|
2578
2580
|
const inlineConfigKeys = new Set(
|
|
2579
|
-
await Promise.all([...modulesToInstall].map(([mod]) =>
|
|
2581
|
+
await Promise.all([...modulesToInstall].map(async ([mod]) => {
|
|
2582
|
+
if (typeof mod === "string") {
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
const meta = await Promise.resolve(mod.getMeta?.());
|
|
2586
|
+
if (meta?.name) {
|
|
2587
|
+
modulesByMetaName.set(meta.name, mod);
|
|
2588
|
+
}
|
|
2589
|
+
if (meta?.configKey) {
|
|
2590
|
+
if (meta.configKey !== meta.name) {
|
|
2591
|
+
modulesByMetaName.set(meta.configKey, mod);
|
|
2592
|
+
}
|
|
2593
|
+
return meta.configKey;
|
|
2594
|
+
}
|
|
2595
|
+
}))
|
|
2580
2596
|
);
|
|
2581
2597
|
let error;
|
|
2582
2598
|
const dependencyMap = /* @__PURE__ */ new Map();
|
|
@@ -2587,12 +2603,12 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
|
|
|
2587
2603
|
}
|
|
2588
2604
|
throw err;
|
|
2589
2605
|
});
|
|
2590
|
-
const dependencyMeta = res.nuxtModule.getModuleDependencies?.(nuxt) || {};
|
|
2606
|
+
const dependencyMeta = await res.nuxtModule.getModuleDependencies?.(nuxt) || {};
|
|
2591
2607
|
for (const [name, value] of Object.entries(dependencyMeta)) {
|
|
2592
2608
|
if (!value.overrides && !value.defaults && !value.version && value.optional) {
|
|
2593
2609
|
continue;
|
|
2594
2610
|
}
|
|
2595
|
-
const resolvedModule = resolveModuleWithOptions(name, nuxt);
|
|
2611
|
+
const resolvedModule = modulesByMetaName.has(name) ? resolveModuleWithOptions(modulesByMetaName.get(name), nuxt) : resolveModuleWithOptions(name, nuxt);
|
|
2596
2612
|
const moduleToAttribute = typeof key === "string" ? `\`${key}\`` : "a module in `nuxt.options`";
|
|
2597
2613
|
if (!resolvedModule?.module) {
|
|
2598
2614
|
const message = `Could not resolve \`${name}\` (specified as a dependency of ${moduleToAttribute}).`;
|
|
@@ -2602,7 +2618,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
|
|
|
2602
2618
|
if (value.version) {
|
|
2603
2619
|
const resolvePaths = [res.resolvedModulePath, ...nuxt.options.modulesDir].filter(Boolean);
|
|
2604
2620
|
const pkg = await readPackageJSON(name, { from: resolvePaths }).catch(() => null);
|
|
2605
|
-
if (pkg?.version && !semver.satisfies(pkg.version, value.version)) {
|
|
2621
|
+
if (pkg?.version && !semver.satisfies(pkg.version, value.version, { includePrerelease: true })) {
|
|
2606
2622
|
const message = `Module \`${name}\` version (\`${pkg.version}\`) does not satisfy \`${value.version}\` (requested by ${moduleToAttribute}).`;
|
|
2607
2623
|
error = new TypeError(message);
|
|
2608
2624
|
}
|
|
@@ -2642,8 +2658,8 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
|
|
|
2642
2658
|
if (error) {
|
|
2643
2659
|
throw error;
|
|
2644
2660
|
}
|
|
2645
|
-
for (const { nuxtModule, meta, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions } of resolvedModules) {
|
|
2646
|
-
const configKey = meta
|
|
2661
|
+
for (const { nuxtModule, meta = {}, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions: inlineOptions2 } of resolvedModules) {
|
|
2662
|
+
const configKey = meta.configKey;
|
|
2647
2663
|
const optionsFns = [
|
|
2648
2664
|
...nuxt._moduleOptionsFunctions.get(moduleToInstall) || [],
|
|
2649
2665
|
...meta?.name ? nuxt._moduleOptionsFunctions.get(meta.name) || [] : [],
|
|
@@ -2662,12 +2678,21 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
|
|
|
2662
2678
|
nuxt.options[configKey] = defu(...overrides, nuxt.options[configKey], ...defaults);
|
|
2663
2679
|
}
|
|
2664
2680
|
}
|
|
2665
|
-
|
|
2666
|
-
|
|
2681
|
+
const isDisabled = configKey && !ignoredConfigKeys.has(configKey) && nuxt.options[configKey] === false;
|
|
2682
|
+
if (!isDisabled) {
|
|
2683
|
+
await callLifecycleHooks(nuxtModule, meta, inlineOptions2, nuxt);
|
|
2684
|
+
}
|
|
2685
|
+
const path = typeof moduleToInstall === "string" ? moduleToInstall : void 0;
|
|
2686
|
+
await callModule(nuxt, nuxtModule, inlineOptions2, {
|
|
2687
|
+
meta: defu({ disabled: isDisabled }, meta, buildTimeModuleMeta),
|
|
2688
|
+
nameOrPath: path,
|
|
2689
|
+
modulePath: resolvedModulePath || path,
|
|
2690
|
+
localLayerModuleDirs
|
|
2691
|
+
});
|
|
2667
2692
|
}
|
|
2668
2693
|
delete nuxt._moduleOptionsFunctions;
|
|
2669
2694
|
}
|
|
2670
|
-
async function installModule(moduleToInstall,
|
|
2695
|
+
async function installModule(moduleToInstall, inlineOptions2, nuxt = useNuxt()) {
|
|
2671
2696
|
const { nuxtModule, buildTimeModuleMeta, resolvedModulePath } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
|
|
2672
2697
|
const localLayerModuleDirs = [];
|
|
2673
2698
|
for (const dirs of getLayerDirectories(nuxt)) {
|
|
@@ -2676,7 +2701,7 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
|
2676
2701
|
}
|
|
2677
2702
|
}
|
|
2678
2703
|
const meta = await nuxtModule.getMeta?.();
|
|
2679
|
-
let mergedOptions =
|
|
2704
|
+
let mergedOptions = inlineOptions2;
|
|
2680
2705
|
const configKey = meta?.configKey;
|
|
2681
2706
|
if (configKey && nuxt._moduleOptionsFunctions) {
|
|
2682
2707
|
const optionsFns = [
|
|
@@ -2691,12 +2716,21 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
|
2691
2716
|
overrides.push(options.overrides);
|
|
2692
2717
|
defaults.push(options.defaults);
|
|
2693
2718
|
}
|
|
2694
|
-
mergedOptions = defu(
|
|
2719
|
+
mergedOptions = defu(inlineOptions2, ...overrides, nuxt.options[configKey], ...defaults);
|
|
2695
2720
|
nuxt.options[configKey] = mergedOptions;
|
|
2696
2721
|
}
|
|
2697
2722
|
}
|
|
2698
|
-
|
|
2699
|
-
|
|
2723
|
+
const isDisabled = configKey && !ignoredConfigKeys.has(configKey) && nuxt.options[configKey] === false;
|
|
2724
|
+
if (!isDisabled) {
|
|
2725
|
+
await callLifecycleHooks(nuxtModule, meta, mergedOptions, nuxt);
|
|
2726
|
+
}
|
|
2727
|
+
const path = typeof moduleToInstall === "string" ? moduleToInstall : void 0;
|
|
2728
|
+
await callModule(nuxt, nuxtModule, mergedOptions, {
|
|
2729
|
+
meta: defu({ disabled: isDisabled }, meta, buildTimeModuleMeta),
|
|
2730
|
+
nameOrPath: path,
|
|
2731
|
+
modulePath: resolvedModulePath || path,
|
|
2732
|
+
localLayerModuleDirs
|
|
2733
|
+
});
|
|
2700
2734
|
}
|
|
2701
2735
|
function resolveModuleWithOptions(definition, nuxt) {
|
|
2702
2736
|
const [module, options = {}] = Array.isArray(definition) ? definition : [definition, {}];
|
|
@@ -2779,7 +2813,7 @@ const normalizeModuleTranspilePath = (p) => {
|
|
|
2779
2813
|
return getDirectory(p).split("node_modules/").pop();
|
|
2780
2814
|
};
|
|
2781
2815
|
const MissingModuleMatcher = /Cannot find module\s+['"]?([^'")\s]+)['"]?/i;
|
|
2782
|
-
async function callLifecycleHooks(nuxtModule, meta = {},
|
|
2816
|
+
async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions2, nuxt = useNuxt()) {
|
|
2783
2817
|
if (!meta.name || !meta.version) {
|
|
2784
2818
|
return;
|
|
2785
2819
|
}
|
|
@@ -2792,7 +2826,7 @@ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions, nuxt = u
|
|
|
2792
2826
|
if (!previousVersion) {
|
|
2793
2827
|
await nuxtModule.onInstall?.(nuxt);
|
|
2794
2828
|
} else if (semver.gt(meta.version, previousVersion)) {
|
|
2795
|
-
await nuxtModule.onUpgrade?.(
|
|
2829
|
+
await nuxtModule.onUpgrade?.(nuxt, inlineOptions2, previousVersion);
|
|
2796
2830
|
}
|
|
2797
2831
|
if (previousVersion !== meta.version) {
|
|
2798
2832
|
update(
|
|
@@ -2806,12 +2840,12 @@ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions, nuxt = u
|
|
|
2806
2840
|
);
|
|
2807
2841
|
}
|
|
2808
2842
|
}
|
|
2809
|
-
async function callModule(nuxtModule,
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
const
|
|
2843
|
+
async function callModule(nuxt, nuxtModule, moduleOptions = {}, options) {
|
|
2844
|
+
const modulePath = options.modulePath;
|
|
2845
|
+
const nameOrPath = options.nameOrPath;
|
|
2846
|
+
const localLayerModuleDirs = options.localLayerModuleDirs;
|
|
2847
|
+
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);
|
|
2848
|
+
const res = options.meta.disabled ? false : await fn();
|
|
2815
2849
|
let entryPath;
|
|
2816
2850
|
if (typeof modulePath === "string") {
|
|
2817
2851
|
const parsed = parseNodeModulePath(modulePath);
|
|
@@ -2819,22 +2853,26 @@ async function callModule(nuxtModule, meta = {}, inlineOptions, resolvedModulePa
|
|
|
2819
2853
|
const subpath = await lookupNodeModuleSubpath(modulePath) || ".";
|
|
2820
2854
|
entryPath = join(parsed.name, subpath === "./" ? "." : subpath);
|
|
2821
2855
|
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2856
|
+
if (res !== false) {
|
|
2857
|
+
const moduleRoot = parsed.dir ? parsed.dir + parsed.name : await resolvePackageJSON(modulePath, { try: true }).then((r) => r ? dirname(r) : modulePath);
|
|
2858
|
+
nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleRoot));
|
|
2859
|
+
const directory = moduleRoot.replace(/\/?$/, "/");
|
|
2860
|
+
if (moduleRoot !== nameOrPath && !localLayerModuleDirs.some((dir) => directory.startsWith(dir))) {
|
|
2861
|
+
nuxt.options.modulesDir.push(join(moduleRoot, "node_modules"));
|
|
2862
|
+
}
|
|
2827
2863
|
}
|
|
2828
2864
|
}
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2865
|
+
if (nameOrPath) {
|
|
2866
|
+
entryPath ||= resolveAlias(nameOrPath, nuxt.options.alias);
|
|
2867
|
+
if (entryPath !== nameOrPath) {
|
|
2868
|
+
options.meta.rawPath = nameOrPath;
|
|
2869
|
+
}
|
|
2833
2870
|
}
|
|
2871
|
+
nuxt.options._installedModules ||= [];
|
|
2834
2872
|
nuxt.options._installedModules.push({
|
|
2835
|
-
meta:
|
|
2873
|
+
meta: options.meta,
|
|
2836
2874
|
module: nuxtModule,
|
|
2837
|
-
timings: res.timings,
|
|
2875
|
+
timings: (res || {}).timings,
|
|
2838
2876
|
entryPath
|
|
2839
2877
|
});
|
|
2840
2878
|
}
|
|
@@ -2885,8 +2923,8 @@ async function loadNuxtConfig(opts) {
|
|
|
2885
2923
|
const localLayers = (await glob("layers/*", {
|
|
2886
2924
|
onlyDirectories: true,
|
|
2887
2925
|
cwd: opts.cwd || process.cwd()
|
|
2888
|
-
})).map((d) =>
|
|
2889
|
-
opts.overrides = defu
|
|
2926
|
+
})).map((d) => withTrailingSlash$2(d)).sort((a, b) => b.localeCompare(a));
|
|
2927
|
+
opts.overrides = defu(opts.overrides, { _extends: localLayers });
|
|
2890
2928
|
const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await withDefineNuxtConfig(
|
|
2891
2929
|
() => loadConfig({
|
|
2892
2930
|
name: "nuxt",
|
|
@@ -2921,7 +2959,7 @@ async function loadNuxtConfig(opts) {
|
|
|
2921
2959
|
}
|
|
2922
2960
|
const _layers = [];
|
|
2923
2961
|
const processedLayers = /* @__PURE__ */ new Set();
|
|
2924
|
-
const localRelativePaths = new Set(localLayers);
|
|
2962
|
+
const localRelativePaths = new Set(localLayers.map((layer) => withoutTrailingSlash(layer)));
|
|
2925
2963
|
for (const layer of layers) {
|
|
2926
2964
|
const resolvedRootDir = layer.config?.rootDir ?? layer.cwd;
|
|
2927
2965
|
layer.config = {
|
|
@@ -3075,7 +3113,7 @@ const HANDLER_METHOD_RE = /\.(get|head|patch|post|put|delete|connect|options|tra
|
|
|
3075
3113
|
function normalizeHandlerMethod(handler) {
|
|
3076
3114
|
const [, method = void 0] = handler.handler.match(HANDLER_METHOD_RE) || [];
|
|
3077
3115
|
return {
|
|
3078
|
-
method,
|
|
3116
|
+
method: method?.toUpperCase(),
|
|
3079
3117
|
...handler,
|
|
3080
3118
|
handler: normalize(handler.handler)
|
|
3081
3119
|
};
|
|
@@ -3148,7 +3186,7 @@ function useRuntimeConfig() {
|
|
|
3148
3186
|
}
|
|
3149
3187
|
function updateRuntimeConfig(runtimeConfig) {
|
|
3150
3188
|
const nuxt = useNuxt();
|
|
3151
|
-
Object.assign(nuxt.options.nitro.runtimeConfig, defu
|
|
3189
|
+
Object.assign(nuxt.options.nitro.runtimeConfig, defu(runtimeConfig, nuxt.options.nitro.runtimeConfig));
|
|
3152
3190
|
try {
|
|
3153
3191
|
return useNitro().updateConfig({ runtimeConfig });
|
|
3154
3192
|
} catch {
|
|
@@ -3200,17 +3238,17 @@ const extendWebpackCompatibleConfig = (builder) => (fn, options = {}) => {
|
|
|
3200
3238
|
if (options.build === false && nuxt.options.build) {
|
|
3201
3239
|
return;
|
|
3202
3240
|
}
|
|
3203
|
-
nuxt.hook(`${builder}:config`, (configs) => {
|
|
3241
|
+
nuxt.hook(`${builder}:config`, async (configs) => {
|
|
3204
3242
|
if (options.server !== false) {
|
|
3205
3243
|
const config = configs.find((i) => i.name === "server");
|
|
3206
3244
|
if (config) {
|
|
3207
|
-
fn(config);
|
|
3245
|
+
await fn(config);
|
|
3208
3246
|
}
|
|
3209
3247
|
}
|
|
3210
3248
|
if (options.client !== false) {
|
|
3211
3249
|
const config = configs.find((i) => i.name === "client");
|
|
3212
3250
|
if (config) {
|
|
3213
|
-
fn(config);
|
|
3251
|
+
await fn(config);
|
|
3214
3252
|
}
|
|
3215
3253
|
}
|
|
3216
3254
|
});
|
|
@@ -3234,17 +3272,17 @@ function extendViteConfig(fn, options = {}) {
|
|
|
3234
3272
|
return nuxt.hook("vite:extend", ({ config }) => fn(config));
|
|
3235
3273
|
}
|
|
3236
3274
|
function addWebpackPlugin(pluginOrGetter, options) {
|
|
3237
|
-
extendWebpackConfig((config) => {
|
|
3275
|
+
extendWebpackConfig(async (config) => {
|
|
3238
3276
|
const method = options?.prepend ? "unshift" : "push";
|
|
3239
|
-
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
3277
|
+
const plugin = typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter;
|
|
3240
3278
|
config.plugins ||= [];
|
|
3241
3279
|
config.plugins[method](...toArray(plugin));
|
|
3242
3280
|
}, options);
|
|
3243
3281
|
}
|
|
3244
3282
|
function addRspackPlugin(pluginOrGetter, options) {
|
|
3245
|
-
extendRspackConfig((config) => {
|
|
3283
|
+
extendRspackConfig(async (config) => {
|
|
3246
3284
|
const method = options?.prepend ? "unshift" : "push";
|
|
3247
|
-
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
3285
|
+
const plugin = typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter;
|
|
3248
3286
|
config.plugins ||= [];
|
|
3249
3287
|
config.plugins[method](...toArray(plugin));
|
|
3250
3288
|
}, options);
|
|
@@ -3258,9 +3296,9 @@ function addVitePlugin(pluginOrGetter, options = {}) {
|
|
|
3258
3296
|
return;
|
|
3259
3297
|
}
|
|
3260
3298
|
let needsEnvInjection = false;
|
|
3261
|
-
nuxt.hook("vite:extend", ({ config }) => {
|
|
3299
|
+
nuxt.hook("vite:extend", async ({ config }) => {
|
|
3262
3300
|
config.plugins ||= [];
|
|
3263
|
-
const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
|
|
3301
|
+
const plugin = toArray(typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter);
|
|
3264
3302
|
if (options.server !== false && options.client !== false) {
|
|
3265
3303
|
const method = options?.prepend ? "unshift" : "push";
|
|
3266
3304
|
config.plugins[method](...plugin);
|
|
@@ -3282,11 +3320,11 @@ function addVitePlugin(pluginOrGetter, options = {}) {
|
|
|
3282
3320
|
}
|
|
3283
3321
|
});
|
|
3284
3322
|
});
|
|
3285
|
-
nuxt.hook("vite:extendConfig", (config, env) => {
|
|
3323
|
+
nuxt.hook("vite:extendConfig", async (config, env) => {
|
|
3286
3324
|
if (!needsEnvInjection) {
|
|
3287
3325
|
return;
|
|
3288
3326
|
}
|
|
3289
|
-
const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
|
|
3327
|
+
const plugin = toArray(typeof pluginOrGetter === "function" ? await pluginOrGetter() : pluginOrGetter);
|
|
3290
3328
|
const method = options?.prepend ? "unshift" : "push";
|
|
3291
3329
|
if (env.isClient && options.server === false) {
|
|
3292
3330
|
config.plugins[method](...plugin);
|
|
@@ -3350,7 +3388,7 @@ function addComponents(addedComponents) {
|
|
|
3350
3388
|
const existingPriority = existingComponent.priority ?? 0;
|
|
3351
3389
|
const newPriority = component.priority ?? 0;
|
|
3352
3390
|
if (newPriority < existingPriority) {
|
|
3353
|
-
|
|
3391
|
+
continue;
|
|
3354
3392
|
}
|
|
3355
3393
|
if (newPriority === existingPriority) {
|
|
3356
3394
|
const name = existingComponent.pascalName || existingComponent.kebabName;
|
|
@@ -3539,6 +3577,7 @@ async function _generateTypes(nuxt) {
|
|
|
3539
3577
|
moduleDetection: "force",
|
|
3540
3578
|
isolatedModules: true,
|
|
3541
3579
|
verbatimModuleSyntax: true,
|
|
3580
|
+
allowArbitraryExtensions: true,
|
|
3542
3581
|
/* Strictness */
|
|
3543
3582
|
strict: nuxt.options.typescript?.strict ?? true,
|
|
3544
3583
|
noUncheckedIndexedAccess: isV4,
|
|
@@ -3652,12 +3691,7 @@ async function _generateTypes(nuxt) {
|
|
|
3652
3691
|
tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
|
|
3653
3692
|
tsConfig.exclude = [...new Set(tsConfig.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
|
|
3654
3693
|
const declaration = [
|
|
3655
|
-
...references.map((ref) =>
|
|
3656
|
-
if ("path" in ref && isAbsolute(ref.path)) {
|
|
3657
|
-
ref.path = relative(nuxt.options.buildDir, ref.path);
|
|
3658
|
-
}
|
|
3659
|
-
return `/// <reference ${renderAttrs(ref)} />`;
|
|
3660
|
-
}),
|
|
3694
|
+
...references.map((ref) => renderReference(ref, nuxt.options.buildDir)),
|
|
3661
3695
|
...declarations,
|
|
3662
3696
|
"",
|
|
3663
3697
|
"export {}",
|
|
@@ -3689,15 +3723,9 @@ function sortTsPaths(paths) {
|
|
|
3689
3723
|
}
|
|
3690
3724
|
}
|
|
3691
3725
|
}
|
|
3692
|
-
function
|
|
3693
|
-
const
|
|
3694
|
-
|
|
3695
|
-
attrs.push(renderAttr(key, obj[key]));
|
|
3696
|
-
}
|
|
3697
|
-
return attrs.join(" ");
|
|
3698
|
-
}
|
|
3699
|
-
function renderAttr(key, value) {
|
|
3700
|
-
return value ? `${key}="${value}"` : "";
|
|
3726
|
+
function renderReference(ref, baseDir) {
|
|
3727
|
+
const stuff = "path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`;
|
|
3728
|
+
return `/// <reference ${stuff} />`;
|
|
3701
3729
|
}
|
|
3702
3730
|
const RELATIVE_WITH_DOT_RE = /^([^.])/;
|
|
3703
3731
|
function relativeWithDot(from, to) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"c12": "^3.3.
|
|
26
|
+
"c12": "^3.3.3",
|
|
27
27
|
"consola": "^3.4.2",
|
|
28
28
|
"defu": "^6.1.4",
|
|
29
29
|
"destr": "^2.0.5",
|
|
@@ -37,32 +37,34 @@
|
|
|
37
37
|
"ohash": "^2.0.11",
|
|
38
38
|
"pathe": "^2.0.3",
|
|
39
39
|
"pkg-types": "^2.3.0",
|
|
40
|
-
"rc9": "^
|
|
40
|
+
"rc9": "^3.0.0",
|
|
41
41
|
"scule": "^1.3.0",
|
|
42
|
-
"semver": "^7.7.
|
|
42
|
+
"semver": "^7.7.4",
|
|
43
43
|
"tinyglobby": "^0.2.15",
|
|
44
|
-
"ufo": "^1.6.
|
|
45
|
-
"unctx": "^2.
|
|
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.
|
|
49
|
+
"@rspack/core": "1.7.5",
|
|
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.
|
|
54
|
-
"
|
|
53
|
+
"lodash-es": "4.17.23",
|
|
54
|
+
"nitro": "3.0.1-alpha.2",
|
|
55
|
+
"nitropack": "2.13.1",
|
|
55
56
|
"unbuild": "3.6.1",
|
|
56
|
-
"unimport": "5.
|
|
57
|
-
"vite": "7.
|
|
58
|
-
"vitest": "
|
|
59
|
-
"webpack": "5.
|
|
60
|
-
"@nuxt/schema": "3.
|
|
57
|
+
"unimport": "5.6.0",
|
|
58
|
+
"vite": "7.3.1",
|
|
59
|
+
"vitest": "4.0.18",
|
|
60
|
+
"webpack": "5.105.0",
|
|
61
|
+
"@nuxt/schema": "3.21.1"
|
|
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
|
}
|