@nuxt/kit 3.15.2 → 3.15.4
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 +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +160 -122
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
1
2
|
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtMiddleware, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
2
3
|
import { LoadConfigOptions } from 'c12';
|
|
3
4
|
import { Import } from 'unimport';
|
|
@@ -188,7 +189,7 @@ declare function getNuxtVersion(nuxt?: Nuxt | any): string;
|
|
|
188
189
|
*/
|
|
189
190
|
declare function addComponentsDir(dir: ComponentsDir, opts?: {
|
|
190
191
|
prepend?: boolean;
|
|
191
|
-
}):
|
|
192
|
+
}): void;
|
|
192
193
|
type AddComponentOptions = {
|
|
193
194
|
name: string;
|
|
194
195
|
filePath: string;
|
|
@@ -198,7 +199,7 @@ type AddComponentOptions = {
|
|
|
198
199
|
*
|
|
199
200
|
* Requires Nuxt 2.13+
|
|
200
201
|
*/
|
|
201
|
-
declare function addComponent(opts: AddComponentOptions):
|
|
202
|
+
declare function addComponent(opts: AddComponentOptions): void;
|
|
202
203
|
|
|
203
204
|
/** Direct access to the Nuxt context - see https://github.com/unjs/unctx. */
|
|
204
205
|
declare const nuxtCtx: unctx.UseContext<Nuxt>;
|
|
@@ -226,10 +227,11 @@ declare function useNuxt(): Nuxt;
|
|
|
226
227
|
*/
|
|
227
228
|
declare function tryUseNuxt(): Nuxt | null;
|
|
228
229
|
|
|
230
|
+
declare function createIsIgnored(nuxt?: _nuxt_schema.Nuxt | null): (pathname: string, stats?: unknown) => boolean;
|
|
229
231
|
/**
|
|
230
232
|
* Return a filter function to filter an array of paths
|
|
231
233
|
*/
|
|
232
|
-
declare function isIgnored(pathname: string): boolean;
|
|
234
|
+
declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: _nuxt_schema.Nuxt | null): boolean;
|
|
233
235
|
declare function resolveIgnorePatterns(relativePath?: string): string[];
|
|
234
236
|
|
|
235
237
|
declare function addLayout(this: any, template: NuxtTemplate | string, name?: string): void;
|
|
@@ -449,4 +451,4 @@ declare const templateUtils: {
|
|
|
449
451
|
}) => string;
|
|
450
452
|
};
|
|
451
453
|
|
|
452
|
-
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, 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, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
454
|
+
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, 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, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
1
2
|
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtMiddleware, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
2
3
|
import { LoadConfigOptions } from 'c12';
|
|
3
4
|
import { Import } from 'unimport';
|
|
@@ -188,7 +189,7 @@ declare function getNuxtVersion(nuxt?: Nuxt | any): string;
|
|
|
188
189
|
*/
|
|
189
190
|
declare function addComponentsDir(dir: ComponentsDir, opts?: {
|
|
190
191
|
prepend?: boolean;
|
|
191
|
-
}):
|
|
192
|
+
}): void;
|
|
192
193
|
type AddComponentOptions = {
|
|
193
194
|
name: string;
|
|
194
195
|
filePath: string;
|
|
@@ -198,7 +199,7 @@ type AddComponentOptions = {
|
|
|
198
199
|
*
|
|
199
200
|
* Requires Nuxt 2.13+
|
|
200
201
|
*/
|
|
201
|
-
declare function addComponent(opts: AddComponentOptions):
|
|
202
|
+
declare function addComponent(opts: AddComponentOptions): void;
|
|
202
203
|
|
|
203
204
|
/** Direct access to the Nuxt context - see https://github.com/unjs/unctx. */
|
|
204
205
|
declare const nuxtCtx: unctx.UseContext<Nuxt>;
|
|
@@ -226,10 +227,11 @@ declare function useNuxt(): Nuxt;
|
|
|
226
227
|
*/
|
|
227
228
|
declare function tryUseNuxt(): Nuxt | null;
|
|
228
229
|
|
|
230
|
+
declare function createIsIgnored(nuxt?: _nuxt_schema.Nuxt | null): (pathname: string, stats?: unknown) => boolean;
|
|
229
231
|
/**
|
|
230
232
|
* Return a filter function to filter an array of paths
|
|
231
233
|
*/
|
|
232
|
-
declare function isIgnored(pathname: string): boolean;
|
|
234
|
+
declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: _nuxt_schema.Nuxt | null): boolean;
|
|
233
235
|
declare function resolveIgnorePatterns(relativePath?: string): string[];
|
|
234
236
|
|
|
235
237
|
declare function addLayout(this: any, template: NuxtTemplate | string, name?: string): void;
|
|
@@ -449,4 +451,4 @@ declare const templateUtils: {
|
|
|
449
451
|
}) => string;
|
|
450
452
|
};
|
|
451
453
|
|
|
452
|
-
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, 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, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
454
|
+
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, 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, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { globby } from 'globby';
|
|
|
16
16
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
17
17
|
import ignore from 'ignore';
|
|
18
18
|
import { loadConfig } from 'c12';
|
|
19
|
-
import {
|
|
19
|
+
import { isWindows } from 'std-env';
|
|
20
20
|
import process$1 from 'node:process';
|
|
21
21
|
import destr from 'destr';
|
|
22
22
|
import { snakeCase, kebabCase, pascalCase } from 'scule';
|
|
@@ -24,7 +24,6 @@ import { klona } from 'klona';
|
|
|
24
24
|
import { hash } from 'ohash';
|
|
25
25
|
import { gte } from 'semver';
|
|
26
26
|
import { isAbsolute as isAbsolute$1 } from 'node:path';
|
|
27
|
-
import { isWindows } from 'std-env';
|
|
28
27
|
|
|
29
28
|
const logger = consola;
|
|
30
29
|
function useLogger(tag, options = {}) {
|
|
@@ -52,11 +51,15 @@ const builderMap = {
|
|
|
52
51
|
"@nuxt/vite-builder": "vite",
|
|
53
52
|
"@nuxt/webpack-builder": "webpack"
|
|
54
53
|
};
|
|
54
|
+
function checkNuxtVersion(version, nuxt = useNuxt()) {
|
|
55
|
+
const nuxtVersion = getNuxtVersion(nuxt);
|
|
56
|
+
return satisfies(normalizeSemanticVersion(nuxtVersion), version, { includePrerelease: true });
|
|
57
|
+
}
|
|
55
58
|
async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
56
59
|
const issues = [];
|
|
57
60
|
if (constraints.nuxt) {
|
|
58
61
|
const nuxtVersion = getNuxtVersion(nuxt);
|
|
59
|
-
if (!
|
|
62
|
+
if (!checkNuxtVersion(constraints.nuxt, nuxt)) {
|
|
60
63
|
issues.push({
|
|
61
64
|
name: "nuxt",
|
|
62
65
|
message: `Nuxt version \`${constraints.nuxt}\` is required but currently using \`${nuxtVersion}\``
|
|
@@ -2205,8 +2208,10 @@ function nuxt2Shims(nuxt) {
|
|
|
2205
2208
|
});
|
|
2206
2209
|
}
|
|
2207
2210
|
|
|
2208
|
-
function
|
|
2209
|
-
|
|
2211
|
+
function createIsIgnored(nuxt = tryUseNuxt()) {
|
|
2212
|
+
return (pathname, stats) => isIgnored(pathname, stats, nuxt);
|
|
2213
|
+
}
|
|
2214
|
+
function isIgnored(pathname, _stats, nuxt = tryUseNuxt()) {
|
|
2210
2215
|
if (!nuxt) {
|
|
2211
2216
|
return false;
|
|
2212
2217
|
}
|
|
@@ -2261,68 +2266,20 @@ function resolveGroupSyntax(group) {
|
|
|
2261
2266
|
}
|
|
2262
2267
|
|
|
2263
2268
|
async function resolvePath(path, opts = {}) {
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
if (opts?.virtual && existsInVFS(path)) {
|
|
2268
|
-
return path;
|
|
2269
|
-
}
|
|
2270
|
-
if (existsSync(path) && !await isDirectory(path)) {
|
|
2271
|
-
return path;
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
const nuxt = tryUseNuxt();
|
|
2275
|
-
const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
|
|
2276
|
-
const extensions = opts.extensions || (nuxt ? nuxt.options.extensions : [".ts", ".mjs", ".cjs", ".json"]);
|
|
2277
|
-
const modulesDir = nuxt ? nuxt.options.modulesDir : [];
|
|
2278
|
-
path = resolveAlias(path);
|
|
2279
|
-
if (!isAbsolute(path)) {
|
|
2280
|
-
path = resolve(cwd, path);
|
|
2269
|
+
const res = await _resolvePathGranularly(path, opts);
|
|
2270
|
+
if (res.type === "file") {
|
|
2271
|
+
return res.path;
|
|
2281
2272
|
}
|
|
2282
|
-
|
|
2283
|
-
return path;
|
|
2284
|
-
}
|
|
2285
|
-
let _isDir = false;
|
|
2286
|
-
if (existsSync(path)) {
|
|
2287
|
-
_isDir = await isDirectory(path);
|
|
2288
|
-
if (!_isDir) {
|
|
2289
|
-
return path;
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
for (const ext of extensions) {
|
|
2293
|
-
const pathWithExt = path + ext;
|
|
2294
|
-
if (opts?.virtual && existsInVFS(pathWithExt, nuxt)) {
|
|
2295
|
-
return pathWithExt;
|
|
2296
|
-
}
|
|
2297
|
-
if (existsSync(pathWithExt)) {
|
|
2298
|
-
return pathWithExt;
|
|
2299
|
-
}
|
|
2300
|
-
const pathWithIndex = join(path, "index" + ext);
|
|
2301
|
-
if (opts?.virtual && existsInVFS(pathWithIndex, nuxt)) {
|
|
2302
|
-
return pathWithIndex;
|
|
2303
|
-
}
|
|
2304
|
-
if (_isDir && existsSync(pathWithIndex)) {
|
|
2305
|
-
return pathWithIndex;
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
const resolveModulePath = await resolvePath$1(_path, { url: [cwd, ...modulesDir] }).catch(() => null);
|
|
2309
|
-
if (resolveModulePath) {
|
|
2310
|
-
return resolveModulePath;
|
|
2311
|
-
}
|
|
2312
|
-
return opts.fallbackToOriginal ? _path : path;
|
|
2273
|
+
return opts.fallbackToOriginal ? path : res.path;
|
|
2313
2274
|
}
|
|
2314
2275
|
async function findPath(paths, opts, pathType = "file") {
|
|
2315
|
-
const nuxt = opts?.virtual ? tryUseNuxt() : undefined;
|
|
2316
2276
|
for (const path of toArray(paths)) {
|
|
2317
|
-
const
|
|
2318
|
-
if (
|
|
2319
|
-
|
|
2320
|
-
}
|
|
2321
|
-
if (await existsSensitive(
|
|
2322
|
-
|
|
2323
|
-
if (!pathType || pathType === "file" && !_isDir || pathType === "dir" && _isDir) {
|
|
2324
|
-
return rPath;
|
|
2325
|
-
}
|
|
2277
|
+
const res = await _resolvePathGranularly(path, opts);
|
|
2278
|
+
if (!res.type || pathType && res.type !== pathType) {
|
|
2279
|
+
continue;
|
|
2280
|
+
}
|
|
2281
|
+
if (res.virtual || await existsSensitive(res.path)) {
|
|
2282
|
+
return res.path;
|
|
2326
2283
|
}
|
|
2327
2284
|
}
|
|
2328
2285
|
return null;
|
|
@@ -2359,15 +2316,82 @@ async function resolveNuxtModule(base, paths) {
|
|
|
2359
2316
|
}
|
|
2360
2317
|
return resolved;
|
|
2361
2318
|
}
|
|
2362
|
-
async function
|
|
2363
|
-
if (
|
|
2364
|
-
return
|
|
2319
|
+
async function _resolvePathType(path, opts = {}, skipFs = false) {
|
|
2320
|
+
if (opts?.virtual && existsInVFS(path)) {
|
|
2321
|
+
return {
|
|
2322
|
+
path,
|
|
2323
|
+
type: "file",
|
|
2324
|
+
virtual: true
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
if (skipFs) {
|
|
2328
|
+
return;
|
|
2365
2329
|
}
|
|
2366
|
-
const
|
|
2367
|
-
|
|
2330
|
+
const fd = await promises.open(path, "r").catch(() => null);
|
|
2331
|
+
try {
|
|
2332
|
+
const stats = await fd?.stat();
|
|
2333
|
+
if (stats) {
|
|
2334
|
+
return {
|
|
2335
|
+
path,
|
|
2336
|
+
type: stats.isFile() ? "file" : "dir",
|
|
2337
|
+
virtual: false
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
} finally {
|
|
2341
|
+
fd?.close();
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
async function _resolvePathGranularly(path, opts = {}) {
|
|
2345
|
+
const _path = path;
|
|
2346
|
+
path = normalize(path);
|
|
2347
|
+
if (isAbsolute(path)) {
|
|
2348
|
+
const res2 = await _resolvePathType(path, opts);
|
|
2349
|
+
if (res2 && res2.type === "file") {
|
|
2350
|
+
return res2;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
const nuxt = tryUseNuxt();
|
|
2354
|
+
const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
|
|
2355
|
+
const extensions = opts.extensions || (nuxt ? nuxt.options.extensions : [".ts", ".mjs", ".cjs", ".json"]);
|
|
2356
|
+
const modulesDir = nuxt ? nuxt.options.modulesDir : [];
|
|
2357
|
+
path = resolveAlias(path);
|
|
2358
|
+
if (!isAbsolute(path)) {
|
|
2359
|
+
path = resolve(cwd, path);
|
|
2360
|
+
}
|
|
2361
|
+
const res = await _resolvePathType(path, opts);
|
|
2362
|
+
if (res && res.type === "file") {
|
|
2363
|
+
return res;
|
|
2364
|
+
}
|
|
2365
|
+
for (const ext of extensions) {
|
|
2366
|
+
const extPath = await _resolvePathType(path + ext, opts);
|
|
2367
|
+
if (extPath && extPath.type === "file") {
|
|
2368
|
+
return extPath;
|
|
2369
|
+
}
|
|
2370
|
+
const indexPath = await _resolvePathType(
|
|
2371
|
+
join(path, "index" + ext),
|
|
2372
|
+
opts,
|
|
2373
|
+
res?.type !== "dir"
|
|
2374
|
+
/* skip checking if parent is not a directory */
|
|
2375
|
+
);
|
|
2376
|
+
if (indexPath && indexPath.type === "file") {
|
|
2377
|
+
return indexPath;
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
const resolvedModulePath = await resolvePath$1(_path, { url: [cwd, ...modulesDir] }).catch(() => null);
|
|
2381
|
+
if (resolvedModulePath) {
|
|
2382
|
+
return {
|
|
2383
|
+
path: resolvedModulePath,
|
|
2384
|
+
type: "file",
|
|
2385
|
+
virtual: false
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
return {
|
|
2389
|
+
path
|
|
2390
|
+
};
|
|
2368
2391
|
}
|
|
2369
|
-
async function
|
|
2370
|
-
|
|
2392
|
+
async function existsSensitive(path) {
|
|
2393
|
+
const dirFiles = await promises.readdir(dirname(path)).catch(() => null);
|
|
2394
|
+
return dirFiles && dirFiles.includes(basename(path));
|
|
2371
2395
|
}
|
|
2372
2396
|
function existsInVFS(path, nuxt = tryUseNuxt()) {
|
|
2373
2397
|
if (!nuxt) {
|
|
@@ -2393,11 +2417,11 @@ async function resolveFiles(path, pattern, opts = {}) {
|
|
|
2393
2417
|
const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
|
|
2394
2418
|
async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
2395
2419
|
const { nuxtModule, buildTimeModuleMeta, resolvedModulePath } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
|
|
2396
|
-
const localLayerModuleDirs =
|
|
2420
|
+
const localLayerModuleDirs = [];
|
|
2397
2421
|
for (const l of nuxt.options._layers) {
|
|
2398
2422
|
const srcDir = l.config.srcDir || l.cwd;
|
|
2399
2423
|
if (!NODE_MODULES_RE.test(srcDir)) {
|
|
2400
|
-
localLayerModuleDirs.
|
|
2424
|
+
localLayerModuleDirs.push(resolve(srcDir, l.config?.dir?.modules || "modules").replace(/\/?$/, "/"));
|
|
2401
2425
|
}
|
|
2402
2426
|
}
|
|
2403
2427
|
const res = (isNuxt2() ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : await nuxtModule(inlineOptions, nuxt)) ?? {};
|
|
@@ -2409,8 +2433,8 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
|
2409
2433
|
const parsed = parseNodeModulePath(modulePath);
|
|
2410
2434
|
const moduleRoot = parsed.dir ? parsed.dir + parsed.name : modulePath;
|
|
2411
2435
|
nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleRoot));
|
|
2412
|
-
const directory = parsed.dir ? moduleRoot : getDirectory(modulePath);
|
|
2413
|
-
if (directory !== moduleToInstall && !localLayerModuleDirs.
|
|
2436
|
+
const directory = (parsed.dir ? moduleRoot : getDirectory(modulePath)).replace(/\/?$/, "/");
|
|
2437
|
+
if (directory !== moduleToInstall && !localLayerModuleDirs.some((dir) => directory.startsWith(dir))) {
|
|
2414
2438
|
nuxt.options.modulesDir.push(resolve(directory, "node_modules"));
|
|
2415
2439
|
}
|
|
2416
2440
|
}
|
|
@@ -2519,13 +2543,44 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
|
|
|
2519
2543
|
return false;
|
|
2520
2544
|
}
|
|
2521
2545
|
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
layerSchema[key] = NuxtConfigSchema[key];
|
|
2546
|
+
async function tryResolveModule(id, url = import.meta.url) {
|
|
2547
|
+
try {
|
|
2548
|
+
return await resolvePath$1(id, { url });
|
|
2549
|
+
} catch {
|
|
2527
2550
|
}
|
|
2528
2551
|
}
|
|
2552
|
+
function resolveModule(id, options) {
|
|
2553
|
+
return resolvePathSync(id, { url: options?.paths ?? [import.meta.url] });
|
|
2554
|
+
}
|
|
2555
|
+
async function importModule(id, opts) {
|
|
2556
|
+
const resolvedPath = await resolveModule(id, opts);
|
|
2557
|
+
return import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
|
|
2558
|
+
}
|
|
2559
|
+
function tryImportModule(id, opts) {
|
|
2560
|
+
try {
|
|
2561
|
+
return importModule(id, opts).catch(() => void 0);
|
|
2562
|
+
} catch {
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
2566
|
+
function requireModule(id, opts) {
|
|
2567
|
+
if (!warnings.has(id)) {
|
|
2568
|
+
console.warn("[@nuxt/kit] `requireModule` is deprecated. Please use `importModule` instead.");
|
|
2569
|
+
warnings.add(id);
|
|
2570
|
+
}
|
|
2571
|
+
const resolvedPath = resolveModule(id, opts);
|
|
2572
|
+
const jiti = createJiti(import.meta.url, {
|
|
2573
|
+
interopDefault: opts?.interopDefault !== false
|
|
2574
|
+
});
|
|
2575
|
+
return jiti(pathToFileURL(resolvedPath).href);
|
|
2576
|
+
}
|
|
2577
|
+
function tryRequireModule(id, opts) {
|
|
2578
|
+
try {
|
|
2579
|
+
return requireModule(id, opts);
|
|
2580
|
+
} catch {
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2529
2584
|
async function loadNuxtConfig(opts) {
|
|
2530
2585
|
opts.overrides = defu$1(opts.overrides, {
|
|
2531
2586
|
_extends: await globby("layers/*", {
|
|
@@ -2553,6 +2608,14 @@ async function loadNuxtConfig(opts) {
|
|
|
2553
2608
|
if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && nuxtConfig.future?.compatibilityVersion === 4 && existsSync(defaultBuildDir)) {
|
|
2554
2609
|
nuxtConfig.buildDir = join(nuxtConfig.rootDir, "node_modules/.cache/nuxt/.nuxt");
|
|
2555
2610
|
}
|
|
2611
|
+
const NuxtConfigSchema = await loadNuxtSchema(nuxtConfig.rootDir || cwd || process.cwd());
|
|
2612
|
+
const layerSchemaKeys = ["future", "srcDir", "rootDir", "serverDir", "dir"];
|
|
2613
|
+
const layerSchema = /* @__PURE__ */ Object.create(null);
|
|
2614
|
+
for (const key of layerSchemaKeys) {
|
|
2615
|
+
if (key in NuxtConfigSchema) {
|
|
2616
|
+
layerSchema[key] = NuxtConfigSchema[key];
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2556
2619
|
const _layers = [];
|
|
2557
2620
|
const processedLayers = /* @__PURE__ */ new Set();
|
|
2558
2621
|
for (const layer of layers) {
|
|
@@ -2580,6 +2643,15 @@ async function loadNuxtConfig(opts) {
|
|
|
2580
2643
|
}
|
|
2581
2644
|
return await applyDefaults(NuxtConfigSchema, nuxtConfig);
|
|
2582
2645
|
}
|
|
2646
|
+
async function loadNuxtSchema(cwd) {
|
|
2647
|
+
const paths = [cwd];
|
|
2648
|
+
const nuxtPath = await tryResolveModule("nuxt", cwd) ?? await tryResolveModule("nuxt-nightly", cwd);
|
|
2649
|
+
if (nuxtPath) {
|
|
2650
|
+
paths.unshift(nuxtPath);
|
|
2651
|
+
}
|
|
2652
|
+
const schemaPath = await tryResolveModule("@nuxt/schema", paths) ?? "@nuxt/schema";
|
|
2653
|
+
return await (isWindows ? import(pathToFileURL(schemaPath).href) : import(schemaPath)).then((r) => r.NuxtConfigSchema);
|
|
2654
|
+
}
|
|
2583
2655
|
|
|
2584
2656
|
function extendNuxtSchema(def) {
|
|
2585
2657
|
const nuxt = useNuxt();
|
|
@@ -2588,44 +2660,6 @@ function extendNuxtSchema(def) {
|
|
|
2588
2660
|
});
|
|
2589
2661
|
}
|
|
2590
2662
|
|
|
2591
|
-
async function tryResolveModule(id, url = import.meta.url) {
|
|
2592
|
-
try {
|
|
2593
|
-
return await resolvePath$1(id, { url });
|
|
2594
|
-
} catch {
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
function resolveModule(id, options) {
|
|
2598
|
-
return resolvePathSync(id, { url: options?.paths ?? [import.meta.url] });
|
|
2599
|
-
}
|
|
2600
|
-
async function importModule(id, opts) {
|
|
2601
|
-
const resolvedPath = await resolveModule(id, opts);
|
|
2602
|
-
return import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
|
|
2603
|
-
}
|
|
2604
|
-
function tryImportModule(id, opts) {
|
|
2605
|
-
try {
|
|
2606
|
-
return importModule(id, opts).catch(() => void 0);
|
|
2607
|
-
} catch {
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
2611
|
-
function requireModule(id, opts) {
|
|
2612
|
-
if (!warnings.has(id)) {
|
|
2613
|
-
console.warn("[@nuxt/kit] `requireModule` is deprecated. Please use `importModule` instead.");
|
|
2614
|
-
warnings.add(id);
|
|
2615
|
-
}
|
|
2616
|
-
const resolvedPath = resolveModule(id, opts);
|
|
2617
|
-
const jiti = createJiti(import.meta.url, {
|
|
2618
|
-
interopDefault: opts?.interopDefault !== false
|
|
2619
|
-
});
|
|
2620
|
-
return jiti(pathToFileURL(resolvedPath).href);
|
|
2621
|
-
}
|
|
2622
|
-
function tryRequireModule(id, opts) {
|
|
2623
|
-
try {
|
|
2624
|
-
return requireModule(id, opts);
|
|
2625
|
-
} catch {
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
2628
|
-
|
|
2629
2663
|
async function loadNuxt(opts) {
|
|
2630
2664
|
opts.cwd = opts.cwd || opts.rootDir;
|
|
2631
2665
|
opts.overrides ||= opts.config || {};
|
|
@@ -2897,18 +2931,22 @@ function addBuildPlugin(pluginFactory, options) {
|
|
|
2897
2931
|
}
|
|
2898
2932
|
}
|
|
2899
2933
|
|
|
2900
|
-
|
|
2934
|
+
function addComponentsDir(dir, opts = {}) {
|
|
2901
2935
|
const nuxt = useNuxt();
|
|
2902
|
-
|
|
2936
|
+
if (!checkNuxtVersion(">=2.13", nuxt)) {
|
|
2937
|
+
throw new Error(`\`addComponentsDir\` requires Nuxt 2.13 or higher.`);
|
|
2938
|
+
}
|
|
2903
2939
|
nuxt.options.components ||= [];
|
|
2904
2940
|
dir.priority ||= 0;
|
|
2905
2941
|
nuxt.hook("components:dirs", (dirs) => {
|
|
2906
2942
|
dirs[opts.prepend ? "unshift" : "push"](dir);
|
|
2907
2943
|
});
|
|
2908
2944
|
}
|
|
2909
|
-
|
|
2945
|
+
function addComponent(opts) {
|
|
2910
2946
|
const nuxt = useNuxt();
|
|
2911
|
-
|
|
2947
|
+
if (!checkNuxtVersion(">=2.13", nuxt)) {
|
|
2948
|
+
throw new Error(`\`addComponent\` requires Nuxt 2.13 or higher.`);
|
|
2949
|
+
}
|
|
2912
2950
|
nuxt.options.components ||= [];
|
|
2913
2951
|
if (!opts.mode) {
|
|
2914
2952
|
const [, mode = "all"] = opts.filePath.match(MODE_RE) || [];
|
|
@@ -3327,4 +3365,4 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
3327
3365
|
return addPlugin(normalizedPlugin, opts);
|
|
3328
3366
|
}
|
|
3329
3367
|
|
|
3330
|
-
export { addBuildPlugin, addComponent, 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, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
3368
|
+
export { addBuildPlugin, addComponent, 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, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, 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",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -34,30 +34,30 @@
|
|
|
34
34
|
"knitwork": "^1.2.0",
|
|
35
35
|
"mlly": "^1.7.4",
|
|
36
36
|
"ohash": "^1.1.4",
|
|
37
|
-
"pathe": "^2.0.
|
|
37
|
+
"pathe": "^2.0.2",
|
|
38
38
|
"pkg-types": "^1.3.1",
|
|
39
39
|
"scule": "^1.3.0",
|
|
40
40
|
"semver": "^7.6.3",
|
|
41
41
|
"std-env": "^3.8.0",
|
|
42
42
|
"ufo": "^1.5.4",
|
|
43
43
|
"unctx": "^2.4.1",
|
|
44
|
-
"unimport": "^
|
|
45
|
-
"untyped": "^1.5.2"
|
|
46
|
-
"@nuxt/schema": "3.15.2"
|
|
44
|
+
"unimport": "^4.0.0",
|
|
45
|
+
"untyped": "^1.5.2"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@rspack/core": "1.
|
|
48
|
+
"@rspack/core": "1.2.2",
|
|
50
49
|
"@types/lodash-es": "4.17.12",
|
|
51
50
|
"@types/semver": "7.5.8",
|
|
52
51
|
"lodash-es": "4.17.21",
|
|
53
52
|
"nitropack": "2.10.4",
|
|
54
53
|
"unbuild": "latest",
|
|
55
|
-
"vite": "6.0.
|
|
56
|
-
"vitest": "
|
|
57
|
-
"webpack": "5.96.1"
|
|
54
|
+
"vite": "6.0.11",
|
|
55
|
+
"vitest": "3.0.4",
|
|
56
|
+
"webpack": "5.96.1",
|
|
57
|
+
"@nuxt/schema": "3.15.4"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
|
-
"node": ">=18.
|
|
60
|
+
"node": ">=18.12.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"test:attw": "attw --pack"
|