@nuxt/kit 3.8.2 → 3.9.0

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
  /**
@@ -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
  /**
@@ -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");
@@ -2063,6 +2063,10 @@ function template(string, options, guard) {
2063
2063
  return result;
2064
2064
  }
2065
2065
 
2066
+ function toArray(value) {
2067
+ return Array.isArray(value) ? value : [value];
2068
+ }
2069
+
2066
2070
  async function compileTemplate(template$1, ctx) {
2067
2071
  const data = { ...ctx, options: template$1.options };
2068
2072
  if (template$1.src) {
@@ -2081,10 +2085,7 @@ async function compileTemplate(template$1, ctx) {
2081
2085
  }
2082
2086
  const serialize = (data) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, (r) => JSON.parse(r).replace(/^{(.*)}$/, "$1"));
2083
2087
  const importSources = (sources, { lazy = false } = {}) => {
2084
- if (!Array.isArray(sources)) {
2085
- sources = [sources];
2086
- }
2087
- return sources.map((src) => {
2088
+ return toArray(sources).map((src) => {
2088
2089
  if (lazy) {
2089
2090
  return `const ${genSafeVariableName(src)} = ${genDynamicImport(src, { comment: `webpackChunkName: ${JSON.stringify(src)}` })}`;
2090
2091
  }
@@ -2373,10 +2374,7 @@ async function resolvePath(path, opts = {}) {
2373
2374
  return path;
2374
2375
  }
2375
2376
  async function findPath(paths, opts, pathType = "file") {
2376
- if (!Array.isArray(paths)) {
2377
- paths = [paths];
2378
- }
2379
- for (const path of paths) {
2377
+ for (const path of toArray(paths)) {
2380
2378
  const rPath = await resolvePath(path, opts);
2381
2379
  if (await existsSensitive(rPath)) {
2382
2380
  const _isDir = await isDirectory(rPath);
@@ -2434,8 +2432,16 @@ async function resolveFiles(path, pattern, opts = {}) {
2434
2432
  return files.map((p) => resolve(path, p)).filter((p) => !isIgnored(p)).sort();
2435
2433
  }
2436
2434
 
2435
+ const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
2437
2436
  async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2438
2437
  const { nuxtModule, buildTimeModuleMeta } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
2438
+ const localLayerModuleDirs = /* @__PURE__ */ new Set();
2439
+ for (const l of nuxt.options._layers) {
2440
+ const srcDir = l.config.srcDir || l.cwd;
2441
+ if (!NODE_MODULES_RE.test(srcDir)) {
2442
+ localLayerModuleDirs.add(resolve(srcDir, l.config?.dir?.modules || "modules"));
2443
+ }
2444
+ }
2439
2445
  const res = (isNuxt2() ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : await nuxtModule(inlineOptions, nuxt)) ?? {};
2440
2446
  if (res === false) {
2441
2447
  return;
@@ -2443,8 +2449,8 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2443
2449
  if (typeof moduleToInstall === "string") {
2444
2450
  nuxt.options.build.transpile.push(normalizeModuleTranspilePath(moduleToInstall));
2445
2451
  const directory = getDirectory(moduleToInstall);
2446
- if (directory !== moduleToInstall) {
2447
- nuxt.options.modulesDir.push(getDirectory(moduleToInstall));
2452
+ if (directory !== moduleToInstall && !localLayerModuleDirs.has(directory)) {
2453
+ nuxt.options.modulesDir.push(directory);
2448
2454
  }
2449
2455
  }
2450
2456
  nuxt.options._installedModules = nuxt.options._installedModules || [];
@@ -2467,16 +2473,26 @@ const normalizeModuleTranspilePath = (p) => {
2467
2473
  async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
2468
2474
  let buildTimeModuleMeta = {};
2469
2475
  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) {
2476
+ const paths = [join(nuxtModule, "nuxt"), join(nuxtModule, "module"), nuxtModule];
2477
+ let error;
2478
+ for (const path of paths) {
2479
+ const src = await resolvePath(path);
2480
+ try {
2481
+ nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir });
2482
+ const moduleMetadataPath = join(dirname(src), "module.json");
2483
+ if (existsSync(moduleMetadataPath)) {
2484
+ buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
2485
+ }
2486
+ break;
2487
+ } catch (_err) {
2488
+ error = _err;
2489
+ continue;
2490
+ }
2491
+ }
2492
+ if (!nuxtModule && error) {
2474
2493
  logger.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
2475
2494
  throw error;
2476
2495
  }
2477
- if (existsSync(join(dirname(src), "module.json"))) {
2478
- buildTimeModuleMeta = JSON.parse(await promises.readFile(join(dirname(src), "module.json"), "utf-8"));
2479
- }
2480
2496
  }
2481
2497
  if (typeof nuxtModule !== "function") {
2482
2498
  throw new TypeError("Nuxt module should be a function: " + nuxtModule);
@@ -2618,13 +2634,13 @@ async function buildNuxt(nuxt) {
2618
2634
  function addImports(imports) {
2619
2635
  assertNuxtCompatibility({ bridge: true });
2620
2636
  useNuxt().hook("imports:extend", (_imports) => {
2621
- _imports.push(...Array.isArray(imports) ? imports : [imports]);
2637
+ _imports.push(...toArray(imports));
2622
2638
  });
2623
2639
  }
2624
2640
  function addImportsDir(dirs, opts = {}) {
2625
2641
  assertNuxtCompatibility({ bridge: true });
2626
2642
  useNuxt().hook("imports:dirs", (_dirs) => {
2627
- for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
2643
+ for (const dir of toArray(dirs)) {
2628
2644
  _dirs[opts.prepend ? "unshift" : "push"](dir);
2629
2645
  }
2630
2646
  });
@@ -2632,7 +2648,7 @@ function addImportsDir(dirs, opts = {}) {
2632
2648
  function addImportsSources(presets) {
2633
2649
  assertNuxtCompatibility({ bridge: true });
2634
2650
  useNuxt().hook("imports:sources", (_presets) => {
2635
- for (const preset of Array.isArray(presets) ? presets : [presets]) {
2651
+ for (const preset of toArray(presets)) {
2636
2652
  _presets.push(preset);
2637
2653
  }
2638
2654
  });
@@ -2686,11 +2702,7 @@ function addWebpackPlugin(pluginOrGetter, options) {
2686
2702
  const method = options?.prepend ? "unshift" : "push";
2687
2703
  const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
2688
2704
  config.plugins = config.plugins || [];
2689
- if (Array.isArray(plugin)) {
2690
- config.plugins[method](...plugin);
2691
- } else {
2692
- config.plugins[method](plugin);
2693
- }
2705
+ config.plugins[method](...toArray(plugin));
2694
2706
  }, options);
2695
2707
  }
2696
2708
  function addVitePlugin(pluginOrGetter, options) {
@@ -2698,11 +2710,7 @@ function addVitePlugin(pluginOrGetter, options) {
2698
2710
  const method = options?.prepend ? "unshift" : "push";
2699
2711
  const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
2700
2712
  config.plugins = config.plugins || [];
2701
- if (Array.isArray(plugin)) {
2702
- config.plugins[method](...plugin);
2703
- } else {
2704
- config.plugins[method](plugin);
2705
- }
2713
+ config.plugins[method](...toArray(plugin));
2706
2714
  }, options);
2707
2715
  }
2708
2716
  function addBuildPlugin(pluginFactory, options) {
@@ -2714,19 +2722,23 @@ function addBuildPlugin(pluginFactory, options) {
2714
2722
  }
2715
2723
  }
2716
2724
 
2717
- async function addComponentsDir(dir) {
2725
+ async function addComponentsDir(dir, opts = {}) {
2718
2726
  const nuxt = useNuxt();
2719
2727
  await assertNuxtCompatibility({ nuxt: ">=2.13" }, nuxt);
2720
2728
  nuxt.options.components = nuxt.options.components || [];
2721
2729
  dir.priority || (dir.priority = 0);
2722
2730
  nuxt.hook("components:dirs", (dirs) => {
2723
- dirs.push(dir);
2731
+ dirs[opts.prepend ? "unshift" : "push"](dir);
2724
2732
  });
2725
2733
  }
2726
2734
  async function addComponent(opts) {
2727
2735
  const nuxt = useNuxt();
2728
2736
  await assertNuxtCompatibility({ nuxt: ">=2.13" }, nuxt);
2729
2737
  nuxt.options.components = nuxt.options.components || [];
2738
+ if (!opts.mode) {
2739
+ const [, mode = "all"] = opts.filePath.match(/\.(server|client)(\.\w+)*$/) || [];
2740
+ opts.mode = mode;
2741
+ }
2730
2742
  const component = {
2731
2743
  export: opts.export || "default",
2732
2744
  chunkName: "components/" + kebabCase(opts.name),
@@ -2827,7 +2839,7 @@ async function writeTypes(nuxt) {
2827
2839
  jsxImportSource: "vue",
2828
2840
  target: "ESNext",
2829
2841
  module: "ESNext",
2830
- moduleResolution: nuxt.options.experimental?.typescriptBundlerResolution ? "Bundler" : "Node",
2842
+ moduleResolution: nuxt.options.future?.typescriptBundlerResolution || nuxt.options.experimental?.typescriptBundlerResolution ? "Bundler" : "Node",
2831
2843
  skipLibCheck: true,
2832
2844
  isolatedModules: true,
2833
2845
  useDefineForClassFields: true,
@@ -2900,9 +2912,6 @@ async function writeTypes(nuxt) {
2900
2912
  ...nuxt.options.modules,
2901
2913
  ...nuxt.options._modules
2902
2914
  ].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
2915
  const declarations = [];
2907
2916
  await nuxt.callHook("prepare:types", { references, declarations, tsConfig });
2908
2917
  for (const alias in tsConfig.compilerOptions.paths) {
@@ -3003,7 +3012,7 @@ function extendRouteRules(route, rule, options = {}) {
3003
3012
  }
3004
3013
  function addRouteMiddleware(input, options = {}) {
3005
3014
  const nuxt = useNuxt();
3006
- const middlewares = Array.isArray(input) ? input : [input];
3015
+ const middlewares = toArray(input);
3007
3016
  nuxt.hook("app:resolve", (app) => {
3008
3017
  for (const middleware of middlewares) {
3009
3018
  const find = app.middleware.findIndex((item) => item.name === middleware.name);
@@ -3076,10 +3085,7 @@ function addServerPlugin(plugin) {
3076
3085
  }
3077
3086
  function addPrerenderRoutes(routes) {
3078
3087
  const nuxt = useNuxt();
3079
- if (!Array.isArray(routes)) {
3080
- routes = [routes];
3081
- }
3082
- routes = routes.filter(Boolean);
3088
+ routes = toArray(routes).filter(Boolean);
3083
3089
  if (!routes.length) {
3084
3090
  return;
3085
3091
  }
@@ -3100,21 +3106,27 @@ function addServerImports(imports) {
3100
3106
  const nuxt = useNuxt();
3101
3107
  nuxt.hook("nitro:config", (config) => {
3102
3108
  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
- }
3109
+ config.imports.imports = config.imports.imports || [];
3110
+ config.imports.imports.push(...imports);
3108
3111
  });
3109
3112
  }
3110
3113
  function addServerImportsDir(dirs, opts = {}) {
3111
3114
  const nuxt = useNuxt();
3112
- const _dirs = Array.isArray(dirs) ? dirs : [dirs];
3115
+ const _dirs = toArray(dirs);
3113
3116
  nuxt.hook("nitro:config", (config) => {
3114
3117
  config.imports = config.imports || {};
3115
3118
  config.imports.dirs = config.imports.dirs || [];
3116
3119
  config.imports.dirs[opts.prepend ? "unshift" : "push"](..._dirs);
3117
3120
  });
3118
3121
  }
3122
+ function addServerScanDir(dirs, opts = {}) {
3123
+ const nuxt = useNuxt();
3124
+ nuxt.hook("nitro:config", (config) => {
3125
+ config.scanDirs = config.scanDirs || [];
3126
+ for (const dir of toArray(dirs)) {
3127
+ config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
3128
+ }
3129
+ });
3130
+ }
3119
3131
 
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 };
3132
+ 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.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -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.0",
42
42
  "untyped": "^1.4.0",
43
- "@nuxt/schema": "3.8.2"
43
+ "@nuxt/schema": "3.9.0"
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.10",
53
+ "vitest": "1.1.0",
54
54
  "webpack": "5.89.0"
55
55
  },
56
56
  "engines": {