@nuxt/kit 3.8.2 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -6,6 +6,7 @@ import { UserConfig, Plugin } from 'vite';
6
6
  import * as unctx_index from 'unctx/index';
7
7
  import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
8
8
  import * as consola_dist_core from 'consola/dist/core';
9
+ import { ConsolaOptions } from 'consola';
9
10
  import { genSafeVariableName } from 'knitwork';
10
11
 
11
12
  /**
@@ -137,11 +138,11 @@ declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nux
137
138
  /**
138
139
  * Check if current nuxt instance is version 2 legacy
139
140
  */
140
- declare function isNuxt2(nuxt?: Nuxt): any;
141
+ declare function isNuxt2(nuxt?: Nuxt): boolean;
141
142
  /**
142
143
  * Check if current nuxt instance is version 3
143
144
  */
144
- declare function isNuxt3(nuxt?: Nuxt): any;
145
+ declare function isNuxt3(nuxt?: Nuxt): boolean;
145
146
  /**
146
147
  * Get nuxt version
147
148
  */
@@ -152,7 +153,9 @@ declare function getNuxtVersion(nuxt?: Nuxt | any): any;
152
153
  *
153
154
  * Requires Nuxt 2.13+
154
155
  */
155
- declare function addComponentsDir(dir: ComponentsDir): Promise<void>;
156
+ declare function addComponentsDir(dir: ComponentsDir, opts?: {
157
+ prepend?: boolean;
158
+ }): Promise<void>;
156
159
  type AddComponentOptions = {
157
160
  name: string;
158
161
  filePath: string;
@@ -322,6 +325,13 @@ declare function addServerImports(imports: Import[]): void;
322
325
  declare function addServerImportsDir(dirs: string | string[], opts?: {
323
326
  prepend?: boolean;
324
327
  }): void;
328
+ /**
329
+ * Add directories to be scanned by Nitro. It will check for subdirectories,
330
+ * which will be registered just like the `~/server` folder is.
331
+ */
332
+ declare function addServerScanDir(dirs: string | string[], opts?: {
333
+ prepend?: boolean;
334
+ }): void;
325
335
 
326
336
  /**
327
337
  * Renders given template using lodash template during build into the project buildDir
@@ -347,7 +357,7 @@ declare function updateTemplates(options?: {
347
357
  declare function writeTypes(nuxt: Nuxt): Promise<void>;
348
358
 
349
359
  declare const logger: consola_dist_core.ConsolaInstance;
350
- declare function useLogger(tag?: string): consola_dist_core.ConsolaInstance;
360
+ declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): consola_dist_core.ConsolaInstance;
351
361
 
352
362
  /** @deprecated Do not use CJS utils */
353
363
  interface ResolveModuleOptions {
@@ -390,4 +400,4 @@ declare const templateUtils: {
390
400
  }) => string;
391
401
  };
392
402
 
393
- export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
403
+ export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { UserConfig, Plugin } from 'vite';
6
6
  import * as unctx_index from 'unctx/index';
7
7
  import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
8
8
  import * as consola_dist_core from 'consola/dist/core';
9
+ import { ConsolaOptions } from 'consola';
9
10
  import { genSafeVariableName } from 'knitwork';
10
11
 
11
12
  /**
@@ -137,11 +138,11 @@ declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nux
137
138
  /**
138
139
  * Check if current nuxt instance is version 2 legacy
139
140
  */
140
- declare function isNuxt2(nuxt?: Nuxt): any;
141
+ declare function isNuxt2(nuxt?: Nuxt): boolean;
141
142
  /**
142
143
  * Check if current nuxt instance is version 3
143
144
  */
144
- declare function isNuxt3(nuxt?: Nuxt): any;
145
+ declare function isNuxt3(nuxt?: Nuxt): boolean;
145
146
  /**
146
147
  * Get nuxt version
147
148
  */
@@ -152,7 +153,9 @@ declare function getNuxtVersion(nuxt?: Nuxt | any): any;
152
153
  *
153
154
  * Requires Nuxt 2.13+
154
155
  */
155
- declare function addComponentsDir(dir: ComponentsDir): Promise<void>;
156
+ declare function addComponentsDir(dir: ComponentsDir, opts?: {
157
+ prepend?: boolean;
158
+ }): Promise<void>;
156
159
  type AddComponentOptions = {
157
160
  name: string;
158
161
  filePath: string;
@@ -322,6 +325,13 @@ declare function addServerImports(imports: Import[]): void;
322
325
  declare function addServerImportsDir(dirs: string | string[], opts?: {
323
326
  prepend?: boolean;
324
327
  }): void;
328
+ /**
329
+ * Add directories to be scanned by Nitro. It will check for subdirectories,
330
+ * which will be registered just like the `~/server` folder is.
331
+ */
332
+ declare function addServerScanDir(dirs: string | string[], opts?: {
333
+ prepend?: boolean;
334
+ }): void;
325
335
 
326
336
  /**
327
337
  * Renders given template using lodash template during build into the project buildDir
@@ -347,7 +357,7 @@ declare function updateTemplates(options?: {
347
357
  declare function writeTypes(nuxt: Nuxt): Promise<void>;
348
358
 
349
359
  declare const logger: consola_dist_core.ConsolaInstance;
350
- declare function useLogger(tag?: string): consola_dist_core.ConsolaInstance;
360
+ declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): consola_dist_core.ConsolaInstance;
351
361
 
352
362
  /** @deprecated Do not use CJS utils */
353
363
  interface ResolveModuleOptions {
@@ -390,4 +400,4 @@ declare const templateUtils: {
390
400
  }) => string;
391
401
  };
392
402
 
393
- export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
403
+ export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
package/dist/index.mjs CHANGED
@@ -21,8 +21,8 @@ import hash from 'hash-sum';
21
21
  import { withTrailingSlash } from 'ufo';
22
22
 
23
23
  const logger = consola;
24
- function useLogger(tag) {
25
- return tag ? logger.withTag(tag) : logger;
24
+ function useLogger(tag, options = {}) {
25
+ return tag ? logger.create(options).withTag(tag) : logger;
26
26
  }
27
27
 
28
28
  const nuxtCtx = getContext("nuxt");
@@ -82,10 +82,12 @@ async function hasNuxtCompatibility(constraints, nuxt = useNuxt()) {
82
82
  return !issues.length;
83
83
  }
84
84
  function isNuxt2(nuxt = useNuxt()) {
85
- return getNuxtVersion(nuxt).startsWith("2.");
85
+ const version = getNuxtVersion(nuxt);
86
+ return version[0] === "2" && version[1] === ".";
86
87
  }
87
88
  function isNuxt3(nuxt = useNuxt()) {
88
- return getNuxtVersion(nuxt).startsWith("3.");
89
+ const version = getNuxtVersion(nuxt);
90
+ return version[0] === "3" && version[1] === ".";
89
91
  }
90
92
  function getNuxtVersion(nuxt = useNuxt()) {
91
93
  const version = (nuxt?._version || nuxt?.version || nuxt?.constructor?.version || "").replace(/^v/g, "");
@@ -98,20 +100,14 @@ function getNuxtVersion(nuxt = useNuxt()) {
98
100
  /** Detect free variable `global` from Node.js. */
99
101
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
100
102
 
101
- const freeGlobal$1 = freeGlobal;
102
-
103
103
  /** Detect free variable `self`. */
104
104
  var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
105
105
 
106
106
  /** Used as a reference to the global object. */
107
- var root = freeGlobal$1 || freeSelf || Function('return this')();
108
-
109
- const root$1 = root;
107
+ var root = freeGlobal || freeSelf || Function('return this')();
110
108
 
111
109
  /** Built-in value references. */
112
- var Symbol = root$1.Symbol;
113
-
114
- const Symbol$1 = Symbol;
110
+ var Symbol = root.Symbol;
115
111
 
116
112
  /** Used for built-in method references. */
117
113
  var objectProto$b = Object.prototype;
@@ -127,7 +123,7 @@ var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
127
123
  var nativeObjectToString$1 = objectProto$b.toString;
128
124
 
129
125
  /** Built-in value references. */
130
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
126
+ var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
131
127
 
132
128
  /**
133
129
  * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
@@ -182,7 +178,7 @@ var nullTag = '[object Null]',
182
178
  undefinedTag = '[object Undefined]';
183
179
 
184
180
  /** Built-in value references. */
185
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
181
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
186
182
 
187
183
  /**
188
184
  * The base implementation of `getTag` without fallbacks for buggy environments.
@@ -298,13 +294,11 @@ function arrayMap(array, iteratee) {
298
294
  */
299
295
  var isArray = Array.isArray;
300
296
 
301
- const isArray$1 = isArray;
302
-
303
297
  /** Used as references for various `Number` constants. */
304
298
  var INFINITY = 1 / 0;
305
299
 
306
300
  /** Used to convert symbols to primitives and strings. */
307
- var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
301
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
308
302
  symbolToString = symbolProto ? symbolProto.toString : undefined;
309
303
 
310
304
  /**
@@ -320,7 +314,7 @@ function baseToString(value) {
320
314
  if (typeof value == 'string') {
321
315
  return value;
322
316
  }
323
- if (isArray$1(value)) {
317
+ if (isArray(value)) {
324
318
  // Recursively convert values (susceptible to call stack limits).
325
319
  return arrayMap(value, baseToString) + '';
326
320
  }
@@ -415,13 +409,11 @@ function isFunction(value) {
415
409
  }
416
410
 
417
411
  /** Used to detect overreaching core-js shims. */
418
- var coreJsData = root$1['__core-js_shared__'];
419
-
420
- const coreJsData$1 = coreJsData;
412
+ var coreJsData = root['__core-js_shared__'];
421
413
 
422
414
  /** Used to detect methods masquerading as native. */
423
415
  var maskSrcKey = (function() {
424
- var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
416
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
425
417
  return uid ? ('Symbol(src)_1.' + uid) : '';
426
418
  }());
427
419
 
@@ -616,8 +608,6 @@ var defineProperty = (function() {
616
608
  } catch (e) {}
617
609
  }());
618
610
 
619
- const defineProperty$1 = defineProperty;
620
-
621
611
  /**
622
612
  * The base implementation of `setToString` without support for hot loop shorting.
623
613
  *
@@ -626,8 +616,8 @@ const defineProperty$1 = defineProperty;
626
616
  * @param {Function} string The `toString` result.
627
617
  * @returns {Function} Returns `func`.
628
618
  */
629
- var baseSetToString = !defineProperty$1 ? identity : function(func, string) {
630
- return defineProperty$1(func, 'toString', {
619
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
620
+ return defineProperty(func, 'toString', {
631
621
  'configurable': true,
632
622
  'enumerable': false,
633
623
  'value': constant(string),
@@ -647,8 +637,6 @@ const baseSetToString$1 = baseSetToString;
647
637
  */
648
638
  var setToString = shortOut(baseSetToString$1);
649
639
 
650
- const setToString$1 = setToString;
651
-
652
640
  /** Used as references for various `Number` constants. */
653
641
  var MAX_SAFE_INTEGER$1 = 9007199254740991;
654
642
 
@@ -683,8 +671,8 @@ function isIndex(value, length) {
683
671
  * @param {*} value The value to assign.
684
672
  */
685
673
  function baseAssignValue(object, key, value) {
686
- if (key == '__proto__' && defineProperty$1) {
687
- defineProperty$1(object, key, {
674
+ if (key == '__proto__' && defineProperty) {
675
+ defineProperty(object, key, {
688
676
  'configurable': true,
689
677
  'enumerable': true,
690
678
  'value': value,
@@ -833,7 +821,7 @@ function overRest(func, start, transform) {
833
821
  * @returns {Function} Returns the new function.
834
822
  */
835
823
  function baseRest(func, start) {
836
- return setToString$1(overRest(func, start, identity), func + '');
824
+ return setToString(overRest(func, start, identity), func + '');
837
825
  }
838
826
 
839
827
  /** Used as references for various `Number` constants. */
@@ -1038,8 +1026,6 @@ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsAr
1038
1026
  !propertyIsEnumerable.call(value, 'callee');
1039
1027
  };
1040
1028
 
1041
- const isArguments$1 = isArguments;
1042
-
1043
1029
  /**
1044
1030
  * This method returns `false`.
1045
1031
  *
@@ -1067,7 +1053,7 @@ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !modu
1067
1053
  var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1068
1054
 
1069
1055
  /** Built-in value references. */
1070
- var Buffer = moduleExports$1 ? root$1.Buffer : undefined;
1056
+ var Buffer = moduleExports$1 ? root.Buffer : undefined;
1071
1057
 
1072
1058
  /* Built-in method references for those with the same name as other `lodash` methods. */
1073
1059
  var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
@@ -1091,8 +1077,6 @@ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1091
1077
  */
1092
1078
  var isBuffer = nativeIsBuffer || stubFalse;
1093
1079
 
1094
- const isBuffer$1 = isBuffer;
1095
-
1096
1080
  /** `Object#toString` result references. */
1097
1081
  var argsTag = '[object Arguments]',
1098
1082
  arrayTag = '[object Array]',
@@ -1171,7 +1155,7 @@ var freeModule = freeExports && typeof module == 'object' && module && !module.n
1171
1155
  var moduleExports = freeModule && freeModule.exports === freeExports;
1172
1156
 
1173
1157
  /** Detect free variable `process` from Node.js. */
1174
- var freeProcess = moduleExports && freeGlobal$1.process;
1158
+ var freeProcess = moduleExports && freeGlobal.process;
1175
1159
 
1176
1160
  /** Used to access faster Node.js helpers. */
1177
1161
  var nodeUtil = (function() {
@@ -1188,10 +1172,8 @@ var nodeUtil = (function() {
1188
1172
  } catch (e) {}
1189
1173
  }());
1190
1174
 
1191
- const nodeUtil$1 = nodeUtil;
1192
-
1193
1175
  /* Node.js helper references. */
1194
- var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
1176
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1195
1177
 
1196
1178
  /**
1197
1179
  * Checks if `value` is classified as a typed array.
@@ -1212,8 +1194,6 @@ var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
1212
1194
  */
1213
1195
  var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1214
1196
 
1215
- const isTypedArray$1 = isTypedArray;
1216
-
1217
1197
  /** Used for built-in method references. */
1218
1198
  var objectProto$5 = Object.prototype;
1219
1199
 
@@ -1229,10 +1209,10 @@ var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
1229
1209
  * @returns {Array} Returns the array of property names.
1230
1210
  */
1231
1211
  function arrayLikeKeys(value, inherited) {
1232
- var isArr = isArray$1(value),
1233
- isArg = !isArr && isArguments$1(value),
1234
- isBuff = !isArr && !isArg && isBuffer$1(value),
1235
- isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
1212
+ var isArr = isArray(value),
1213
+ isArg = !isArr && isArguments(value),
1214
+ isBuff = !isArr && !isArg && isBuffer(value),
1215
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1236
1216
  skipIndexes = isArr || isArg || isBuff || isType,
1237
1217
  result = skipIndexes ? baseTimes(value.length, String) : [],
1238
1218
  length = result.length;
@@ -1272,8 +1252,6 @@ function overArg(func, transform) {
1272
1252
  /* Built-in method references for those with the same name as other `lodash` methods. */
1273
1253
  var nativeKeys = overArg(Object.keys, Object);
1274
1254
 
1275
- const nativeKeys$1 = nativeKeys;
1276
-
1277
1255
  /** Used for built-in method references. */
1278
1256
  var objectProto$4 = Object.prototype;
1279
1257
 
@@ -1289,7 +1267,7 @@ var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
1289
1267
  */
1290
1268
  function baseKeys(object) {
1291
1269
  if (!isPrototype(object)) {
1292
- return nativeKeys$1(object);
1270
+ return nativeKeys(object);
1293
1271
  }
1294
1272
  var result = [];
1295
1273
  for (var key in Object(object)) {
@@ -1439,8 +1417,6 @@ var assignInWith = createAssigner(function(object, source, srcIndex, customizer)
1439
1417
  copyObject(source, keysIn(source), object, customizer);
1440
1418
  });
1441
1419
 
1442
- const extendWith = assignInWith;
1443
-
1444
1420
  /**
1445
1421
  * Converts `value` to a string. An empty string is returned for `null`
1446
1422
  * and `undefined` values. The sign of `-0` is preserved.
@@ -1469,8 +1445,6 @@ function toString(value) {
1469
1445
  /** Built-in value references. */
1470
1446
  var getPrototype = overArg(Object.getPrototypeOf, Object);
1471
1447
 
1472
- const getPrototype$1 = getPrototype;
1473
-
1474
1448
  /** `Object#toString` result references. */
1475
1449
  var objectTag = '[object Object]';
1476
1450
 
@@ -1519,7 +1493,7 @@ function isPlainObject(value) {
1519
1493
  if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
1520
1494
  return false;
1521
1495
  }
1522
- var proto = getPrototype$1(value);
1496
+ var proto = getPrototype(value);
1523
1497
  if (proto === null) {
1524
1498
  return true;
1525
1499
  }
@@ -1589,8 +1563,6 @@ var attempt = baseRest(function(func, args) {
1589
1563
  }
1590
1564
  });
1591
1565
 
1592
- const attempt$1 = attempt;
1593
-
1594
1566
  /**
1595
1567
  * The base implementation of `_.propertyOf` without support for deep paths.
1596
1568
  *
@@ -1802,8 +1774,6 @@ var templateSettings = {
1802
1774
  }
1803
1775
  };
1804
1776
 
1805
- const templateSettings$1 = templateSettings;
1806
-
1807
1777
  /** Error message constants. */
1808
1778
  var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
1809
1779
 
@@ -1950,15 +1920,15 @@ function template(string, options, guard) {
1950
1920
  // Based on John Resig's `tmpl` implementation
1951
1921
  // (http://ejohn.org/blog/javascript-micro-templating/)
1952
1922
  // and Laura Doktorova's doT.js (https://github.com/olado/doT).
1953
- var settings = templateSettings$1.imports._.templateSettings || templateSettings$1;
1923
+ var settings = templateSettings.imports._.templateSettings || templateSettings;
1954
1924
 
1955
1925
  if (guard && isIterateeCall(string, options, guard)) {
1956
1926
  options = undefined;
1957
1927
  }
1958
1928
  string = toString(string);
1959
- options = extendWith({}, options, settings, customDefaultsAssignIn);
1929
+ options = assignInWith({}, options, settings, customDefaultsAssignIn);
1960
1930
 
1961
- var imports = extendWith({}, options.imports, settings.imports, customDefaultsAssignIn),
1931
+ var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
1962
1932
  importsKeys = keys(imports),
1963
1933
  importsValues = baseValues(imports, importsKeys);
1964
1934
 
@@ -2049,7 +2019,7 @@ function template(string, options, guard) {
2049
2019
  source +
2050
2020
  'return __p\n}';
2051
2021
 
2052
- var result = attempt$1(function() {
2022
+ var result = attempt(function() {
2053
2023
  return Function(importsKeys, sourceURL + 'return ' + source)
2054
2024
  .apply(undefined, importsValues);
2055
2025
  });
@@ -2063,6 +2033,10 @@ function template(string, options, guard) {
2063
2033
  return result;
2064
2034
  }
2065
2035
 
2036
+ function toArray(value) {
2037
+ return Array.isArray(value) ? value : [value];
2038
+ }
2039
+
2066
2040
  async function compileTemplate(template$1, ctx) {
2067
2041
  const data = { ...ctx, options: template$1.options };
2068
2042
  if (template$1.src) {
@@ -2081,10 +2055,7 @@ async function compileTemplate(template$1, ctx) {
2081
2055
  }
2082
2056
  const serialize = (data) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, (r) => JSON.parse(r).replace(/^{(.*)}$/, "$1"));
2083
2057
  const importSources = (sources, { lazy = false } = {}) => {
2084
- if (!Array.isArray(sources)) {
2085
- sources = [sources];
2086
- }
2087
- return sources.map((src) => {
2058
+ return toArray(sources).map((src) => {
2088
2059
  if (lazy) {
2089
2060
  return `const ${genSafeVariableName(src)} = ${genDynamicImport(src, { comment: `webpackChunkName: ${JSON.stringify(src)}` })}`;
2090
2061
  }
@@ -2297,7 +2268,7 @@ function isIgnored(pathname) {
2297
2268
  const cwds = nuxt.options._layers?.map((layer2) => layer2.cwd).sort((a, b) => b.length - a.length);
2298
2269
  const layer = cwds?.find((cwd) => pathname.startsWith(cwd));
2299
2270
  const relativePath = relative(layer ?? nuxt.options.rootDir, pathname);
2300
- if (relativePath.startsWith("..")) {
2271
+ if (relativePath[0] === "." && relativePath[1] === ".") {
2301
2272
  return false;
2302
2273
  }
2303
2274
  return !!(relativePath && nuxt._ignore.ignores(relativePath));
@@ -2316,7 +2287,7 @@ function resolveIgnorePatterns(relativePath) {
2316
2287
  }
2317
2288
  }
2318
2289
  if (relativePath) {
2319
- return nuxt._ignorePatterns.map((p) => p.startsWith("*") || p.startsWith("!*") ? p : relative(relativePath, resolve(nuxt.options.rootDir, p)));
2290
+ return nuxt._ignorePatterns.map((p) => p[0] === "*" || p[0] === "!" && p[1] === "*" ? p : relative(relativePath, resolve(nuxt.options.rootDir, p)));
2320
2291
  }
2321
2292
  return nuxt._ignorePatterns;
2322
2293
  }
@@ -2373,10 +2344,7 @@ async function resolvePath(path, opts = {}) {
2373
2344
  return path;
2374
2345
  }
2375
2346
  async function findPath(paths, opts, pathType = "file") {
2376
- if (!Array.isArray(paths)) {
2377
- paths = [paths];
2378
- }
2379
- for (const path of paths) {
2347
+ for (const path of toArray(paths)) {
2380
2348
  const rPath = await resolvePath(path, opts);
2381
2349
  if (await existsSensitive(rPath)) {
2382
2350
  const _isDir = await isDirectory(rPath);
@@ -2434,8 +2402,16 @@ async function resolveFiles(path, pattern, opts = {}) {
2434
2402
  return files.map((p) => resolve(path, p)).filter((p) => !isIgnored(p)).sort();
2435
2403
  }
2436
2404
 
2405
+ const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
2437
2406
  async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2438
2407
  const { nuxtModule, buildTimeModuleMeta } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
2408
+ const localLayerModuleDirs = /* @__PURE__ */ new Set();
2409
+ for (const l of nuxt.options._layers) {
2410
+ const srcDir = l.config.srcDir || l.cwd;
2411
+ if (!NODE_MODULES_RE.test(srcDir)) {
2412
+ localLayerModuleDirs.add(resolve(srcDir, l.config?.dir?.modules || "modules"));
2413
+ }
2414
+ }
2439
2415
  const res = (isNuxt2() ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : await nuxtModule(inlineOptions, nuxt)) ?? {};
2440
2416
  if (res === false) {
2441
2417
  return;
@@ -2443,8 +2419,8 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2443
2419
  if (typeof moduleToInstall === "string") {
2444
2420
  nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleToInstall));
2445
2421
  const directory = getDirectory(moduleToInstall);
2446
- if (directory !== moduleToInstall) {
2447
- nuxt.options.modulesDir.push(getDirectory(moduleToInstall));
2422
+ if (directory !== moduleToInstall && !localLayerModuleDirs.has(directory)) {
2423
+ nuxt.options.modulesDir.push(directory);
2448
2424
  }
2449
2425
  }
2450
2426
  nuxt.options._installedModules = nuxt.options._installedModules || [];
@@ -2467,16 +2443,26 @@ const normalizeModuleTranspilePath = (p) => {
2467
2443
  async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
2468
2444
  let buildTimeModuleMeta = {};
2469
2445
  if (typeof nuxtModule === "string") {
2470
- const src = await resolvePath(nuxtModule);
2471
- try {
2472
- nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir });
2473
- } catch (error) {
2446
+ const paths = [join(nuxtModule, "nuxt"), join(nuxtModule, "module"), nuxtModule];
2447
+ let error;
2448
+ for (const path of paths) {
2449
+ const src = await resolvePath(path);
2450
+ try {
2451
+ nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir });
2452
+ const moduleMetadataPath = join(dirname(src), "module.json");
2453
+ if (existsSync(moduleMetadataPath)) {
2454
+ buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
2455
+ }
2456
+ break;
2457
+ } catch (_err) {
2458
+ error = _err;
2459
+ continue;
2460
+ }
2461
+ }
2462
+ if (typeof nuxtModule !== "function" && error) {
2474
2463
  logger.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
2475
2464
  throw error;
2476
2465
  }
2477
- if (existsSync(join(dirname(src), "module.json"))) {
2478
- buildTimeModuleMeta = JSON.parse(await promises.readFile(join(dirname(src), "module.json"), "utf-8"));
2479
- }
2480
2466
  }
2481
2467
  if (typeof nuxtModule !== "function") {
2482
2468
  throw new TypeError("Nuxt module should be a function: " + nuxtModule);
@@ -2618,13 +2604,13 @@ async function buildNuxt(nuxt) {
2618
2604
  function addImports(imports) {
2619
2605
  assertNuxtCompatibility({ bridge: true });
2620
2606
  useNuxt().hook("imports:extend", (_imports) => {
2621
- _imports.push(...Array.isArray(imports) ? imports : [imports]);
2607
+ _imports.push(...toArray(imports));
2622
2608
  });
2623
2609
  }
2624
2610
  function addImportsDir(dirs, opts = {}) {
2625
2611
  assertNuxtCompatibility({ bridge: true });
2626
2612
  useNuxt().hook("imports:dirs", (_dirs) => {
2627
- for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
2613
+ for (const dir of toArray(dirs)) {
2628
2614
  _dirs[opts.prepend ? "unshift" : "push"](dir);
2629
2615
  }
2630
2616
  });
@@ -2632,7 +2618,7 @@ function addImportsDir(dirs, opts = {}) {
2632
2618
  function addImportsSources(presets) {
2633
2619
  assertNuxtCompatibility({ bridge: true });
2634
2620
  useNuxt().hook("imports:sources", (_presets) => {
2635
- for (const preset of Array.isArray(presets) ? presets : [presets]) {
2621
+ for (const preset of toArray(presets)) {
2636
2622
  _presets.push(preset);
2637
2623
  }
2638
2624
  });
@@ -2686,11 +2672,7 @@ function addWebpackPlugin(pluginOrGetter, options) {
2686
2672
  const method = options?.prepend ? "unshift" : "push";
2687
2673
  const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
2688
2674
  config.plugins = config.plugins || [];
2689
- if (Array.isArray(plugin)) {
2690
- config.plugins[method](...plugin);
2691
- } else {
2692
- config.plugins[method](plugin);
2693
- }
2675
+ config.plugins[method](...toArray(plugin));
2694
2676
  }, options);
2695
2677
  }
2696
2678
  function addVitePlugin(pluginOrGetter, options) {
@@ -2698,11 +2680,7 @@ function addVitePlugin(pluginOrGetter, options) {
2698
2680
  const method = options?.prepend ? "unshift" : "push";
2699
2681
  const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
2700
2682
  config.plugins = config.plugins || [];
2701
- if (Array.isArray(plugin)) {
2702
- config.plugins[method](...plugin);
2703
- } else {
2704
- config.plugins[method](plugin);
2705
- }
2683
+ config.plugins[method](...toArray(plugin));
2706
2684
  }, options);
2707
2685
  }
2708
2686
  function addBuildPlugin(pluginFactory, options) {
@@ -2714,19 +2692,23 @@ function addBuildPlugin(pluginFactory, options) {
2714
2692
  }
2715
2693
  }
2716
2694
 
2717
- async function addComponentsDir(dir) {
2695
+ async function addComponentsDir(dir, opts = {}) {
2718
2696
  const nuxt = useNuxt();
2719
2697
  await assertNuxtCompatibility({ nuxt: ">=2.13" }, nuxt);
2720
2698
  nuxt.options.components = nuxt.options.components || [];
2721
2699
  dir.priority || (dir.priority = 0);
2722
2700
  nuxt.hook("components:dirs", (dirs) => {
2723
- dirs.push(dir);
2701
+ dirs[opts.prepend ? "unshift" : "push"](dir);
2724
2702
  });
2725
2703
  }
2726
2704
  async function addComponent(opts) {
2727
2705
  const nuxt = useNuxt();
2728
2706
  await assertNuxtCompatibility({ nuxt: ">=2.13" }, nuxt);
2729
2707
  nuxt.options.components = nuxt.options.components || [];
2708
+ if (!opts.mode) {
2709
+ const [, mode = "all"] = opts.filePath.match(/\.(server|client)(\.\w+)*$/) || [];
2710
+ opts.mode = mode;
2711
+ }
2730
2712
  const component = {
2731
2713
  export: opts.export || "default",
2732
2714
  chunkName: "components/" + kebabCase(opts.name),
@@ -2827,7 +2809,7 @@ async function writeTypes(nuxt) {
2827
2809
  jsxImportSource: "vue",
2828
2810
  target: "ESNext",
2829
2811
  module: "ESNext",
2830
- moduleResolution: nuxt.options.experimental?.typescriptBundlerResolution ? "Bundler" : "Node",
2812
+ moduleResolution: nuxt.options.future?.typescriptBundlerResolution || nuxt.options.experimental?.typescriptBundlerResolution ? "Bundler" : "Node",
2831
2813
  skipLibCheck: true,
2832
2814
  isolatedModules: true,
2833
2815
  useDefineForClassFields: true,
@@ -2900,9 +2882,6 @@ async function writeTypes(nuxt) {
2900
2882
  ...nuxt.options.modules,
2901
2883
  ...nuxt.options._modules
2902
2884
  ].filter((f) => typeof f === "string").map(async (id) => ({ types: (await readPackageJSON(id, { url: nodeModulePaths }).catch(() => null))?.name || id })));
2903
- if (nuxt.options.experimental?.reactivityTransform) {
2904
- references.push({ types: "vue/macros-global" });
2905
- }
2906
2885
  const declarations = [];
2907
2886
  await nuxt.callHook("prepare:types", { references, declarations, tsConfig });
2908
2887
  for (const alias in tsConfig.compilerOptions.paths) {
@@ -3003,7 +2982,7 @@ function extendRouteRules(route, rule, options = {}) {
3003
2982
  }
3004
2983
  function addRouteMiddleware(input, options = {}) {
3005
2984
  const nuxt = useNuxt();
3006
- const middlewares = Array.isArray(input) ? input : [input];
2985
+ const middlewares = toArray(input);
3007
2986
  nuxt.hook("app:resolve", (app) => {
3008
2987
  for (const middleware of middlewares) {
3009
2988
  const find = app.middleware.findIndex((item) => item.name === middleware.name);
@@ -3076,10 +3055,7 @@ function addServerPlugin(plugin) {
3076
3055
  }
3077
3056
  function addPrerenderRoutes(routes) {
3078
3057
  const nuxt = useNuxt();
3079
- if (!Array.isArray(routes)) {
3080
- routes = [routes];
3081
- }
3082
- routes = routes.filter(Boolean);
3058
+ routes = toArray(routes).filter(Boolean);
3083
3059
  if (!routes.length) {
3084
3060
  return;
3085
3061
  }
@@ -3100,21 +3076,27 @@ function addServerImports(imports) {
3100
3076
  const nuxt = useNuxt();
3101
3077
  nuxt.hook("nitro:config", (config) => {
3102
3078
  config.imports = config.imports || {};
3103
- if (Array.isArray(config.imports.imports)) {
3104
- config.imports.imports.push(...imports);
3105
- } else {
3106
- config.imports.imports = [config.imports.imports, ...imports];
3107
- }
3079
+ config.imports.imports = config.imports.imports || [];
3080
+ config.imports.imports.push(...imports);
3108
3081
  });
3109
3082
  }
3110
3083
  function addServerImportsDir(dirs, opts = {}) {
3111
3084
  const nuxt = useNuxt();
3112
- const _dirs = Array.isArray(dirs) ? dirs : [dirs];
3085
+ const _dirs = toArray(dirs);
3113
3086
  nuxt.hook("nitro:config", (config) => {
3114
3087
  config.imports = config.imports || {};
3115
3088
  config.imports.dirs = config.imports.dirs || [];
3116
3089
  config.imports.dirs[opts.prepend ? "unshift" : "push"](..._dirs);
3117
3090
  });
3118
3091
  }
3092
+ function addServerScanDir(dirs, opts = {}) {
3093
+ const nuxt = useNuxt();
3094
+ nuxt.hook("nitro:config", (config) => {
3095
+ config.scanDirs = config.scanDirs || [];
3096
+ for (const dir of toArray(dirs)) {
3097
+ config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
3098
+ }
3099
+ });
3100
+ }
3119
3101
 
3120
- export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
3102
+ export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.8.2",
3
+ "version": "3.9.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -23,9 +23,9 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "c12": "^1.5.1",
26
+ "c12": "^1.6.1",
27
27
  "consola": "^3.2.3",
28
- "defu": "^6.1.3",
28
+ "defu": "^6.1.4",
29
29
  "globby": "^14.0.0",
30
30
  "hash-sum": "^2.0.0",
31
31
  "ignore": "^5.3.0",
@@ -34,23 +34,23 @@
34
34
  "mlly": "^1.4.2",
35
35
  "pathe": "^1.1.1",
36
36
  "pkg-types": "^1.0.3",
37
- "scule": "^1.1.0",
37
+ "scule": "^1.1.1",
38
38
  "semver": "^7.5.4",
39
39
  "ufo": "^1.3.2",
40
40
  "unctx": "^2.3.1",
41
- "unimport": "^3.5.0",
41
+ "unimport": "^3.7.1",
42
42
  "untyped": "^1.4.0",
43
- "@nuxt/schema": "3.8.2"
43
+ "@nuxt/schema": "3.9.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/hash-sum": "1.0.2",
47
- "@types/lodash-es": "4.17.11",
48
- "@types/semver": "7.5.5",
47
+ "@types/lodash-es": "4.17.12",
48
+ "@types/semver": "7.5.6",
49
49
  "lodash-es": "4.17.21",
50
- "nitropack": "2.8.0",
50
+ "nitropack": "2.8.1",
51
51
  "unbuild": "latest",
52
- "vite": "4.5.0",
53
- "vitest": "0.33.0",
52
+ "vite": "5.0.11",
53
+ "vitest": "1.1.1",
54
54
  "webpack": "5.89.0"
55
55
  },
56
56
  "engines": {