@nuxt/kit 3.7.3 → 3.8.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/README.md CHANGED
@@ -17,7 +17,7 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
17
17
  - Automatic routing with code-splitting
18
18
  - State management
19
19
  - SEO Optimization
20
- - Extandable with [100+ modules](https://nuxt.com/modules)
20
+ - Extensible with [100+ modules](https://nuxt.com/modules)
21
21
  - Deployment to a variety of hosting platforms
22
22
  - ...[and much more](https://nuxt.com) 🚀
23
23
 
@@ -50,7 +50,7 @@ Here are a few ways you can get involved:
50
50
 
51
51
  ## Local Development
52
52
 
53
- Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#set-up-your-local-development-environment) to contribute to the framework and documentation.
53
+ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#setup) to contribute to the framework and documentation.
54
54
 
55
55
  ## Nuxt 2
56
56
 
package/dist/index.d.mts CHANGED
@@ -68,30 +68,26 @@ declare function addImportsSources(presets: ImportPresetWithDeprecation | Import
68
68
  interface ExtendConfigOptions {
69
69
  /**
70
70
  * Install plugin on dev
71
- *
72
71
  * @default true
73
72
  */
74
73
  dev?: boolean;
75
74
  /**
76
75
  * Install plugin on build
77
- *
78
76
  * @default true
79
77
  */
80
78
  build?: boolean;
81
79
  /**
82
80
  * Install plugin on server side
83
- *
84
81
  * @default true
85
82
  */
86
83
  server?: boolean;
87
84
  /**
88
85
  * Install plugin on client side
89
- *
90
86
  * @default true
91
87
  */
92
88
  client?: boolean;
93
89
  /**
94
- * Prepends the plugin to the array with `unshit()` instead of `push()`.
90
+ * Prepends the plugin to the array with `unshift()` instead of `push()`.
95
91
  */
96
92
  prepend?: boolean;
97
93
  }
@@ -173,7 +169,6 @@ declare const nuxtCtx: unctx_index.UseContext<Nuxt>;
173
169
  * Get access to Nuxt instance.
174
170
  *
175
171
  * Throws an error if Nuxt instance is unavailable.
176
- *
177
172
  * @example
178
173
  * ```js
179
174
  * const nuxt = useNuxt()
@@ -184,7 +179,6 @@ declare function useNuxt(): Nuxt;
184
179
  * Get access to Nuxt instance.
185
180
  *
186
181
  * Returns null if Nuxt instance is unavailable.
187
- *
188
182
  * @example
189
183
  * ```js
190
184
  * const nuxt = tryUseNuxt()
@@ -207,7 +201,6 @@ declare function extendPages(cb: NuxtHooks['pages:extend']): void;
207
201
  interface ExtendRouteRulesOptions {
208
202
  /**
209
203
  * Override route rule config
210
- *
211
204
  * @default false
212
205
  */
213
206
  override?: boolean;
@@ -216,7 +209,6 @@ declare function extendRouteRules(route: string, rule: NitroRouteConfig, options
216
209
  interface AddRouteMiddlewareOptions {
217
210
  /**
218
211
  * Override existing middleware with the same name, if it exists
219
- *
220
212
  * @default false
221
213
  */
222
214
  override?: boolean;
@@ -234,7 +226,6 @@ declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
234
226
  * to use plugin only in client or server side.
235
227
  *
236
228
  * Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
237
- *
238
229
  * @example
239
230
  * ```js
240
231
  * addPlugin({
@@ -282,6 +273,7 @@ interface Resolver {
282
273
  * Create a relative resolver
283
274
  */
284
275
  declare function createResolver(base: string | URL): Resolver;
276
+ declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
285
277
  declare function resolveFiles(path: string, pattern: string | string[], opts?: {
286
278
  followSymbolicLinks?: boolean;
287
279
  }): Promise<string[]>;
@@ -310,7 +302,6 @@ declare function addPrerenderRoutes(routes: string | string[]): void;
310
302
  * **Note:** You can call `useNitro()` only after `ready` hook.
311
303
  *
312
304
  * **Note:** Changes to the Nitro instance configuration are not applied.
313
- *
314
305
  * @example
315
306
  *
316
307
  * ```ts
@@ -320,6 +311,16 @@ declare function addPrerenderRoutes(routes: string | string[]): void;
320
311
  * ```
321
312
  */
322
313
  declare function useNitro(): Nitro;
314
+ /**
315
+ * Add server imports to be auto-imported by Nitro
316
+ */
317
+ declare function addServerImports(imports: Import[]): void;
318
+ /**
319
+ * Add directories to be scanned by Nitro
320
+ */
321
+ declare function addServerImportsDir(dirs: string | string[], opts?: {
322
+ prepend?: boolean;
323
+ }): void;
323
324
 
324
325
  /**
325
326
  * Renders given template using lodash template during build into the project buildDir
@@ -388,4 +389,4 @@ declare const templateUtils: {
388
389
  }) => string;
389
390
  };
390
391
 
391
- 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, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
392
+ 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, 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
@@ -68,30 +68,26 @@ declare function addImportsSources(presets: ImportPresetWithDeprecation | Import
68
68
  interface ExtendConfigOptions {
69
69
  /**
70
70
  * Install plugin on dev
71
- *
72
71
  * @default true
73
72
  */
74
73
  dev?: boolean;
75
74
  /**
76
75
  * Install plugin on build
77
- *
78
76
  * @default true
79
77
  */
80
78
  build?: boolean;
81
79
  /**
82
80
  * Install plugin on server side
83
- *
84
81
  * @default true
85
82
  */
86
83
  server?: boolean;
87
84
  /**
88
85
  * Install plugin on client side
89
- *
90
86
  * @default true
91
87
  */
92
88
  client?: boolean;
93
89
  /**
94
- * Prepends the plugin to the array with `unshit()` instead of `push()`.
90
+ * Prepends the plugin to the array with `unshift()` instead of `push()`.
95
91
  */
96
92
  prepend?: boolean;
97
93
  }
@@ -173,7 +169,6 @@ declare const nuxtCtx: unctx_index.UseContext<Nuxt>;
173
169
  * Get access to Nuxt instance.
174
170
  *
175
171
  * Throws an error if Nuxt instance is unavailable.
176
- *
177
172
  * @example
178
173
  * ```js
179
174
  * const nuxt = useNuxt()
@@ -184,7 +179,6 @@ declare function useNuxt(): Nuxt;
184
179
  * Get access to Nuxt instance.
185
180
  *
186
181
  * Returns null if Nuxt instance is unavailable.
187
- *
188
182
  * @example
189
183
  * ```js
190
184
  * const nuxt = tryUseNuxt()
@@ -207,7 +201,6 @@ declare function extendPages(cb: NuxtHooks['pages:extend']): void;
207
201
  interface ExtendRouteRulesOptions {
208
202
  /**
209
203
  * Override route rule config
210
- *
211
204
  * @default false
212
205
  */
213
206
  override?: boolean;
@@ -216,7 +209,6 @@ declare function extendRouteRules(route: string, rule: NitroRouteConfig, options
216
209
  interface AddRouteMiddlewareOptions {
217
210
  /**
218
211
  * Override existing middleware with the same name, if it exists
219
- *
220
212
  * @default false
221
213
  */
222
214
  override?: boolean;
@@ -234,7 +226,6 @@ declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
234
226
  * to use plugin only in client or server side.
235
227
  *
236
228
  * Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
237
- *
238
229
  * @example
239
230
  * ```js
240
231
  * addPlugin({
@@ -282,6 +273,7 @@ interface Resolver {
282
273
  * Create a relative resolver
283
274
  */
284
275
  declare function createResolver(base: string | URL): Resolver;
276
+ declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
285
277
  declare function resolveFiles(path: string, pattern: string | string[], opts?: {
286
278
  followSymbolicLinks?: boolean;
287
279
  }): Promise<string[]>;
@@ -310,7 +302,6 @@ declare function addPrerenderRoutes(routes: string | string[]): void;
310
302
  * **Note:** You can call `useNitro()` only after `ready` hook.
311
303
  *
312
304
  * **Note:** Changes to the Nitro instance configuration are not applied.
313
- *
314
305
  * @example
315
306
  *
316
307
  * ```ts
@@ -320,6 +311,16 @@ declare function addPrerenderRoutes(routes: string | string[]): void;
320
311
  * ```
321
312
  */
322
313
  declare function useNitro(): Nitro;
314
+ /**
315
+ * Add server imports to be auto-imported by Nitro
316
+ */
317
+ declare function addServerImports(imports: Import[]): void;
318
+ /**
319
+ * Add directories to be scanned by Nitro
320
+ */
321
+ declare function addServerImportsDir(dirs: string | string[], opts?: {
322
+ prepend?: boolean;
323
+ }): void;
323
324
 
324
325
  /**
325
326
  * Renders given template using lodash template during build into the project buildDir
@@ -388,4 +389,4 @@ declare const templateUtils: {
388
389
  }) => string;
389
390
  };
390
391
 
391
- 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, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
392
+ 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, 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
@@ -2070,7 +2070,7 @@ async function compileTemplate(template$1, ctx) {
2070
2070
  const srcContents = await promises.readFile(template$1.src, "utf-8");
2071
2071
  return template(srcContents, {})(data);
2072
2072
  } catch (err) {
2073
- console.error("Error compiling template: ", template$1);
2073
+ logger.error("Error compiling template: ", template$1);
2074
2074
  throw err;
2075
2075
  }
2076
2076
  }
@@ -2406,6 +2406,19 @@ function createResolver(base) {
2406
2406
  resolvePath: (path, opts) => resolvePath(path, { cwd: base, ...opts })
2407
2407
  };
2408
2408
  }
2409
+ async function resolveNuxtModule(base, paths) {
2410
+ const resolved = [];
2411
+ const resolver = createResolver(base);
2412
+ for (const path of paths) {
2413
+ if (path.startsWith(base)) {
2414
+ resolved.push(path.split("/index.ts")[0]);
2415
+ } else {
2416
+ const resolvedPath = await resolver.resolvePath(path);
2417
+ resolved.push(resolvedPath.slice(0, resolvedPath.lastIndexOf(path) + path.length));
2418
+ }
2419
+ }
2420
+ return resolved;
2421
+ }
2409
2422
  async function existsSensitive(path) {
2410
2423
  if (!existsSync(path)) {
2411
2424
  return false;
@@ -2458,7 +2471,7 @@ async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
2458
2471
  try {
2459
2472
  nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir });
2460
2473
  } catch (error) {
2461
- console.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
2474
+ logger.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
2462
2475
  throw error;
2463
2476
  }
2464
2477
  if (existsSync(join(dirname(src), "module.json"))) {
@@ -2559,7 +2572,7 @@ async function loadNuxt(opts) {
2559
2572
  opts.cwd = opts.cwd || opts.rootDir;
2560
2573
  opts.overrides = opts.overrides || opts.config || {};
2561
2574
  opts.overrides.dev = !!opts.dev;
2562
- const nearestNuxtPkg = await Promise.all(["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]);
2575
+ 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]);
2563
2576
  if (!nearestNuxtPkg) {
2564
2577
  throw new Error(`Cannot find any nuxt version from ${opts.cwd}`);
2565
2578
  }
@@ -2580,12 +2593,22 @@ async function loadNuxt(opts) {
2580
2593
  envConfig: opts.dotenv
2581
2594
  // TODO: Backward format conversion
2582
2595
  });
2596
+ nuxt.removeHook || (nuxt.removeHook = nuxt.clearHook.bind(nuxt));
2597
+ nuxt.removeAllHooks || (nuxt.removeAllHooks = nuxt.clearHooks.bind(nuxt));
2598
+ nuxt.hookOnce || (nuxt.hookOnce = (name, fn, ...hookArgs) => {
2599
+ const unsub = nuxt.hook(name, (...args) => {
2600
+ unsub();
2601
+ return fn(...args);
2602
+ }, ...hookArgs);
2603
+ return unsub;
2604
+ });
2605
+ nuxt.hooks || (nuxt.hooks = nuxt);
2583
2606
  return nuxt;
2584
2607
  }
2585
2608
  async function buildNuxt(nuxt) {
2586
2609
  const rootDir = pathToFileURL(nuxt.options.rootDir).href;
2587
2610
  if (nuxt.options._majorVersion === 3) {
2588
- const { build: build2 } = await tryImportModule("nuxt3", rootDir) || await importModule("nuxt", rootDir);
2611
+ const { build: build2 } = await tryImportModule("nuxt-nightly", rootDir) || await tryImportModule("nuxt3", rootDir) || await importModule("nuxt", rootDir);
2589
2612
  return build2(nuxt);
2590
2613
  }
2591
2614
  const { build } = await tryImportModule("nuxt-edge", rootDir) || await importModule("nuxt", rootDir);
@@ -2727,7 +2750,7 @@ async function addComponent(opts) {
2727
2750
  }
2728
2751
  if (newPriority === existingPriority) {
2729
2752
  const name = existingComponent.pascalName || existingComponent.kebabName;
2730
- console.warn(`Overriding ${name} component. You can specify a \`priority\` option when calling \`addComponent\` to avoid this warning.`);
2753
+ logger.warn(`Overriding ${name} component. You can specify a \`priority\` option when calling \`addComponent\` to avoid this warning.`);
2731
2754
  }
2732
2755
  Object.assign(existingComponent, component);
2733
2756
  } else {
@@ -2793,6 +2816,10 @@ async function updateTemplates(options) {
2793
2816
  async function writeTypes(nuxt) {
2794
2817
  const modulePaths = getModulePaths(nuxt.options.modulesDir);
2795
2818
  const rootDirWithSlash = withTrailingSlash(nuxt.options.rootDir);
2819
+ const modules = await resolveNuxtModule(
2820
+ rootDirWithSlash,
2821
+ nuxt.options._installedModules.filter((m) => m.entryPath).map((m) => m.entryPath)
2822
+ );
2796
2823
  const tsConfig = defu(nuxt.options.typescript?.tsConfig, {
2797
2824
  compilerOptions: {
2798
2825
  forceConsistentCasingInFileNames: true,
@@ -2807,9 +2834,8 @@ async function writeTypes(nuxt) {
2807
2834
  strict: nuxt.options.typescript?.strict ?? true,
2808
2835
  noImplicitThis: true,
2809
2836
  esModuleInterop: true,
2810
- // TODO: enable by default in v3.8
2811
- // types: [],
2812
- // verbatimModuleSyntax: true,
2837
+ types: [],
2838
+ verbatimModuleSyntax: true,
2813
2839
  allowJs: true,
2814
2840
  noEmit: true,
2815
2841
  resolveJsonModule: true,
@@ -2821,10 +2847,12 @@ async function writeTypes(nuxt) {
2821
2847
  join(relativeWithDot(nuxt.options.buildDir, nuxt.options.rootDir), "**/*"),
2822
2848
  ...nuxt.options.srcDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.srcDir), "**/*")] : [],
2823
2849
  ...nuxt.options._layers.map((layer) => layer.config.srcDir ?? layer.cwd).filter((srcOrCwd) => !srcOrCwd.startsWith(rootDirWithSlash) || srcOrCwd.includes("node_modules")).map((srcOrCwd) => join(relative(nuxt.options.buildDir, srcOrCwd), "**/*")),
2824
- ...nuxt.options.typescript.includeWorkspace && nuxt.options.workspaceDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.workspaceDir), "**/*")] : []
2850
+ ...nuxt.options.typescript.includeWorkspace && nuxt.options.workspaceDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.workspaceDir), "**/*")] : [],
2851
+ ...modules.map((m) => join(relativeWithDot(nuxt.options.buildDir, m), "runtime"))
2825
2852
  ],
2826
2853
  exclude: [
2827
2854
  ...nuxt.options.modulesDir.map((m) => relativeWithDot(nuxt.options.buildDir, m)),
2855
+ ...modules.map((m) => join(relativeWithDot(nuxt.options.buildDir, m), "runtime/server")),
2828
2856
  // nitro generate output: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/nitro.ts#L186
2829
2857
  relativeWithDot(nuxt.options.buildDir, resolve(nuxt.options.rootDir, "dist"))
2830
2858
  ]
@@ -2983,7 +3011,7 @@ function addRouteMiddleware(input, options = {}) {
2983
3011
  if (options.override === true) {
2984
3012
  app.middleware[find] = middleware;
2985
3013
  } else {
2986
- console.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`);
3014
+ logger.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`);
2987
3015
  }
2988
3016
  } else {
2989
3017
  app.middleware.push(middleware);
@@ -3003,7 +3031,7 @@ function normalizePlugin(plugin) {
3003
3031
  }
3004
3032
  const nonTopLevelPlugin = plugin.src.match(/\/plugins\/[^/]+\/index\.[^/]+$/i);
3005
3033
  if (nonTopLevelPlugin && nonTopLevelPlugin.length > 0 && !useNuxt().options.plugins.find((i) => (typeof i === "string" ? i : i.src).endsWith(nonTopLevelPlugin[0]))) {
3006
- console.warn(`[warn] [nuxt] [deprecation] You are using a plugin that is within a subfolder of your plugins directory without adding it to your config explicitly. You can move it to the top-level plugins directory, or include the file '~${nonTopLevelPlugin[0]}' in your plugins config (https://nuxt.com/docs/api/configuration/nuxt-config#plugins-1) to remove this warning.`);
3034
+ logger.warn(`[deprecation] You are using a plugin that is within a subfolder of your plugins directory without adding it to your config explicitly. You can move it to the top-level plugins directory, or include the file '~${nonTopLevelPlugin[0]}' in your plugins config (https://nuxt.com/docs/api/nuxt-config#plugins-1) to remove this warning.`);
3007
3035
  }
3008
3036
  plugin.src = normalize(resolveAlias(plugin.src));
3009
3037
  if (plugin.ssr) {
@@ -3068,5 +3096,25 @@ function useNitro() {
3068
3096
  }
3069
3097
  return nuxt._nitro;
3070
3098
  }
3099
+ function addServerImports(imports) {
3100
+ const nuxt = useNuxt();
3101
+ nuxt.hook("nitro:config", (config) => {
3102
+ 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
+ }
3108
+ });
3109
+ }
3110
+ function addServerImportsDir(dirs, opts = {}) {
3111
+ const nuxt = useNuxt();
3112
+ nuxt.hook("nitro:config", (config) => {
3113
+ config.scanDirs = config.scanDirs || [];
3114
+ for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
3115
+ config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
3116
+ }
3117
+ });
3118
+ }
3071
3119
 
3072
- export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, 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, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
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, 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,7 +1,8 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.7.3",
3
+ "version": "3.8.0",
4
4
  "repository": "nuxt/nuxt",
5
+ "description": "Toolkit for authoring modules and interacting with Nuxt",
5
6
  "license": "MIT",
6
7
  "type": "module",
7
8
  "types": "./dist/index.d.ts",
@@ -17,7 +18,7 @@
17
18
  "dist"
18
19
  ],
19
20
  "dependencies": {
20
- "c12": "^1.4.2",
21
+ "c12": "^1.5.1",
21
22
  "consola": "^3.2.3",
22
23
  "defu": "^6.1.2",
23
24
  "globby": "^13.2.2",
@@ -30,22 +31,22 @@
30
31
  "pkg-types": "^1.0.3",
31
32
  "scule": "^1.0.0",
32
33
  "semver": "^7.5.4",
33
- "ufo": "^1.3.0",
34
+ "ufo": "^1.3.1",
34
35
  "unctx": "^2.3.1",
35
- "unimport": "^3.3.0",
36
+ "unimport": "^3.4.0",
36
37
  "untyped": "^1.4.0",
37
- "@nuxt/schema": "3.7.3"
38
+ "@nuxt/schema": "3.8.0"
38
39
  },
39
40
  "devDependencies": {
40
- "@types/hash-sum": "1.0.0",
41
- "@types/lodash-es": "4.17.9",
42
- "@types/semver": "7.5.1",
41
+ "@types/hash-sum": "1.0.1",
42
+ "@types/lodash-es": "4.17.10",
43
+ "@types/semver": "7.5.4",
43
44
  "lodash-es": "4.17.21",
44
- "nitropack": "2.6.3",
45
+ "nitropack": "2.7.0",
45
46
  "unbuild": "latest",
46
- "vite": "4.4.9",
47
+ "vite": "4.5.0",
47
48
  "vitest": "0.33.0",
48
- "webpack": "5.88.2"
49
+ "webpack": "5.89.0"
49
50
  },
50
51
  "engines": {
51
52
  "node": "^14.18.0 || >=16.10.0"