@nuxt/kit 3.15.1 → 3.15.3
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 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.mjs +181 -131
- package/package.json +13 -12
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;
|
|
@@ -257,9 +259,6 @@ interface AddRouteMiddlewareOptions {
|
|
|
257
259
|
}
|
|
258
260
|
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
|
|
259
261
|
|
|
260
|
-
/**
|
|
261
|
-
* Normalize a nuxt plugin object
|
|
262
|
-
*/
|
|
263
262
|
declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
|
|
264
263
|
/**
|
|
265
264
|
* Registers a nuxt plugin and to the plugins array.
|
|
@@ -452,4 +451,4 @@ declare const templateUtils: {
|
|
|
452
451
|
}) => string;
|
|
453
452
|
};
|
|
454
453
|
|
|
455
|
-
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;
|
|
@@ -257,9 +259,6 @@ interface AddRouteMiddlewareOptions {
|
|
|
257
259
|
}
|
|
258
260
|
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
|
|
259
261
|
|
|
260
|
-
/**
|
|
261
|
-
* Normalize a nuxt plugin object
|
|
262
|
-
*/
|
|
263
262
|
declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
|
|
264
263
|
/**
|
|
265
264
|
* Registers a nuxt plugin and to the plugins array.
|
|
@@ -452,4 +451,4 @@ declare const templateUtils: {
|
|
|
452
451
|
}) => string;
|
|
453
452
|
};
|
|
454
453
|
|
|
455
|
-
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
|
@@ -23,6 +23,8 @@ import { snakeCase, kebabCase, pascalCase } from 'scule';
|
|
|
23
23
|
import { klona } from 'klona';
|
|
24
24
|
import { hash } from 'ohash';
|
|
25
25
|
import { gte } from 'semver';
|
|
26
|
+
import { isAbsolute as isAbsolute$1 } from 'node:path';
|
|
27
|
+
import { isWindows } from 'std-env';
|
|
26
28
|
|
|
27
29
|
const logger = consola;
|
|
28
30
|
function useLogger(tag, options = {}) {
|
|
@@ -50,11 +52,15 @@ const builderMap = {
|
|
|
50
52
|
"@nuxt/vite-builder": "vite",
|
|
51
53
|
"@nuxt/webpack-builder": "webpack"
|
|
52
54
|
};
|
|
55
|
+
function checkNuxtVersion(version, nuxt = useNuxt()) {
|
|
56
|
+
const nuxtVersion = getNuxtVersion(nuxt);
|
|
57
|
+
return satisfies(normalizeSemanticVersion(nuxtVersion), version, { includePrerelease: true });
|
|
58
|
+
}
|
|
53
59
|
async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
54
60
|
const issues = [];
|
|
55
61
|
if (constraints.nuxt) {
|
|
56
62
|
const nuxtVersion = getNuxtVersion(nuxt);
|
|
57
|
-
if (!
|
|
63
|
+
if (!checkNuxtVersion(constraints.nuxt, nuxt)) {
|
|
58
64
|
issues.push({
|
|
59
65
|
name: "nuxt",
|
|
60
66
|
message: `Nuxt version \`${constraints.nuxt}\` is required but currently using \`${nuxtVersion}\``
|
|
@@ -86,7 +92,7 @@ async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
|
86
92
|
message: `Not compatible with \`${nuxt.options.builder}\`.`
|
|
87
93
|
});
|
|
88
94
|
} else {
|
|
89
|
-
const builderVersion = await readPackageJSON(nuxt.options.builder, { url: nuxt.options.modulesDir }).then((r) => r.version).catch(() =>
|
|
95
|
+
const builderVersion = await readPackageJSON(nuxt.options.builder, { url: nuxt.options.modulesDir }).then((r) => r.version).catch(() => undefined);
|
|
90
96
|
if (builderVersion && !satisfies(normalizeSemanticVersion(builderVersion), constraint, { includePrerelease: true })) {
|
|
91
97
|
issues.push({
|
|
92
98
|
name: "builder",
|
|
@@ -140,7 +146,7 @@ var freeSelf = typeof self == 'object' && self && self.Object === Object && self
|
|
|
140
146
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|
141
147
|
|
|
142
148
|
/** Built-in value references. */
|
|
143
|
-
var Symbol = root.Symbol;
|
|
149
|
+
var Symbol$1 = root.Symbol;
|
|
144
150
|
|
|
145
151
|
/** Used for built-in method references. */
|
|
146
152
|
var objectProto$b = Object.prototype;
|
|
@@ -156,7 +162,7 @@ var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
|
|
|
156
162
|
var nativeObjectToString$1 = objectProto$b.toString;
|
|
157
163
|
|
|
158
164
|
/** Built-in value references. */
|
|
159
|
-
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
|
165
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
160
166
|
|
|
161
167
|
/**
|
|
162
168
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
@@ -211,7 +217,7 @@ var nullTag = '[object Null]',
|
|
|
211
217
|
undefinedTag = '[object Undefined]';
|
|
212
218
|
|
|
213
219
|
/** Built-in value references. */
|
|
214
|
-
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
220
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
215
221
|
|
|
216
222
|
/**
|
|
217
223
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
@@ -327,11 +333,8 @@ function arrayMap(array, iteratee) {
|
|
|
327
333
|
*/
|
|
328
334
|
var isArray = Array.isArray;
|
|
329
335
|
|
|
330
|
-
/** Used as references for various `Number` constants. */
|
|
331
|
-
var INFINITY = 1 / 0;
|
|
332
|
-
|
|
333
336
|
/** Used to convert symbols to primitives and strings. */
|
|
334
|
-
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
337
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
|
|
335
338
|
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
336
339
|
|
|
337
340
|
/**
|
|
@@ -355,7 +358,7 @@ function baseToString(value) {
|
|
|
355
358
|
return symbolToString ? symbolToString.call(value) : '';
|
|
356
359
|
}
|
|
357
360
|
var result = (value + '');
|
|
358
|
-
return (result == '0' && (1 / value) == -
|
|
361
|
+
return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
|
|
359
362
|
}
|
|
360
363
|
|
|
361
364
|
/**
|
|
@@ -2055,6 +2058,14 @@ function template(string, options, guard) {
|
|
|
2055
2058
|
function toArray(value) {
|
|
2056
2059
|
return Array.isArray(value) ? value : [value];
|
|
2057
2060
|
}
|
|
2061
|
+
function filterInPlace(array, predicate) {
|
|
2062
|
+
for (let i = array.length; i--; i >= 0) {
|
|
2063
|
+
if (!predicate(array[i], i, array)) {
|
|
2064
|
+
array.splice(i, 1);
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
return array;
|
|
2068
|
+
}
|
|
2058
2069
|
const MODE_RE = /\.(server|client)(\.\w+)*$/;
|
|
2059
2070
|
|
|
2060
2071
|
async function compileTemplate(template$1, ctx) {
|
|
@@ -2116,7 +2127,7 @@ function _defineNuxtModule(definition) {
|
|
|
2116
2127
|
}
|
|
2117
2128
|
const uniqueKey = module.meta.name || module.meta.configKey;
|
|
2118
2129
|
if (uniqueKey) {
|
|
2119
|
-
nuxt.options._requiredModules
|
|
2130
|
+
nuxt.options._requiredModules ||= {};
|
|
2120
2131
|
if (nuxt.options._requiredModules[uniqueKey]) {
|
|
2121
2132
|
return false;
|
|
2122
2133
|
}
|
|
@@ -2198,8 +2209,10 @@ function nuxt2Shims(nuxt) {
|
|
|
2198
2209
|
});
|
|
2199
2210
|
}
|
|
2200
2211
|
|
|
2201
|
-
function
|
|
2202
|
-
|
|
2212
|
+
function createIsIgnored(nuxt = tryUseNuxt()) {
|
|
2213
|
+
return (pathname, stats) => isIgnored(pathname, stats, nuxt);
|
|
2214
|
+
}
|
|
2215
|
+
function isIgnored(pathname, _stats, nuxt = tryUseNuxt()) {
|
|
2203
2216
|
if (!nuxt) {
|
|
2204
2217
|
return false;
|
|
2205
2218
|
}
|
|
@@ -2254,68 +2267,20 @@ function resolveGroupSyntax(group) {
|
|
|
2254
2267
|
}
|
|
2255
2268
|
|
|
2256
2269
|
async function resolvePath(path, opts = {}) {
|
|
2257
|
-
const
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
if (opts?.virtual && existsInVFS(path)) {
|
|
2261
|
-
return path;
|
|
2262
|
-
}
|
|
2263
|
-
if (existsSync(path) && !await isDirectory(path)) {
|
|
2264
|
-
return path;
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
const nuxt = tryUseNuxt();
|
|
2268
|
-
const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
|
|
2269
|
-
const extensions = opts.extensions || (nuxt ? nuxt.options.extensions : [".ts", ".mjs", ".cjs", ".json"]);
|
|
2270
|
-
const modulesDir = nuxt ? nuxt.options.modulesDir : [];
|
|
2271
|
-
path = resolveAlias(path);
|
|
2272
|
-
if (!isAbsolute(path)) {
|
|
2273
|
-
path = resolve(cwd, path);
|
|
2274
|
-
}
|
|
2275
|
-
if (opts?.virtual && existsInVFS(path, nuxt)) {
|
|
2276
|
-
return path;
|
|
2277
|
-
}
|
|
2278
|
-
let _isDir = false;
|
|
2279
|
-
if (existsSync(path)) {
|
|
2280
|
-
_isDir = await isDirectory(path);
|
|
2281
|
-
if (!_isDir) {
|
|
2282
|
-
return path;
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
for (const ext of extensions) {
|
|
2286
|
-
const pathWithExt = path + ext;
|
|
2287
|
-
if (opts?.virtual && existsInVFS(pathWithExt, nuxt)) {
|
|
2288
|
-
return pathWithExt;
|
|
2289
|
-
}
|
|
2290
|
-
if (existsSync(pathWithExt)) {
|
|
2291
|
-
return pathWithExt;
|
|
2292
|
-
}
|
|
2293
|
-
const pathWithIndex = join(path, "index" + ext);
|
|
2294
|
-
if (opts?.virtual && existsInVFS(pathWithIndex, nuxt)) {
|
|
2295
|
-
return pathWithIndex;
|
|
2296
|
-
}
|
|
2297
|
-
if (_isDir && existsSync(pathWithIndex)) {
|
|
2298
|
-
return pathWithIndex;
|
|
2299
|
-
}
|
|
2270
|
+
const res = await _resolvePathGranularly(path, opts);
|
|
2271
|
+
if (res.type === "file") {
|
|
2272
|
+
return res.path;
|
|
2300
2273
|
}
|
|
2301
|
-
|
|
2302
|
-
if (resolveModulePath) {
|
|
2303
|
-
return resolveModulePath;
|
|
2304
|
-
}
|
|
2305
|
-
return opts.fallbackToOriginal ? _path : path;
|
|
2274
|
+
return opts.fallbackToOriginal ? path : res.path;
|
|
2306
2275
|
}
|
|
2307
2276
|
async function findPath(paths, opts, pathType = "file") {
|
|
2308
|
-
const nuxt = opts?.virtual ? tryUseNuxt() : void 0;
|
|
2309
2277
|
for (const path of toArray(paths)) {
|
|
2310
|
-
const
|
|
2311
|
-
if (
|
|
2312
|
-
|
|
2313
|
-
}
|
|
2314
|
-
if (await existsSensitive(
|
|
2315
|
-
|
|
2316
|
-
if (!pathType || pathType === "file" && !_isDir || pathType === "dir" && _isDir) {
|
|
2317
|
-
return rPath;
|
|
2318
|
-
}
|
|
2278
|
+
const res = await _resolvePathGranularly(path, opts);
|
|
2279
|
+
if (!res.type || pathType && res.type !== pathType) {
|
|
2280
|
+
continue;
|
|
2281
|
+
}
|
|
2282
|
+
if (res.virtual || await existsSensitive(res.path)) {
|
|
2283
|
+
return res.path;
|
|
2319
2284
|
}
|
|
2320
2285
|
}
|
|
2321
2286
|
return null;
|
|
@@ -2352,15 +2317,82 @@ async function resolveNuxtModule(base, paths) {
|
|
|
2352
2317
|
}
|
|
2353
2318
|
return resolved;
|
|
2354
2319
|
}
|
|
2355
|
-
async function
|
|
2356
|
-
if (
|
|
2357
|
-
return
|
|
2320
|
+
async function _resolvePathType(path, opts = {}, skipFs = false) {
|
|
2321
|
+
if (opts?.virtual && existsInVFS(path)) {
|
|
2322
|
+
return {
|
|
2323
|
+
path,
|
|
2324
|
+
type: "file",
|
|
2325
|
+
virtual: true
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
if (skipFs) {
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
const fd = await promises.open(path, "r").catch(() => null);
|
|
2332
|
+
try {
|
|
2333
|
+
const stats = await fd?.stat();
|
|
2334
|
+
if (stats) {
|
|
2335
|
+
return {
|
|
2336
|
+
path,
|
|
2337
|
+
type: stats.isFile() ? "file" : "dir",
|
|
2338
|
+
virtual: false
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
} finally {
|
|
2342
|
+
fd?.close();
|
|
2358
2343
|
}
|
|
2359
|
-
const dirFiles = await promises.readdir(dirname(path));
|
|
2360
|
-
return dirFiles.includes(basename(path));
|
|
2361
2344
|
}
|
|
2362
|
-
async function
|
|
2363
|
-
|
|
2345
|
+
async function _resolvePathGranularly(path, opts = {}) {
|
|
2346
|
+
const _path = path;
|
|
2347
|
+
path = normalize(path);
|
|
2348
|
+
if (isAbsolute(path)) {
|
|
2349
|
+
const res2 = await _resolvePathType(path, opts);
|
|
2350
|
+
if (res2 && res2.type === "file") {
|
|
2351
|
+
return res2;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
const nuxt = tryUseNuxt();
|
|
2355
|
+
const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
|
|
2356
|
+
const extensions = opts.extensions || (nuxt ? nuxt.options.extensions : [".ts", ".mjs", ".cjs", ".json"]);
|
|
2357
|
+
const modulesDir = nuxt ? nuxt.options.modulesDir : [];
|
|
2358
|
+
path = resolveAlias(path);
|
|
2359
|
+
if (!isAbsolute(path)) {
|
|
2360
|
+
path = resolve(cwd, path);
|
|
2361
|
+
}
|
|
2362
|
+
const res = await _resolvePathType(path, opts);
|
|
2363
|
+
if (res && res.type === "file") {
|
|
2364
|
+
return res;
|
|
2365
|
+
}
|
|
2366
|
+
for (const ext of extensions) {
|
|
2367
|
+
const extPath = await _resolvePathType(path + ext, opts);
|
|
2368
|
+
if (extPath && extPath.type === "file") {
|
|
2369
|
+
return extPath;
|
|
2370
|
+
}
|
|
2371
|
+
const indexPath = await _resolvePathType(
|
|
2372
|
+
join(path, "index" + ext),
|
|
2373
|
+
opts,
|
|
2374
|
+
res?.type !== "dir"
|
|
2375
|
+
/* skip checking if parent is not a directory */
|
|
2376
|
+
);
|
|
2377
|
+
if (indexPath && indexPath.type === "file") {
|
|
2378
|
+
return indexPath;
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
const resolvedModulePath = await resolvePath$1(_path, { url: [cwd, ...modulesDir] }).catch(() => null);
|
|
2382
|
+
if (resolvedModulePath) {
|
|
2383
|
+
return {
|
|
2384
|
+
path: resolvedModulePath,
|
|
2385
|
+
type: "file",
|
|
2386
|
+
virtual: false
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
return {
|
|
2390
|
+
path
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
async function existsSensitive(path) {
|
|
2394
|
+
const dirFiles = await promises.readdir(dirname(path)).catch(() => null);
|
|
2395
|
+
return dirFiles && dirFiles.includes(basename(path));
|
|
2364
2396
|
}
|
|
2365
2397
|
function existsInVFS(path, nuxt = tryUseNuxt()) {
|
|
2366
2398
|
if (!nuxt) {
|
|
@@ -2386,11 +2418,11 @@ async function resolveFiles(path, pattern, opts = {}) {
|
|
|
2386
2418
|
const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
|
|
2387
2419
|
async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
2388
2420
|
const { nuxtModule, buildTimeModuleMeta, resolvedModulePath } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
|
|
2389
|
-
const localLayerModuleDirs =
|
|
2421
|
+
const localLayerModuleDirs = [];
|
|
2390
2422
|
for (const l of nuxt.options._layers) {
|
|
2391
2423
|
const srcDir = l.config.srcDir || l.cwd;
|
|
2392
2424
|
if (!NODE_MODULES_RE.test(srcDir)) {
|
|
2393
|
-
localLayerModuleDirs.
|
|
2425
|
+
localLayerModuleDirs.push(resolve(srcDir, l.config?.dir?.modules || "modules").replace(/\/?$/, "/"));
|
|
2394
2426
|
}
|
|
2395
2427
|
}
|
|
2396
2428
|
const res = (isNuxt2() ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : await nuxtModule(inlineOptions, nuxt)) ?? {};
|
|
@@ -2402,13 +2434,13 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
|
2402
2434
|
const parsed = parseNodeModulePath(modulePath);
|
|
2403
2435
|
const moduleRoot = parsed.dir ? parsed.dir + parsed.name : modulePath;
|
|
2404
2436
|
nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleRoot));
|
|
2405
|
-
const directory = parsed.dir ? moduleRoot : getDirectory(modulePath);
|
|
2406
|
-
if (directory !== moduleToInstall && !localLayerModuleDirs.
|
|
2437
|
+
const directory = (parsed.dir ? moduleRoot : getDirectory(modulePath)).replace(/\/?$/, "/");
|
|
2438
|
+
if (directory !== moduleToInstall && !localLayerModuleDirs.some((dir) => directory.startsWith(dir))) {
|
|
2407
2439
|
nuxt.options.modulesDir.push(resolve(directory, "node_modules"));
|
|
2408
2440
|
}
|
|
2409
2441
|
}
|
|
2410
|
-
nuxt.options._installedModules
|
|
2411
|
-
const entryPath = typeof moduleToInstall === "string" ? resolveAlias(moduleToInstall) :
|
|
2442
|
+
nuxt.options._installedModules ||= [];
|
|
2443
|
+
const entryPath = typeof moduleToInstall === "string" ? resolveAlias(moduleToInstall) : undefined;
|
|
2412
2444
|
if (typeof moduleToInstall === "string" && entryPath !== moduleToInstall) {
|
|
2413
2445
|
buildTimeModuleMeta.rawPath = moduleToInstall;
|
|
2414
2446
|
}
|
|
@@ -2442,27 +2474,22 @@ async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
|
|
|
2442
2474
|
paths.add(join(nuxtModule, "module"));
|
|
2443
2475
|
paths.add(nuxtModule);
|
|
2444
2476
|
for (const path of paths) {
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
|
|
2453
|
-
}
|
|
2454
|
-
break;
|
|
2455
|
-
} catch (error) {
|
|
2456
|
-
const code = error.code;
|
|
2457
|
-
if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNSUPPORTED_DIR_IMPORT" || code === "ENOTDIR") {
|
|
2458
|
-
continue;
|
|
2459
|
-
}
|
|
2460
|
-
logger.error(`Error while importing module \`${nuxtModule}\`: ${error}`);
|
|
2461
|
-
throw error;
|
|
2477
|
+
try {
|
|
2478
|
+
const src = isAbsolute(path) ? pathToFileURL(await resolvePath(path, { fallbackToOriginal: false, extensions: nuxt.options.extensions })).href : await resolve$1(path, { url: nuxt.options.modulesDir.map((m) => pathToFileURL(m.replace(/\/node_modules\/?$/, ""))), extensions: nuxt.options.extensions });
|
|
2479
|
+
nuxtModule = await jiti.import(src, { default: true });
|
|
2480
|
+
resolvedModulePath = fileURLToPath(new URL(src));
|
|
2481
|
+
const moduleMetadataPath = new URL("module.json", src);
|
|
2482
|
+
if (existsSync(moduleMetadataPath)) {
|
|
2483
|
+
buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
|
|
2462
2484
|
}
|
|
2463
|
-
}
|
|
2464
|
-
if (typeof nuxtModule !== "string") {
|
|
2465
2485
|
break;
|
|
2486
|
+
} catch (error) {
|
|
2487
|
+
const code = error.code;
|
|
2488
|
+
if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNSUPPORTED_DIR_IMPORT" || code === "ENOTDIR") {
|
|
2489
|
+
continue;
|
|
2490
|
+
}
|
|
2491
|
+
logger.error(`Error while importing module \`${nuxtModule}\`: ${error}`);
|
|
2492
|
+
throw error;
|
|
2466
2493
|
}
|
|
2467
2494
|
}
|
|
2468
2495
|
}
|
|
@@ -2554,7 +2581,7 @@ async function loadNuxtConfig(opts) {
|
|
|
2554
2581
|
const _layers = [];
|
|
2555
2582
|
const processedLayers = /* @__PURE__ */ new Set();
|
|
2556
2583
|
for (const layer of layers) {
|
|
2557
|
-
layer.config
|
|
2584
|
+
layer.config ||= {};
|
|
2558
2585
|
layer.config.rootDir = layer.config.rootDir ?? layer.cwd;
|
|
2559
2586
|
if (processedLayers.has(layer.config.rootDir)) {
|
|
2560
2587
|
continue;
|
|
@@ -2626,7 +2653,7 @@ function tryRequireModule(id, opts) {
|
|
|
2626
2653
|
|
|
2627
2654
|
async function loadNuxt(opts) {
|
|
2628
2655
|
opts.cwd = opts.cwd || opts.rootDir;
|
|
2629
|
-
opts.overrides
|
|
2656
|
+
opts.overrides ||= opts.config || {};
|
|
2630
2657
|
opts.overrides.dev = !!opts.dev;
|
|
2631
2658
|
const nearestNuxtPkg = await Promise.all(["nuxt-nightly", "nuxt3", "nuxt", "nuxt-edge"].map((pkg2) => resolvePackageJSON(pkg2, { url: opts.cwd }).catch(() => null))).then((r) => r.filter(Boolean).sort((a, b) => b.length - a.length)[0]);
|
|
2632
2659
|
if (!nearestNuxtPkg) {
|
|
@@ -2696,7 +2723,7 @@ function addImportsSources(presets) {
|
|
|
2696
2723
|
|
|
2697
2724
|
const HANDLER_METHOD_RE = /\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/;
|
|
2698
2725
|
function normalizeHandlerMethod(handler) {
|
|
2699
|
-
const [, method =
|
|
2726
|
+
const [, method = undefined] = handler.handler.match(HANDLER_METHOD_RE) || [];
|
|
2700
2727
|
return {
|
|
2701
2728
|
method,
|
|
2702
2729
|
...handler,
|
|
@@ -2711,7 +2738,7 @@ function addDevServerHandler(handler) {
|
|
|
2711
2738
|
}
|
|
2712
2739
|
function addServerPlugin(plugin) {
|
|
2713
2740
|
const nuxt = useNuxt();
|
|
2714
|
-
nuxt.options.nitro.plugins
|
|
2741
|
+
nuxt.options.nitro.plugins ||= [];
|
|
2715
2742
|
nuxt.options.nitro.plugins.push(normalize(plugin));
|
|
2716
2743
|
}
|
|
2717
2744
|
function addPrerenderRoutes(routes) {
|
|
@@ -2736,8 +2763,8 @@ function useNitro() {
|
|
|
2736
2763
|
function addServerImports(imports) {
|
|
2737
2764
|
const nuxt = useNuxt();
|
|
2738
2765
|
nuxt.hook("nitro:config", (config) => {
|
|
2739
|
-
config.imports
|
|
2740
|
-
config.imports.imports
|
|
2766
|
+
config.imports ||= {};
|
|
2767
|
+
config.imports.imports ||= [];
|
|
2741
2768
|
config.imports.imports.push(...imports);
|
|
2742
2769
|
});
|
|
2743
2770
|
}
|
|
@@ -2745,15 +2772,15 @@ function addServerImportsDir(dirs, opts = {}) {
|
|
|
2745
2772
|
const nuxt = useNuxt();
|
|
2746
2773
|
const _dirs = toArray(dirs);
|
|
2747
2774
|
nuxt.hook("nitro:config", (config) => {
|
|
2748
|
-
config.imports
|
|
2749
|
-
config.imports.dirs
|
|
2775
|
+
config.imports ||= {};
|
|
2776
|
+
config.imports.dirs ||= [];
|
|
2750
2777
|
config.imports.dirs[opts.prepend ? "unshift" : "push"](..._dirs);
|
|
2751
2778
|
});
|
|
2752
2779
|
}
|
|
2753
2780
|
function addServerScanDir(dirs, opts = {}) {
|
|
2754
2781
|
const nuxt = useNuxt();
|
|
2755
2782
|
nuxt.hook("nitro:config", (config) => {
|
|
2756
|
-
config.scanDirs
|
|
2783
|
+
config.scanDirs ||= [];
|
|
2757
2784
|
for (const dir of toArray(dirs)) {
|
|
2758
2785
|
config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
|
|
2759
2786
|
}
|
|
@@ -2793,7 +2820,7 @@ function applyEnv(obj, opts, parentKey = "") {
|
|
|
2793
2820
|
if (_isObject(envValue)) {
|
|
2794
2821
|
obj[key] = { ...obj[key], ...envValue };
|
|
2795
2822
|
applyEnv(obj[key], opts, subKey);
|
|
2796
|
-
} else if (envValue ===
|
|
2823
|
+
} else if (envValue === undefined) {
|
|
2797
2824
|
applyEnv(obj[key], opts, subKey);
|
|
2798
2825
|
} else {
|
|
2799
2826
|
obj[key] = envValue ?? obj[key];
|
|
@@ -2863,7 +2890,7 @@ function addWebpackPlugin(pluginOrGetter, options) {
|
|
|
2863
2890
|
extendWebpackConfig((config) => {
|
|
2864
2891
|
const method = options?.prepend ? "unshift" : "push";
|
|
2865
2892
|
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
2866
|
-
config.plugins
|
|
2893
|
+
config.plugins ||= [];
|
|
2867
2894
|
config.plugins[method](...toArray(plugin));
|
|
2868
2895
|
}, options);
|
|
2869
2896
|
}
|
|
@@ -2871,7 +2898,7 @@ function addRspackPlugin(pluginOrGetter, options) {
|
|
|
2871
2898
|
extendRspackConfig((config) => {
|
|
2872
2899
|
const method = options?.prepend ? "unshift" : "push";
|
|
2873
2900
|
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
2874
|
-
config.plugins
|
|
2901
|
+
config.plugins ||= [];
|
|
2875
2902
|
config.plugins[method](...toArray(plugin));
|
|
2876
2903
|
}, options);
|
|
2877
2904
|
}
|
|
@@ -2879,7 +2906,7 @@ function addVitePlugin(pluginOrGetter, options) {
|
|
|
2879
2906
|
extendViteConfig((config) => {
|
|
2880
2907
|
const method = options?.prepend ? "unshift" : "push";
|
|
2881
2908
|
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
2882
|
-
config.plugins
|
|
2909
|
+
config.plugins ||= [];
|
|
2883
2910
|
config.plugins[method](...toArray(plugin));
|
|
2884
2911
|
}, options);
|
|
2885
2912
|
}
|
|
@@ -2895,19 +2922,23 @@ function addBuildPlugin(pluginFactory, options) {
|
|
|
2895
2922
|
}
|
|
2896
2923
|
}
|
|
2897
2924
|
|
|
2898
|
-
|
|
2925
|
+
function addComponentsDir(dir, opts = {}) {
|
|
2899
2926
|
const nuxt = useNuxt();
|
|
2900
|
-
|
|
2901
|
-
|
|
2927
|
+
if (!checkNuxtVersion(">=2.13", nuxt)) {
|
|
2928
|
+
throw new Error(`\`addComponentsDir\` requires Nuxt 2.13 or higher.`);
|
|
2929
|
+
}
|
|
2930
|
+
nuxt.options.components ||= [];
|
|
2902
2931
|
dir.priority ||= 0;
|
|
2903
2932
|
nuxt.hook("components:dirs", (dirs) => {
|
|
2904
2933
|
dirs[opts.prepend ? "unshift" : "push"](dir);
|
|
2905
2934
|
});
|
|
2906
2935
|
}
|
|
2907
|
-
|
|
2936
|
+
function addComponent(opts) {
|
|
2908
2937
|
const nuxt = useNuxt();
|
|
2909
|
-
|
|
2910
|
-
|
|
2938
|
+
if (!checkNuxtVersion(">=2.13", nuxt)) {
|
|
2939
|
+
throw new Error(`\`addComponent\` requires Nuxt 2.13 or higher.`);
|
|
2940
|
+
}
|
|
2941
|
+
nuxt.options.components ||= [];
|
|
2911
2942
|
if (!opts.mode) {
|
|
2912
2943
|
const [, mode = "all"] = opts.filePath.match(MODE_RE) || [];
|
|
2913
2944
|
opts.mode = mode;
|
|
@@ -2949,7 +2980,7 @@ async function addComponent(opts) {
|
|
|
2949
2980
|
function addTemplate(_template) {
|
|
2950
2981
|
const nuxt = useNuxt();
|
|
2951
2982
|
const template = normalizeTemplate(_template);
|
|
2952
|
-
nuxt.options.build.templates
|
|
2983
|
+
filterInPlace(nuxt.options.build.templates, (p) => normalizeTemplate(p).dst !== template.dst);
|
|
2953
2984
|
nuxt.options.build.templates.push(template);
|
|
2954
2985
|
return template;
|
|
2955
2986
|
}
|
|
@@ -3097,9 +3128,9 @@ async function _generateTypes(nuxt) {
|
|
|
3097
3128
|
});
|
|
3098
3129
|
const aliases = nuxt.options.alias;
|
|
3099
3130
|
const basePath = tsConfig.compilerOptions.baseUrl ? resolve(nuxt.options.buildDir, tsConfig.compilerOptions.baseUrl) : nuxt.options.buildDir;
|
|
3100
|
-
tsConfig.compilerOptions
|
|
3101
|
-
tsConfig.compilerOptions.paths
|
|
3102
|
-
tsConfig.include
|
|
3131
|
+
tsConfig.compilerOptions ||= {};
|
|
3132
|
+
tsConfig.compilerOptions.paths ||= {};
|
|
3133
|
+
tsConfig.include ||= [];
|
|
3103
3134
|
for (const alias in aliases) {
|
|
3104
3135
|
if (excludedAlias.some((re) => re.test(alias))) {
|
|
3105
3136
|
continue;
|
|
@@ -3154,6 +3185,7 @@ async function _generateTypes(nuxt) {
|
|
|
3154
3185
|
return relativeWithDot(nuxt.options.buildDir, stats?.isFile() ? path.replace(EXTENSION_RE, "") : path);
|
|
3155
3186
|
}));
|
|
3156
3187
|
}
|
|
3188
|
+
sortTsPaths(tsConfig.compilerOptions.paths);
|
|
3157
3189
|
tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
|
|
3158
3190
|
tsConfig.exclude = [...new Set(tsConfig.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
|
|
3159
3191
|
const declaration = [
|
|
@@ -3186,6 +3218,15 @@ async function writeTypes(nuxt) {
|
|
|
3186
3218
|
nuxt.hook("builder:prepared", writeFile);
|
|
3187
3219
|
await writeFile();
|
|
3188
3220
|
}
|
|
3221
|
+
function sortTsPaths(paths) {
|
|
3222
|
+
for (const pathKey in paths) {
|
|
3223
|
+
if (pathKey.startsWith("#build")) {
|
|
3224
|
+
const pathValue = paths[pathKey];
|
|
3225
|
+
delete paths[pathKey];
|
|
3226
|
+
paths[pathKey] = pathValue;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3189
3230
|
function renderAttrs(obj) {
|
|
3190
3231
|
const attrs = [];
|
|
3191
3232
|
for (const key in obj) {
|
|
@@ -3244,9 +3285,7 @@ function extendPages(cb) {
|
|
|
3244
3285
|
function extendRouteRules(route, rule, options = {}) {
|
|
3245
3286
|
const nuxt = useNuxt();
|
|
3246
3287
|
for (const opts of [nuxt.options, nuxt.options.nitro]) {
|
|
3247
|
-
|
|
3248
|
-
opts.routeRules = {};
|
|
3249
|
-
}
|
|
3288
|
+
opts.routeRules ||= {};
|
|
3250
3289
|
opts.routeRules[route] = options.override ? defu(rule, opts.routeRules[route]) : defu(opts.routeRules[route], rule);
|
|
3251
3290
|
}
|
|
3252
3291
|
}
|
|
@@ -3275,16 +3314,26 @@ function addRouteMiddleware(input, options = {}) {
|
|
|
3275
3314
|
});
|
|
3276
3315
|
}
|
|
3277
3316
|
|
|
3317
|
+
const pluginSymbol = Symbol.for("nuxt plugin");
|
|
3278
3318
|
function normalizePlugin(plugin) {
|
|
3279
3319
|
if (typeof plugin === "string") {
|
|
3280
3320
|
plugin = { src: plugin };
|
|
3281
3321
|
} else {
|
|
3282
3322
|
plugin = { ...plugin };
|
|
3283
3323
|
}
|
|
3324
|
+
if (pluginSymbol in plugin) {
|
|
3325
|
+
return plugin;
|
|
3326
|
+
}
|
|
3284
3327
|
if (!plugin.src) {
|
|
3285
3328
|
throw new Error("Invalid plugin. src option is required: " + JSON.stringify(plugin));
|
|
3286
3329
|
}
|
|
3287
3330
|
plugin.src = normalize(resolveAlias(plugin.src));
|
|
3331
|
+
if (!existsSync(plugin.src) && isAbsolute$1(plugin.src)) {
|
|
3332
|
+
try {
|
|
3333
|
+
plugin.src = resolvePathSync(isWindows ? pathToFileURL(plugin.src).href : plugin.src, { extensions: tryUseNuxt()?.options.extensions });
|
|
3334
|
+
} catch {
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3288
3337
|
if (plugin.ssr) {
|
|
3289
3338
|
plugin.mode = "server";
|
|
3290
3339
|
}
|
|
@@ -3292,12 +3341,13 @@ function normalizePlugin(plugin) {
|
|
|
3292
3341
|
const [, mode = "all"] = plugin.src.match(MODE_RE) || [];
|
|
3293
3342
|
plugin.mode = mode;
|
|
3294
3343
|
}
|
|
3344
|
+
plugin[pluginSymbol] = true;
|
|
3295
3345
|
return plugin;
|
|
3296
3346
|
}
|
|
3297
3347
|
function addPlugin(_plugin, opts = {}) {
|
|
3298
3348
|
const nuxt = useNuxt();
|
|
3299
3349
|
const plugin = normalizePlugin(_plugin);
|
|
3300
|
-
nuxt.options.plugins
|
|
3350
|
+
filterInPlace(nuxt.options.plugins, (p) => normalizePlugin(p).src !== plugin.src);
|
|
3301
3351
|
nuxt.options.plugins[opts.append ? "push" : "unshift"](plugin);
|
|
3302
3352
|
return plugin;
|
|
3303
3353
|
}
|
|
@@ -3306,4 +3356,4 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
3306
3356
|
return addPlugin(normalizedPlugin, opts);
|
|
3307
3357
|
}
|
|
3308
3358
|
|
|
3309
|
-
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 };
|
|
3359
|
+
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.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -24,39 +24,40 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"c12": "^2.0.1",
|
|
27
|
-
"consola": "^3.
|
|
27
|
+
"consola": "^3.4.0",
|
|
28
28
|
"defu": "^6.1.4",
|
|
29
29
|
"destr": "^2.0.3",
|
|
30
30
|
"globby": "^14.0.2",
|
|
31
|
-
"ignore": "^7.0.
|
|
31
|
+
"ignore": "^7.0.3",
|
|
32
32
|
"jiti": "^2.4.2",
|
|
33
33
|
"klona": "^2.0.6",
|
|
34
34
|
"knitwork": "^1.2.0",
|
|
35
|
-
"mlly": "^1.7.
|
|
35
|
+
"mlly": "^1.7.4",
|
|
36
36
|
"ohash": "^1.1.4",
|
|
37
|
-
"pathe": "^2.0.
|
|
38
|
-
"pkg-types": "^1.3.
|
|
37
|
+
"pathe": "^2.0.2",
|
|
38
|
+
"pkg-types": "^1.3.1",
|
|
39
39
|
"scule": "^1.3.0",
|
|
40
40
|
"semver": "^7.6.3",
|
|
41
|
+
"std-env": "^3.8.0",
|
|
41
42
|
"ufo": "^1.5.4",
|
|
42
43
|
"unctx": "^2.4.1",
|
|
43
|
-
"unimport": "^
|
|
44
|
+
"unimport": "^4.0.0",
|
|
44
45
|
"untyped": "^1.5.2",
|
|
45
|
-
"@nuxt/schema": "3.15.
|
|
46
|
+
"@nuxt/schema": "3.15.3"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@rspack/core": "1.
|
|
49
|
+
"@rspack/core": "1.2.2",
|
|
49
50
|
"@types/lodash-es": "4.17.12",
|
|
50
51
|
"@types/semver": "7.5.8",
|
|
51
52
|
"lodash-es": "4.17.21",
|
|
52
53
|
"nitropack": "2.10.4",
|
|
53
54
|
"unbuild": "latest",
|
|
54
|
-
"vite": "6.0.
|
|
55
|
-
"vitest": "
|
|
55
|
+
"vite": "6.0.11",
|
|
56
|
+
"vitest": "3.0.4",
|
|
56
57
|
"webpack": "5.96.1"
|
|
57
58
|
},
|
|
58
59
|
"engines": {
|
|
59
|
-
"node": ">=18.
|
|
60
|
+
"node": ">=18.12.0"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"test:attw": "attw --pack"
|