@nuxt/kit-nightly 4.4.3-29621460.375401cc → 4.4.3-29621635.a4e85d14
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/dist/index.d.mts +0 -49
- package/dist/index.mjs +0 -289
- package/package.json +14 -14
package/dist/index.d.mts
CHANGED
|
@@ -9,8 +9,6 @@ import { RspackPluginInstance } from "@rspack/core";
|
|
|
9
9
|
import { Plugin, UserConfig } from "vite";
|
|
10
10
|
import * as NitroV2 from "nitropack/types";
|
|
11
11
|
import * as NitroV3 from "nitro/types";
|
|
12
|
-
|
|
13
|
-
//#region src/module/define.d.ts
|
|
14
12
|
/**
|
|
15
13
|
* Define a Nuxt module, automatically merging defaults with user provided options, installing
|
|
16
14
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
@@ -19,8 +17,6 @@ declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: Mo
|
|
|
19
17
|
declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
|
|
20
18
|
with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
|
|
21
19
|
};
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/module/install.d.ts
|
|
24
20
|
type ModuleToInstall = string | NuxtModule<ModuleOptions, Partial<ModuleOptions>, false>;
|
|
25
21
|
/**
|
|
26
22
|
* Installs a set of modules on a Nuxt instance.
|
|
@@ -44,8 +40,6 @@ declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?:
|
|
|
44
40
|
}>;
|
|
45
41
|
declare function getDirectory(p: string): string;
|
|
46
42
|
declare const normalizeModuleTranspilePath: (p: string) => string;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/module/compatibility.d.ts
|
|
49
43
|
/**
|
|
50
44
|
* Check if a Nuxt module is installed by name.
|
|
51
45
|
*
|
|
@@ -63,17 +57,11 @@ declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverV
|
|
|
63
57
|
* Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
|
|
64
58
|
*/
|
|
65
59
|
declare function getNuxtModuleVersion(module: string | NuxtModule, nuxt?: Nuxt | any): Promise<string | false>;
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/loader/config.d.ts
|
|
68
60
|
interface LoadNuxtConfigOptions extends Omit<LoadConfigOptions<NuxtConfig>, "overrides"> {
|
|
69
61
|
overrides?: Exclude<LoadConfigOptions<NuxtConfig>["overrides"], Promise<any> | Function>;
|
|
70
62
|
}
|
|
71
63
|
declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/loader/schema.d.ts
|
|
74
64
|
declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/loader/nuxt.d.ts
|
|
77
65
|
interface LoadNuxtOptions extends LoadNuxtConfigOptions {
|
|
78
66
|
/** Load nuxt with development mode */
|
|
79
67
|
dev?: boolean;
|
|
@@ -82,8 +70,6 @@ interface LoadNuxtOptions extends LoadNuxtConfigOptions {
|
|
|
82
70
|
}
|
|
83
71
|
declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
|
|
84
72
|
declare function buildNuxt(nuxt: Nuxt): Promise<any>;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/layers.d.ts
|
|
87
73
|
interface LayerDirectories {
|
|
88
74
|
/** Nuxt rootDir (`/` by default) */
|
|
89
75
|
readonly root: string;
|
|
@@ -118,18 +104,12 @@ interface LayerDirectories {
|
|
|
118
104
|
* @returns Array of LayerDirectories objects, ordered by priority (user layer first)
|
|
119
105
|
*/
|
|
120
106
|
declare function getLayerDirectories(nuxt?: Nuxt): LayerDirectories[];
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/head.d.ts
|
|
123
107
|
declare function setGlobalHead(head: NuxtAppConfig["head"]): void;
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/imports.d.ts
|
|
126
108
|
declare function addImports(imports: Import | Import[]): void;
|
|
127
109
|
declare function addImportsDir(dirs: string | string[], opts?: {
|
|
128
110
|
prepend?: boolean;
|
|
129
111
|
}): void;
|
|
130
112
|
declare function addImportsSources(presets: Preset | Preset[]): void;
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/runtime-config.d.ts
|
|
133
113
|
/**
|
|
134
114
|
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
135
115
|
*
|
|
@@ -140,8 +120,6 @@ declare function useRuntimeConfig(): Record<string, any>;
|
|
|
140
120
|
* Update Nuxt runtime configuration.
|
|
141
121
|
*/
|
|
142
122
|
declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
|
|
143
|
-
//#endregion
|
|
144
|
-
//#region src/build.d.ts
|
|
145
123
|
type Arrayable<T> = T | T[];
|
|
146
124
|
type Thenable<T> = T | Promise<T>;
|
|
147
125
|
interface ExtendConfigOptions {
|
|
@@ -226,8 +204,6 @@ interface AddBuildPluginFactory {
|
|
|
226
204
|
rspack?: () => Thenable<Arrayable<RspackPluginInstance>>;
|
|
227
205
|
}
|
|
228
206
|
declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/compatibility.d.ts
|
|
231
207
|
declare function normalizeSemanticVersion(version: string): string;
|
|
232
208
|
/**
|
|
233
209
|
* Check version constraints and return incompatibility issues as an array
|
|
@@ -258,8 +234,6 @@ declare function isNuxt3(nuxt?: Nuxt): boolean;
|
|
|
258
234
|
* Get nuxt version
|
|
259
235
|
*/
|
|
260
236
|
declare function getNuxtVersion(nuxt?: Nuxt | any): string;
|
|
261
|
-
//#endregion
|
|
262
|
-
//#region src/components.d.ts
|
|
263
237
|
/**
|
|
264
238
|
* Register a directory to be scanned for components and imported only when used.
|
|
265
239
|
*/
|
|
@@ -280,8 +254,6 @@ declare function addComponentExports(opts: Omit<AddComponentOptions, "name"> & {
|
|
|
280
254
|
* Register a component by its name and filePath.
|
|
281
255
|
*/
|
|
282
256
|
declare function addComponent(opts: AddComponentOptions): void;
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region src/context.d.ts
|
|
285
257
|
/**
|
|
286
258
|
* Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
|
|
287
259
|
* @deprecated Use `getNuxtCtx` instead
|
|
@@ -313,27 +285,19 @@ declare function useNuxt(): Nuxt;
|
|
|
313
285
|
*/
|
|
314
286
|
declare function tryUseNuxt(): Nuxt | null;
|
|
315
287
|
declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/ignore.d.ts
|
|
318
288
|
declare function createIsIgnored(nuxt?: Nuxt | null | undefined): (pathname: string, stats?: unknown) => boolean;
|
|
319
289
|
/**
|
|
320
290
|
* Return a filter function to filter an array of paths
|
|
321
291
|
*/
|
|
322
292
|
declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: Nuxt | null | undefined): boolean;
|
|
323
293
|
declare function resolveIgnorePatterns(relativePath?: string): string[];
|
|
324
|
-
//#endregion
|
|
325
|
-
//#region src/layout.d.ts
|
|
326
294
|
declare function addLayout(template: NuxtTemplate | string, name?: string): void;
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/nitro-types.d.ts
|
|
329
295
|
type isNitroV2 = "options" extends keyof NitroV2.Nitro ? "___INVALID" extends keyof NitroV2.Nitro ? false : true : false;
|
|
330
296
|
type isNitroV3 = "options" extends keyof NitroV3.Nitro ? "___INVALID" extends keyof NitroV3.Nitro ? false : true : false;
|
|
331
297
|
type Nitro = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.Nitro | NitroV3.Nitro : NitroV2.Nitro : NitroV3.Nitro;
|
|
332
298
|
type NitroDevEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroDevEventHandler | NitroV3.NitroDevEventHandler : NitroV2.NitroDevEventHandler : NitroV3.NitroDevEventHandler;
|
|
333
299
|
type NitroEventHandler = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroEventHandler | NitroV3.NitroEventHandler : NitroV2.NitroEventHandler : NitroV3.NitroEventHandler;
|
|
334
300
|
type NitroRouteConfig = isNitroV2 extends true ? isNitroV3 extends true ? NitroV2.NitroRouteConfig | NitroV3.NitroRouteConfig : NitroV2.NitroRouteConfig : NitroV3.NitroRouteConfig;
|
|
335
|
-
//#endregion
|
|
336
|
-
//#region src/pages.d.ts
|
|
337
301
|
declare function extendPages(cb: NuxtHooks["pages:extend"]): void;
|
|
338
302
|
interface ExtendRouteRulesOptions {
|
|
339
303
|
/**
|
|
@@ -356,8 +320,6 @@ interface AddRouteMiddlewareOptions {
|
|
|
356
320
|
prepend?: boolean;
|
|
357
321
|
}
|
|
358
322
|
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region src/plugin.d.ts
|
|
361
323
|
declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
|
|
362
324
|
/**
|
|
363
325
|
* Registers a nuxt plugin and to the plugins array.
|
|
@@ -385,8 +347,6 @@ declare function addPlugin(_plugin: NuxtPlugin | string, opts?: AddPluginOptions
|
|
|
385
347
|
* Adds a template and registers as a nuxt plugin.
|
|
386
348
|
*/
|
|
387
349
|
declare function addPluginTemplate(plugin: NuxtPluginTemplate | string, opts?: AddPluginOptions): NuxtPlugin;
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/resolve.d.ts
|
|
390
350
|
interface ResolvePathOptions {
|
|
391
351
|
/** Base for resolving paths from. Default is Nuxt rootDir. */
|
|
392
352
|
cwd?: string;
|
|
@@ -453,8 +413,6 @@ declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
|
453
413
|
followSymbolicLinks?: boolean;
|
|
454
414
|
ignore?: GlobOptions["ignore"];
|
|
455
415
|
}): Promise<string[]>;
|
|
456
|
-
//#endregion
|
|
457
|
-
//#region src/nitro.d.ts
|
|
458
416
|
/**
|
|
459
417
|
* Adds a nitro server handler
|
|
460
418
|
*
|
|
@@ -505,8 +463,6 @@ declare function addServerImportsDir(dirs: string | string[], opts?: {
|
|
|
505
463
|
declare function addServerScanDir(dirs: string | string[], opts?: {
|
|
506
464
|
prepend?: boolean;
|
|
507
465
|
}): void;
|
|
508
|
-
//#endregion
|
|
509
|
-
//#region src/template.d.ts
|
|
510
466
|
/**
|
|
511
467
|
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
|
|
512
468
|
*/
|
|
@@ -542,12 +498,8 @@ declare function updateTemplates(options?: {
|
|
|
542
498
|
filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
|
|
543
499
|
}): Promise<void>;
|
|
544
500
|
declare function writeTypes(nuxt: Nuxt): Promise<void>;
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/logger.d.ts
|
|
547
501
|
declare const logger: ConsolaInstance;
|
|
548
502
|
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance;
|
|
549
|
-
//#endregion
|
|
550
|
-
//#region src/internal/esm.d.ts
|
|
551
503
|
interface ResolveModuleOptions {
|
|
552
504
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
553
505
|
paths?: string | string[];
|
|
@@ -580,5 +532,4 @@ declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptio
|
|
|
580
532
|
* @deprecated Please use `tryImportModule` instead.
|
|
581
533
|
*/
|
|
582
534
|
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
|
|
583
|
-
//#endregion
|
|
584
535
|
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LayerDirectories, type LoadNuxtConfigOptions, type LoadNuxtOptions, type NuxtMajorVersion, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, 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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/dist/index.mjs
CHANGED
|
@@ -26,59 +26,27 @@ import { kebabCase, pascalCase, snakeCase } from "scule";
|
|
|
26
26
|
import { klona } from "klona";
|
|
27
27
|
import { hash } from "ohash";
|
|
28
28
|
import { isAbsolute as isAbsolute$1 } from "node:path";
|
|
29
|
-
//#region src/logger.ts
|
|
30
29
|
const logger = consola;
|
|
31
30
|
function useLogger(tag, options = {}) {
|
|
32
31
|
return tag ? logger.create(options).withTag(tag) : logger;
|
|
33
32
|
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/context.ts
|
|
36
|
-
/**
|
|
37
|
-
* Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
|
|
38
|
-
* @deprecated Use `getNuxtCtx` instead
|
|
39
|
-
*/
|
|
40
33
|
const nuxtCtx = getContext("nuxt");
|
|
41
|
-
/** async local storage for the name of the current nuxt instance */
|
|
42
34
|
const asyncNuxtStorage = getContext("asyncNuxtStorage", {
|
|
43
35
|
asyncContext: true,
|
|
44
36
|
AsyncLocalStorage
|
|
45
37
|
});
|
|
46
|
-
/** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
|
|
47
38
|
const getNuxtCtx = () => asyncNuxtStorage.tryUse();
|
|
48
|
-
/**
|
|
49
|
-
* Get access to Nuxt instance.
|
|
50
|
-
*
|
|
51
|
-
* Throws an error if Nuxt instance is unavailable.
|
|
52
|
-
* @example
|
|
53
|
-
* ```js
|
|
54
|
-
* const nuxt = useNuxt()
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
39
|
function useNuxt() {
|
|
58
40
|
const instance = asyncNuxtStorage.tryUse() || nuxtCtx.tryUse();
|
|
59
41
|
if (!instance) throw new Error("Nuxt instance is unavailable!");
|
|
60
42
|
return instance;
|
|
61
43
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Get access to Nuxt instance.
|
|
64
|
-
*
|
|
65
|
-
* Returns null if Nuxt instance is unavailable.
|
|
66
|
-
* @example
|
|
67
|
-
* ```js
|
|
68
|
-
* const nuxt = tryUseNuxt()
|
|
69
|
-
* if (nuxt) {
|
|
70
|
-
* // Do something
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
44
|
function tryUseNuxt() {
|
|
75
45
|
return asyncNuxtStorage.tryUse() || nuxtCtx.tryUse();
|
|
76
46
|
}
|
|
77
47
|
function runWithNuxtContext(nuxt, fn) {
|
|
78
48
|
return asyncNuxtStorage.call(nuxt, fn);
|
|
79
49
|
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/compatibility.ts
|
|
82
50
|
const SEMANTIC_VERSION_RE = /-\d+\.[0-9a-f]+/;
|
|
83
51
|
function normalizeSemanticVersion(version) {
|
|
84
52
|
return version.replace(SEMANTIC_VERSION_RE, "");
|
|
@@ -91,9 +59,6 @@ const builderMap = {
|
|
|
91
59
|
function checkNuxtVersion(version, nuxt = useNuxt()) {
|
|
92
60
|
return satisfies(normalizeSemanticVersion(getNuxtVersion(nuxt)), version, { includePrerelease: true });
|
|
93
61
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Check version constraints and return incompatibility issues as an array
|
|
96
|
-
*/
|
|
97
62
|
async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
98
63
|
const issues = [];
|
|
99
64
|
if (constraints.nuxt) {
|
|
@@ -131,50 +96,30 @@ async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
|
131
96
|
issues.toString = () => issues.map((issue) => ` - [${issue.name}] ${issue.message}`).join("\n");
|
|
132
97
|
return issues;
|
|
133
98
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Check version constraints and throw a detailed error if has any, otherwise returns true
|
|
136
|
-
*/
|
|
137
99
|
async function assertNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
138
100
|
const issues = await checkNuxtCompatibility(constraints, nuxt);
|
|
139
101
|
if (issues.length) throw new Error("Nuxt compatibility issues found:\n" + issues.toString());
|
|
140
102
|
return true;
|
|
141
103
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Check version constraints and return true if passed, otherwise returns false
|
|
144
|
-
*/
|
|
145
104
|
async function hasNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
146
105
|
return !(await checkNuxtCompatibility(constraints, nuxt)).length;
|
|
147
106
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Check if current Nuxt instance is of specified major version
|
|
150
|
-
*/
|
|
151
107
|
function isNuxtMajorVersion(majorVersion, nuxt = useNuxt()) {
|
|
152
108
|
const version = getNuxtVersion(nuxt);
|
|
153
109
|
return version[0] === majorVersion.toString() && version[1] === ".";
|
|
154
110
|
}
|
|
155
|
-
/**
|
|
156
|
-
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
|
157
|
-
*/
|
|
158
111
|
function isNuxt2(nuxt = useNuxt()) {
|
|
159
112
|
return isNuxtMajorVersion(2, nuxt);
|
|
160
113
|
}
|
|
161
|
-
/**
|
|
162
|
-
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
|
163
|
-
*/
|
|
164
114
|
function isNuxt3(nuxt = useNuxt()) {
|
|
165
115
|
return isNuxtMajorVersion(3, nuxt);
|
|
166
116
|
}
|
|
167
117
|
const NUXT_VERSION_RE = /^v/g;
|
|
168
|
-
/**
|
|
169
|
-
* Get nuxt version
|
|
170
|
-
*/
|
|
171
118
|
function getNuxtVersion(nuxt = useNuxt()) {
|
|
172
119
|
const rawVersion = nuxt?._version || nuxt?.version || nuxt?.constructor?.version;
|
|
173
120
|
if (typeof rawVersion !== "string") throw new TypeError("Cannot determine nuxt version! Is current instance passed?");
|
|
174
121
|
return rawVersion.replace(NUXT_VERSION_RE, "");
|
|
175
122
|
}
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region src/module/define.ts
|
|
178
123
|
function defineNuxtModule(definition) {
|
|
179
124
|
if (definition) return _defineNuxtModule(definition);
|
|
180
125
|
return { with: (definition) => _defineNuxtModule(definition) };
|
|
@@ -239,8 +184,6 @@ function _defineNuxtModule(definition) {
|
|
|
239
184
|
normalizedModule.onUpgrade = module.onUpgrade;
|
|
240
185
|
return normalizedModule;
|
|
241
186
|
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/internal/trace.ts
|
|
244
187
|
const distURL = import.meta.url.replace(/\/dist\/.*$/, "/");
|
|
245
188
|
function getUserCaller() {
|
|
246
189
|
if (!import.meta.dev) return null;
|
|
@@ -259,20 +202,7 @@ function warn(warning) {
|
|
|
259
202
|
warnings.add(warning);
|
|
260
203
|
}
|
|
261
204
|
}
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/layers.ts
|
|
264
205
|
const layerMap = /* @__PURE__ */ new WeakMap();
|
|
265
|
-
/**
|
|
266
|
-
* Get the resolved directory paths for all layers in a Nuxt application.
|
|
267
|
-
*
|
|
268
|
-
* Returns an array of LayerDirectories objects, ordered by layer priority:
|
|
269
|
-
* - The first layer is the user/project layer (highest priority)
|
|
270
|
-
* - Earlier layers override later layers in the array
|
|
271
|
-
* - Base layers appear last in the array (lowest priority)
|
|
272
|
-
*
|
|
273
|
-
* @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
|
|
274
|
-
* @returns Array of LayerDirectories objects, ordered by priority (user layer first)
|
|
275
|
-
*/
|
|
276
206
|
function getLayerDirectories(nuxt = useNuxt()) {
|
|
277
207
|
return nuxt.options._layers.map((layer) => {
|
|
278
208
|
if (layerMap.has(layer)) return layerMap.get(layer);
|
|
@@ -298,14 +228,9 @@ function getLayerDirectories(nuxt = useNuxt()) {
|
|
|
298
228
|
function withTrailingSlash$2(dir) {
|
|
299
229
|
return dir.replace(/[^/]$/, "$&/");
|
|
300
230
|
}
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/ignore.ts
|
|
303
231
|
function createIsIgnored(nuxt = tryUseNuxt()) {
|
|
304
232
|
return (pathname, stats) => isIgnored(pathname, stats, nuxt);
|
|
305
233
|
}
|
|
306
|
-
/**
|
|
307
|
-
* Return a filter function to filter an array of paths
|
|
308
|
-
*/
|
|
309
234
|
function isIgnored(pathname, _stats, nuxt = tryUseNuxt()) {
|
|
310
235
|
if (!nuxt) return false;
|
|
311
236
|
if (!nuxt._ignore) {
|
|
@@ -333,13 +258,6 @@ function resolveIgnorePatterns(relativePath) {
|
|
|
333
258
|
});
|
|
334
259
|
return ignorePatterns;
|
|
335
260
|
}
|
|
336
|
-
/**
|
|
337
|
-
* This function turns string containing groups '**\/*.{spec,test}.{js,ts}' into an array of strings.
|
|
338
|
-
* For example will '**\/*.{spec,test}.{js,ts}' be resolved to:
|
|
339
|
-
* ['**\/*.spec.js', '**\/*.spec.ts', '**\/*.test.js', '**\/*.test.ts']
|
|
340
|
-
* @param group string containing the group syntax
|
|
341
|
-
* @returns {string[]} array of strings without the group syntax
|
|
342
|
-
*/
|
|
343
261
|
function resolveGroupSyntax(group) {
|
|
344
262
|
let groups = [group];
|
|
345
263
|
while (groups.some((group) => group.includes("{"))) groups = groups.flatMap((group) => {
|
|
@@ -352,32 +270,15 @@ function resolveGroupSyntax(group) {
|
|
|
352
270
|
});
|
|
353
271
|
return groups;
|
|
354
272
|
}
|
|
355
|
-
//#endregion
|
|
356
|
-
//#region src/utils.ts
|
|
357
|
-
/** @since 3.9.0 */
|
|
358
273
|
function toArray(value) {
|
|
359
274
|
return Array.isArray(value) ? value : [value];
|
|
360
275
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Filter out items from an array in place. This function mutates the array.
|
|
363
|
-
* `predicate` get through the array from the end to the start for performance.
|
|
364
|
-
*
|
|
365
|
-
* This function should be faster than `Array.prototype.filter` on large arrays.
|
|
366
|
-
*/
|
|
367
276
|
function filterInPlace(array, predicate) {
|
|
368
277
|
for (let i = array.length; i--;) if (!predicate(array[i], i, array)) array.splice(i, 1);
|
|
369
278
|
return array;
|
|
370
279
|
}
|
|
371
280
|
const MODE_RE = /\.(server|client)(\.\w+)*$/;
|
|
372
281
|
const distDirURL = new URL(".", import.meta.url);
|
|
373
|
-
//#endregion
|
|
374
|
-
//#region src/resolve.ts
|
|
375
|
-
/**
|
|
376
|
-
* Resolve the full path to a file or a directory (based on the provided type), respecting Nuxt alias and extensions options.
|
|
377
|
-
*
|
|
378
|
-
* If a path cannot be resolved, normalized input will be returned unless the `fallbackToOriginal` option is set to `true`,
|
|
379
|
-
* in which case the original input path will be returned.
|
|
380
|
-
*/
|
|
381
282
|
async function resolvePath(path, opts = {}) {
|
|
382
283
|
const { type = "file" } = opts;
|
|
383
284
|
const res = await _resolvePathGranularly(path, {
|
|
@@ -387,9 +288,6 @@ async function resolvePath(path, opts = {}) {
|
|
|
387
288
|
if (res.type === type) return res.path;
|
|
388
289
|
return opts.fallbackToOriginal ? path : res.path;
|
|
389
290
|
}
|
|
390
|
-
/**
|
|
391
|
-
* Try to resolve first existing file in paths
|
|
392
|
-
*/
|
|
393
291
|
async function findPath(paths, opts, pathType = "file") {
|
|
394
292
|
for (const path of toArray(paths)) {
|
|
395
293
|
const res = await _resolvePathGranularly(path, {
|
|
@@ -401,16 +299,10 @@ async function findPath(paths, opts, pathType = "file") {
|
|
|
401
299
|
}
|
|
402
300
|
return null;
|
|
403
301
|
}
|
|
404
|
-
/**
|
|
405
|
-
* Resolve path aliases respecting Nuxt alias options
|
|
406
|
-
*/
|
|
407
302
|
function resolveAlias(path, alias) {
|
|
408
303
|
alias ||= tryUseNuxt()?.options.alias || {};
|
|
409
304
|
return resolveAlias$1(path, alias);
|
|
410
305
|
}
|
|
411
|
-
/**
|
|
412
|
-
* Create a relative resolver
|
|
413
|
-
*/
|
|
414
306
|
function createResolver(base) {
|
|
415
307
|
if (!base) throw new Error("`base` argument is missing for createResolver(base)!");
|
|
416
308
|
base = base.toString();
|
|
@@ -513,15 +405,6 @@ function existsInVFS(path, nuxt = tryUseNuxt()) {
|
|
|
513
405
|
if (path in nuxt.vfs) return true;
|
|
514
406
|
return (nuxt.apps.default?.templates ?? nuxt.options.build.templates).some((template) => template.dst === path);
|
|
515
407
|
}
|
|
516
|
-
/**
|
|
517
|
-
* Resolve absolute file paths in the provided directory with respect to `.nuxtignore` and return them sorted.
|
|
518
|
-
* @param path path to the directory to resolve files in
|
|
519
|
-
* @param pattern glob pattern or an array of glob patterns to match files
|
|
520
|
-
* @param opts options for globbing
|
|
521
|
-
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
|
|
522
|
-
* @param opts.ignore additional glob patterns to ignore
|
|
523
|
-
* @returns sorted array of absolute file paths
|
|
524
|
-
*/
|
|
525
408
|
async function resolveFiles(path, pattern, opts = {}) {
|
|
526
409
|
const files = [];
|
|
527
410
|
for (const p of await glob(pattern, {
|
|
@@ -532,8 +415,6 @@ async function resolveFiles(path, pattern, opts = {}) {
|
|
|
532
415
|
})) if (!isIgnored(p)) files.push(p);
|
|
533
416
|
return files.sort();
|
|
534
417
|
}
|
|
535
|
-
//#endregion
|
|
536
|
-
//#region src/internal/esm.ts
|
|
537
418
|
function directoryToURL(dir) {
|
|
538
419
|
return pathToFileURL(dir + "/");
|
|
539
420
|
}
|
|
@@ -565,25 +446,17 @@ function tryImportModule(id, opts) {
|
|
|
565
446
|
return importModule(id, opts).catch(() => void 0);
|
|
566
447
|
} catch {}
|
|
567
448
|
}
|
|
568
|
-
/**
|
|
569
|
-
* @deprecated Please use `importModule` instead.
|
|
570
|
-
*/
|
|
571
449
|
function requireModule(id, opts) {
|
|
572
450
|
const caller = getUserCaller();
|
|
573
451
|
warn(`[@nuxt/kit] \`requireModule\` is deprecated${caller ? ` (used at \`${resolveAlias(caller.source)}:${caller.line}:${caller.column}\`)` : ""}. Please use \`importModule\` instead.`);
|
|
574
452
|
const resolvedPath = resolveModule(id, opts);
|
|
575
453
|
return createJiti(import.meta.url, { interopDefault: opts?.interopDefault !== false })(pathToFileURL(resolvedPath).href);
|
|
576
454
|
}
|
|
577
|
-
/**
|
|
578
|
-
* @deprecated Please use `tryImportModule` instead.
|
|
579
|
-
*/
|
|
580
455
|
function tryRequireModule(id, opts) {
|
|
581
456
|
try {
|
|
582
457
|
return requireModule(id, opts);
|
|
583
458
|
} catch {}
|
|
584
459
|
}
|
|
585
|
-
//#endregion
|
|
586
|
-
//#region src/module/install.ts
|
|
587
460
|
const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
|
|
588
461
|
const ignoredConfigKeys = new Set([
|
|
589
462
|
"components",
|
|
@@ -592,10 +465,6 @@ const ignoredConfigKeys = new Set([
|
|
|
592
465
|
"devtools",
|
|
593
466
|
"telemetry"
|
|
594
467
|
]);
|
|
595
|
-
/**
|
|
596
|
-
* Installs a set of modules on a Nuxt instance.
|
|
597
|
-
* @internal
|
|
598
|
-
*/
|
|
599
468
|
async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useNuxt()) {
|
|
600
469
|
const localLayerModuleDirs = [];
|
|
601
470
|
for (const l of nuxt.options._layers) {
|
|
@@ -696,10 +565,6 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
|
|
|
696
565
|
}
|
|
697
566
|
delete nuxt._moduleOptionsFunctions;
|
|
698
567
|
}
|
|
699
|
-
/**
|
|
700
|
-
* Installs a module on a Nuxt instance.
|
|
701
|
-
* @deprecated Use module dependencies.
|
|
702
|
-
*/
|
|
703
568
|
async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
704
569
|
const { nuxtModule, buildTimeModuleMeta, resolvedModulePath } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
|
|
705
570
|
const localLayerModuleDirs = [];
|
|
@@ -884,35 +749,19 @@ async function callModule(nuxt, nuxtModule, moduleOptions = {}, options) {
|
|
|
884
749
|
entryPath
|
|
885
750
|
});
|
|
886
751
|
}
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region src/module/compatibility.ts
|
|
889
752
|
function resolveNuxtModuleEntryName(m) {
|
|
890
753
|
if (typeof m === "object" && !Array.isArray(m)) return m.name;
|
|
891
754
|
if (Array.isArray(m)) return resolveNuxtModuleEntryName(m[0]);
|
|
892
755
|
return m || false;
|
|
893
756
|
}
|
|
894
|
-
/**
|
|
895
|
-
* Check if a Nuxt module is installed by name.
|
|
896
|
-
*
|
|
897
|
-
* This will check both the installed modules and the modules to be installed. Note
|
|
898
|
-
* that it cannot detect if a module is _going to be_ installed programmatically by another module.
|
|
899
|
-
*/
|
|
900
757
|
function hasNuxtModule(moduleName, nuxt = useNuxt()) {
|
|
901
758
|
return nuxt.options._installedModules.some(({ meta }) => meta.name === moduleName) || nuxt.options.modules.some((m) => moduleName === resolveNuxtModuleEntryName(m));
|
|
902
759
|
}
|
|
903
|
-
/**
|
|
904
|
-
* Checks if a Nuxt module is compatible with a given semver version.
|
|
905
|
-
*/
|
|
906
760
|
async function hasNuxtModuleCompatibility(module, semverVersion, nuxt = useNuxt()) {
|
|
907
761
|
const version = await getNuxtModuleVersion(module, nuxt);
|
|
908
762
|
if (!version) return false;
|
|
909
763
|
return satisfies(normalizeSemanticVersion(version), semverVersion, { includePrerelease: true });
|
|
910
764
|
}
|
|
911
|
-
/**
|
|
912
|
-
* Get the version of a Nuxt module.
|
|
913
|
-
*
|
|
914
|
-
* Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
|
|
915
|
-
*/
|
|
916
765
|
async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
|
|
917
766
|
const moduleMeta = (typeof module === "string" ? { name: module } : await module.getMeta?.()) || {};
|
|
918
767
|
if (moduleMeta.version) return moduleMeta.version;
|
|
@@ -924,8 +773,6 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
|
|
|
924
773
|
}
|
|
925
774
|
return false;
|
|
926
775
|
}
|
|
927
|
-
//#endregion
|
|
928
|
-
//#region src/loader/config.ts
|
|
929
776
|
const merger = createDefu((obj, key, value) => {
|
|
930
777
|
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
931
778
|
obj[key] = obj[key].concat(value);
|
|
@@ -1038,15 +885,11 @@ async function withDefineNuxtConfig(fn) {
|
|
|
1038
885
|
if (!globalSelf[key].count) delete globalSelf[key];
|
|
1039
886
|
}
|
|
1040
887
|
}
|
|
1041
|
-
//#endregion
|
|
1042
|
-
//#region src/loader/schema.ts
|
|
1043
888
|
function extendNuxtSchema(def) {
|
|
1044
889
|
useNuxt().hook("schema:extend", (schemas) => {
|
|
1045
890
|
schemas.push(typeof def === "function" ? def() : def);
|
|
1046
891
|
});
|
|
1047
892
|
}
|
|
1048
|
-
//#endregion
|
|
1049
|
-
//#region src/loader/nuxt.ts
|
|
1050
893
|
async function loadNuxt(opts) {
|
|
1051
894
|
opts.cwd = resolve(opts.cwd || opts.rootDir || ".");
|
|
1052
895
|
opts.overrides ||= opts.config || {};
|
|
@@ -1067,14 +910,10 @@ async function buildNuxt(nuxt) {
|
|
|
1067
910
|
const { build } = await tryImportModule("nuxt-nightly", { url: rootURL }) || await importModule("nuxt", { url: rootURL });
|
|
1068
911
|
return runWithNuxtContext(nuxt, () => build(nuxt));
|
|
1069
912
|
}
|
|
1070
|
-
//#endregion
|
|
1071
|
-
//#region src/head.ts
|
|
1072
913
|
function setGlobalHead(head) {
|
|
1073
914
|
const nuxt = useNuxt();
|
|
1074
915
|
nuxt.options.app.head = defu(head, nuxt.options.app.head);
|
|
1075
916
|
}
|
|
1076
|
-
//#endregion
|
|
1077
|
-
//#region src/imports.ts
|
|
1078
917
|
function addImports(imports) {
|
|
1079
918
|
useNuxt().hook("imports:extend", (_imports) => {
|
|
1080
919
|
_imports.push(...toArray(imports));
|
|
@@ -1090,13 +929,7 @@ function addImportsSources(presets) {
|
|
|
1090
929
|
for (const preset of toArray(presets)) _presets.push(preset);
|
|
1091
930
|
});
|
|
1092
931
|
}
|
|
1093
|
-
//#endregion
|
|
1094
|
-
//#region src/nitro.ts
|
|
1095
932
|
const HANDLER_METHOD_RE = /\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/;
|
|
1096
|
-
/**
|
|
1097
|
-
* normalize handler object
|
|
1098
|
-
*
|
|
1099
|
-
*/
|
|
1100
933
|
function normalizeHandlerMethod(handler) {
|
|
1101
934
|
const [, method = void 0] = handler.handler.match(HANDLER_METHOD_RE) || [];
|
|
1102
935
|
return {
|
|
@@ -1105,31 +938,17 @@ function normalizeHandlerMethod(handler) {
|
|
|
1105
938
|
handler: normalize(handler.handler)
|
|
1106
939
|
};
|
|
1107
940
|
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Adds a nitro server handler
|
|
1110
|
-
*
|
|
1111
|
-
*/
|
|
1112
941
|
function addServerHandler(handler) {
|
|
1113
942
|
useNuxt().options.serverHandlers.push(normalizeHandlerMethod(handler));
|
|
1114
943
|
}
|
|
1115
|
-
/**
|
|
1116
|
-
* Adds a nitro server handler for development-only
|
|
1117
|
-
*
|
|
1118
|
-
*/
|
|
1119
944
|
function addDevServerHandler(handler) {
|
|
1120
945
|
useNuxt().options.devServerHandlers.push(handler);
|
|
1121
946
|
}
|
|
1122
|
-
/**
|
|
1123
|
-
* Adds a Nitro plugin
|
|
1124
|
-
*/
|
|
1125
947
|
function addServerPlugin(plugin) {
|
|
1126
948
|
const nuxt = useNuxt();
|
|
1127
949
|
nuxt.options.nitro.plugins ||= [];
|
|
1128
950
|
nuxt.options.nitro.plugins.push(normalize(plugin));
|
|
1129
951
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
* Adds routes to be prerendered
|
|
1132
|
-
*/
|
|
1133
952
|
function addPrerenderRoutes(routes) {
|
|
1134
953
|
const nuxt = useNuxt();
|
|
1135
954
|
routes = toArray(routes).filter(Boolean);
|
|
@@ -1138,28 +957,11 @@ function addPrerenderRoutes(routes) {
|
|
|
1138
957
|
for (const route of routes) ctx.routes.add(route);
|
|
1139
958
|
});
|
|
1140
959
|
}
|
|
1141
|
-
/**
|
|
1142
|
-
* Access to the Nitro instance
|
|
1143
|
-
*
|
|
1144
|
-
* **Note:** You can call `useNitro()` only after `ready` hook.
|
|
1145
|
-
*
|
|
1146
|
-
* **Note:** Changes to the Nitro instance configuration are not applied.
|
|
1147
|
-
* @example
|
|
1148
|
-
*
|
|
1149
|
-
* ```ts
|
|
1150
|
-
* nuxt.hook('ready', () => {
|
|
1151
|
-
* console.log(useNitro())
|
|
1152
|
-
* })
|
|
1153
|
-
* ```
|
|
1154
|
-
*/
|
|
1155
960
|
function useNitro() {
|
|
1156
961
|
const nuxt = useNuxt();
|
|
1157
962
|
if (!nuxt._nitro) throw new Error("Nitro is not initialized yet. You can call `useNitro()` only after `ready` hook.");
|
|
1158
963
|
return nuxt._nitro;
|
|
1159
964
|
}
|
|
1160
|
-
/**
|
|
1161
|
-
* Add server imports to be auto-imported by Nitro
|
|
1162
|
-
*/
|
|
1163
965
|
function addServerImports(imports) {
|
|
1164
966
|
const nuxt = useNuxt();
|
|
1165
967
|
const _imports = toArray(imports);
|
|
@@ -1169,9 +971,6 @@ function addServerImports(imports) {
|
|
|
1169
971
|
config.imports.imports.push(..._imports);
|
|
1170
972
|
});
|
|
1171
973
|
}
|
|
1172
|
-
/**
|
|
1173
|
-
* Add directories to be scanned for auto-imports by Nitro
|
|
1174
|
-
*/
|
|
1175
974
|
function addServerImportsDir(dirs, opts = {}) {
|
|
1176
975
|
const nuxt = useNuxt();
|
|
1177
976
|
const _dirs = toArray(dirs);
|
|
@@ -1181,23 +980,12 @@ function addServerImportsDir(dirs, opts = {}) {
|
|
|
1181
980
|
config.imports.dirs[opts.prepend ? "unshift" : "push"](..._dirs);
|
|
1182
981
|
});
|
|
1183
982
|
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Add directories to be scanned by Nitro. It will check for subdirectories,
|
|
1186
|
-
* which will be registered just like the `~~/server` folder is.
|
|
1187
|
-
*/
|
|
1188
983
|
function addServerScanDir(dirs, opts = {}) {
|
|
1189
984
|
useNuxt().hook("nitro:config", (config) => {
|
|
1190
985
|
config.scanDirs ||= [];
|
|
1191
986
|
for (const dir of toArray(dirs)) config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
|
|
1192
987
|
});
|
|
1193
988
|
}
|
|
1194
|
-
//#endregion
|
|
1195
|
-
//#region src/runtime-config.ts
|
|
1196
|
-
/**
|
|
1197
|
-
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
1198
|
-
*
|
|
1199
|
-
* This mirrors the runtime behavior of Nitro.
|
|
1200
|
-
*/
|
|
1201
989
|
function useRuntimeConfig() {
|
|
1202
990
|
const nuxt = useNuxt();
|
|
1203
991
|
return applyEnv(klona(nuxt.options.nitro.runtimeConfig), {
|
|
@@ -1206,9 +994,6 @@ function useRuntimeConfig() {
|
|
|
1206
994
|
envExpansion: nuxt.options.nitro.experimental?.envExpansion ?? !!process.env.NITRO_ENV_EXPANSION
|
|
1207
995
|
});
|
|
1208
996
|
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Update Nuxt runtime configuration.
|
|
1211
|
-
*/
|
|
1212
997
|
function updateRuntimeConfig(runtimeConfig) {
|
|
1213
998
|
const nuxt = useNuxt();
|
|
1214
999
|
Object.assign(nuxt.options.nitro.runtimeConfig, defu(runtimeConfig, nuxt.options.nitro.runtimeConfig));
|
|
@@ -1246,8 +1031,6 @@ function _expandFromEnv(value, env = process.env) {
|
|
|
1246
1031
|
return env[key] || match;
|
|
1247
1032
|
});
|
|
1248
1033
|
}
|
|
1249
|
-
//#endregion
|
|
1250
|
-
//#region src/build.ts
|
|
1251
1034
|
const extendWebpackCompatibleConfig = (builder) => (fn, options = {}) => {
|
|
1252
1035
|
const nuxt = useNuxt();
|
|
1253
1036
|
if (options.dev === false && nuxt.options.dev) return;
|
|
@@ -1263,23 +1046,8 @@ const extendWebpackCompatibleConfig = (builder) => (fn, options = {}) => {
|
|
|
1263
1046
|
}
|
|
1264
1047
|
});
|
|
1265
1048
|
};
|
|
1266
|
-
/**
|
|
1267
|
-
* Extend webpack config
|
|
1268
|
-
*
|
|
1269
|
-
* The fallback function might be called multiple times
|
|
1270
|
-
* when applying to both client and server builds.
|
|
1271
|
-
*/
|
|
1272
1049
|
const extendWebpackConfig = extendWebpackCompatibleConfig("webpack");
|
|
1273
|
-
/**
|
|
1274
|
-
* Extend rspack config
|
|
1275
|
-
*
|
|
1276
|
-
* The fallback function might be called multiple times
|
|
1277
|
-
* when applying to both client and server builds.
|
|
1278
|
-
*/
|
|
1279
1050
|
const extendRspackConfig = extendWebpackCompatibleConfig("rspack");
|
|
1280
|
-
/**
|
|
1281
|
-
* Extend Vite config
|
|
1282
|
-
*/
|
|
1283
1051
|
function extendViteConfig(fn, options = {}) {
|
|
1284
1052
|
const nuxt = useNuxt();
|
|
1285
1053
|
if (options.dev === false && nuxt.options.dev) return;
|
|
@@ -1290,9 +1058,6 @@ function extendViteConfig(fn, options = {}) {
|
|
|
1290
1058
|
}
|
|
1291
1059
|
return nuxt.hook("vite:extend", ({ config }) => fn(config));
|
|
1292
1060
|
}
|
|
1293
|
-
/**
|
|
1294
|
-
* Append webpack plugin to the config.
|
|
1295
|
-
*/
|
|
1296
1061
|
function addWebpackPlugin(pluginOrGetter, options) {
|
|
1297
1062
|
extendWebpackConfig(async (config) => {
|
|
1298
1063
|
const method = options?.prepend ? "unshift" : "push";
|
|
@@ -1301,9 +1066,6 @@ function addWebpackPlugin(pluginOrGetter, options) {
|
|
|
1301
1066
|
config.plugins[method](...toArray(plugin));
|
|
1302
1067
|
}, options);
|
|
1303
1068
|
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Append rspack plugin to the config.
|
|
1306
|
-
*/
|
|
1307
1069
|
function addRspackPlugin(pluginOrGetter, options) {
|
|
1308
1070
|
extendRspackConfig(async (config) => {
|
|
1309
1071
|
const method = options?.prepend ? "unshift" : "push";
|
|
@@ -1312,9 +1074,6 @@ function addRspackPlugin(pluginOrGetter, options) {
|
|
|
1312
1074
|
config.plugins[method](...toArray(plugin));
|
|
1313
1075
|
}, options);
|
|
1314
1076
|
}
|
|
1315
|
-
/**
|
|
1316
|
-
* Append Vite plugin to the config.
|
|
1317
|
-
*/
|
|
1318
1077
|
function addVitePlugin(pluginOrGetter, options = {}) {
|
|
1319
1078
|
const nuxt = useNuxt();
|
|
1320
1079
|
if (options.dev === false && nuxt.options.dev) return;
|
|
@@ -1355,11 +1114,6 @@ function addBuildPlugin(pluginFactory, options) {
|
|
|
1355
1114
|
if (pluginFactory.webpack) addWebpackPlugin(pluginFactory.webpack, options);
|
|
1356
1115
|
if (pluginFactory.rspack) addRspackPlugin(pluginFactory.rspack, options);
|
|
1357
1116
|
}
|
|
1358
|
-
//#endregion
|
|
1359
|
-
//#region src/components.ts
|
|
1360
|
-
/**
|
|
1361
|
-
* Register a directory to be scanned for components and imported only when used.
|
|
1362
|
-
*/
|
|
1363
1117
|
function addComponentsDir(dir, opts = {}) {
|
|
1364
1118
|
const nuxt = useNuxt();
|
|
1365
1119
|
nuxt.options.components ||= [];
|
|
@@ -1368,9 +1122,6 @@ function addComponentsDir(dir, opts = {}) {
|
|
|
1368
1122
|
dirs[opts.prepend ? "unshift" : "push"](dir);
|
|
1369
1123
|
});
|
|
1370
1124
|
}
|
|
1371
|
-
/**
|
|
1372
|
-
* This utility takes a file path or npm package that is scanned for named exports, which are get added automatically
|
|
1373
|
-
*/
|
|
1374
1125
|
function addComponentExports(opts) {
|
|
1375
1126
|
const nuxt = useNuxt();
|
|
1376
1127
|
const components = [];
|
|
@@ -1385,9 +1136,6 @@ function addComponentExports(opts) {
|
|
|
1385
1136
|
});
|
|
1386
1137
|
addComponents(components);
|
|
1387
1138
|
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Register a component by its name and filePath.
|
|
1390
|
-
*/
|
|
1391
1139
|
function addComponent(opts) {
|
|
1392
1140
|
addComponents([normalizeComponent(opts)]);
|
|
1393
1141
|
}
|
|
@@ -1431,11 +1179,6 @@ function normalizeComponent(opts) {
|
|
|
1431
1179
|
...opts
|
|
1432
1180
|
};
|
|
1433
1181
|
}
|
|
1434
|
-
//#endregion
|
|
1435
|
-
//#region src/template.ts
|
|
1436
|
-
/**
|
|
1437
|
-
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
|
|
1438
|
-
*/
|
|
1439
1182
|
function addTemplate(_template) {
|
|
1440
1183
|
const nuxt = useNuxt();
|
|
1441
1184
|
const template = normalizeTemplate(_template);
|
|
@@ -1451,23 +1194,12 @@ function addTemplate(_template) {
|
|
|
1451
1194
|
nuxt.options.build.templates.push(template);
|
|
1452
1195
|
return template;
|
|
1453
1196
|
}
|
|
1454
|
-
/**
|
|
1455
|
-
* Adds a virtual file that can be used within the Nuxt Nitro server build.
|
|
1456
|
-
*/
|
|
1457
1197
|
function addServerTemplate(template) {
|
|
1458
1198
|
const nuxt = useNuxt();
|
|
1459
1199
|
nuxt.options.nitro.virtual ||= {};
|
|
1460
1200
|
nuxt.options.nitro.virtual[template.filename] = template.getContents;
|
|
1461
1201
|
return template;
|
|
1462
1202
|
}
|
|
1463
|
-
/**
|
|
1464
|
-
* Renders given types during build to disk in the project `buildDir`
|
|
1465
|
-
* and register them as types.
|
|
1466
|
-
*
|
|
1467
|
-
* You can pass a second context object to specify in which context the type should be added.
|
|
1468
|
-
*
|
|
1469
|
-
* If no context object is passed, then it will only be added to the nuxt context.
|
|
1470
|
-
*/
|
|
1471
1203
|
function addTypeTemplate(_template, context) {
|
|
1472
1204
|
const nuxt = useNuxt();
|
|
1473
1205
|
const template = addTemplate(_template);
|
|
@@ -1491,9 +1223,6 @@ function addTypeTemplate(_template, context) {
|
|
|
1491
1223
|
});
|
|
1492
1224
|
return template;
|
|
1493
1225
|
}
|
|
1494
|
-
/**
|
|
1495
|
-
* Normalize a nuxt template object
|
|
1496
|
-
*/
|
|
1497
1226
|
function normalizeTemplate(template, buildDir) {
|
|
1498
1227
|
if (!template) throw new Error("Invalid template: " + JSON.stringify(template));
|
|
1499
1228
|
if (typeof template === "string") template = { src: template };
|
|
@@ -1511,11 +1240,6 @@ function normalizeTemplate(template, buildDir) {
|
|
|
1511
1240
|
template.dst ||= resolve(buildDir ?? useNuxt().options.buildDir, template.filename);
|
|
1512
1241
|
return template;
|
|
1513
1242
|
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Trigger rebuilding Nuxt templates
|
|
1516
|
-
*
|
|
1517
|
-
* You can pass a filter within the options to selectively regenerate a subset of templates.
|
|
1518
|
-
*/
|
|
1519
1243
|
async function updateTemplates(options) {
|
|
1520
1244
|
await tryUseNuxt()?.hooks.callHook("builder:generateApp", options);
|
|
1521
1245
|
}
|
|
@@ -1890,8 +1614,6 @@ function relativeWithDot(from, to) {
|
|
|
1890
1614
|
function withTrailingSlash$1(dir) {
|
|
1891
1615
|
return dir.replace(/[^/]$/, "$&/");
|
|
1892
1616
|
}
|
|
1893
|
-
//#endregion
|
|
1894
|
-
//#region src/layout.ts
|
|
1895
1617
|
const LAYOUT_RE = /["']/g;
|
|
1896
1618
|
function addLayout(template, name) {
|
|
1897
1619
|
const nuxt = useNuxt();
|
|
@@ -1915,8 +1637,6 @@ const strippedAtAliases = {
|
|
|
1915
1637
|
"@": "",
|
|
1916
1638
|
"@@": ""
|
|
1917
1639
|
};
|
|
1918
|
-
//#endregion
|
|
1919
|
-
//#region src/pages.ts
|
|
1920
1640
|
function extendPages(cb) {
|
|
1921
1641
|
useNuxt().hook("pages:extend", cb);
|
|
1922
1642
|
}
|
|
@@ -1943,11 +1663,6 @@ function addRouteMiddleware(input, options = {}) {
|
|
|
1943
1663
|
}
|
|
1944
1664
|
});
|
|
1945
1665
|
}
|
|
1946
|
-
//#endregion
|
|
1947
|
-
//#region src/plugin.ts
|
|
1948
|
-
/**
|
|
1949
|
-
* Normalize a nuxt plugin object
|
|
1950
|
-
*/
|
|
1951
1666
|
const pluginSymbol = Symbol.for("nuxt plugin");
|
|
1952
1667
|
function normalizePlugin(plugin) {
|
|
1953
1668
|
if (typeof plugin === "string") plugin = { src: plugin };
|
|
@@ -1981,14 +1696,10 @@ function addPlugin(_plugin, opts = {}) {
|
|
|
1981
1696
|
nuxt.options.plugins[opts.append ? "push" : "unshift"](plugin);
|
|
1982
1697
|
return plugin;
|
|
1983
1698
|
}
|
|
1984
|
-
/**
|
|
1985
|
-
* Adds a template and registers as a nuxt plugin.
|
|
1986
|
-
*/
|
|
1987
1699
|
function addPluginTemplate(plugin, opts = {}) {
|
|
1988
1700
|
return addPlugin(typeof plugin === "string" ? { src: plugin } : {
|
|
1989
1701
|
...plugin,
|
|
1990
1702
|
src: addTemplate(plugin).dst
|
|
1991
1703
|
}, opts);
|
|
1992
1704
|
}
|
|
1993
|
-
//#endregion
|
|
1994
1705
|
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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit-nightly",
|
|
3
|
-
"version": "4.4.3-
|
|
3
|
+
"version": "4.4.3-29621635.a4e85d14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -19,39 +19,39 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"c12": "^3.3.
|
|
22
|
+
"c12": "^3.3.4",
|
|
23
23
|
"consola": "^3.4.2",
|
|
24
|
-
"defu": "^6.1.
|
|
24
|
+
"defu": "^6.1.7",
|
|
25
25
|
"destr": "^2.0.5",
|
|
26
26
|
"errx": "^0.1.0",
|
|
27
27
|
"exsolve": "^1.0.8",
|
|
28
28
|
"ignore": "^7.0.5",
|
|
29
29
|
"jiti": "^2.6.1",
|
|
30
30
|
"klona": "^2.0.6",
|
|
31
|
-
"mlly": "^1.8.
|
|
31
|
+
"mlly": "^1.8.2",
|
|
32
32
|
"ohash": "^2.0.11",
|
|
33
33
|
"pathe": "^2.0.3",
|
|
34
34
|
"pkg-types": "^2.3.0",
|
|
35
|
-
"rc9": "^3.0.
|
|
35
|
+
"rc9": "^3.0.1",
|
|
36
36
|
"scule": "^1.3.0",
|
|
37
37
|
"semver": "^7.7.4",
|
|
38
|
-
"tinyglobby": "^0.2.
|
|
38
|
+
"tinyglobby": "^0.2.16",
|
|
39
39
|
"ufo": "^1.6.3",
|
|
40
40
|
"unctx": "^2.5.0",
|
|
41
41
|
"untyped": "^2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.3-
|
|
45
|
-
"@rspack/core": "1.7.
|
|
44
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.3-29621635.a4e85d14",
|
|
45
|
+
"@rspack/core": "1.7.11",
|
|
46
46
|
"@types/semver": "7.7.1",
|
|
47
|
-
"hookable": "6.1.
|
|
47
|
+
"hookable": "6.1.1",
|
|
48
48
|
"nitro": "3.0.260311-beta",
|
|
49
49
|
"nitropack": "2.13.1",
|
|
50
|
-
"obuild": "0.4.
|
|
51
|
-
"unimport": "6.
|
|
52
|
-
"vite": "7.3.
|
|
53
|
-
"vitest": "4.
|
|
54
|
-
"webpack": "5.
|
|
50
|
+
"obuild": "0.4.33",
|
|
51
|
+
"unimport": "6.1.1",
|
|
52
|
+
"vite": "7.3.2",
|
|
53
|
+
"vitest": "4.1.5",
|
|
54
|
+
"webpack": "5.106.2"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.12.0"
|