@nuxt/kit 3.7.3 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -282,6 +282,7 @@ interface Resolver {
282
282
  * Create a relative resolver
283
283
  */
284
284
  declare function createResolver(base: string | URL): Resolver;
285
+ declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
285
286
  declare function resolveFiles(path: string, pattern: string | string[], opts?: {
286
287
  followSymbolicLinks?: boolean;
287
288
  }): Promise<string[]>;
@@ -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, 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
@@ -282,6 +282,7 @@ interface Resolver {
282
282
  * Create a relative resolver
283
283
  */
284
284
  declare function createResolver(base: string | URL): Resolver;
285
+ declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
285
286
  declare function resolveFiles(path: string, pattern: string | string[], opts?: {
286
287
  followSymbolicLinks?: boolean;
287
288
  }): Promise<string[]>;
@@ -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, 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"))) {
@@ -2727,7 +2740,7 @@ async function addComponent(opts) {
2727
2740
  }
2728
2741
  if (newPriority === existingPriority) {
2729
2742
  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.`);
2743
+ logger.warn(`Overriding ${name} component. You can specify a \`priority\` option when calling \`addComponent\` to avoid this warning.`);
2731
2744
  }
2732
2745
  Object.assign(existingComponent, component);
2733
2746
  } else {
@@ -2793,6 +2806,10 @@ async function updateTemplates(options) {
2793
2806
  async function writeTypes(nuxt) {
2794
2807
  const modulePaths = getModulePaths(nuxt.options.modulesDir);
2795
2808
  const rootDirWithSlash = withTrailingSlash(nuxt.options.rootDir);
2809
+ const modules = await resolveNuxtModule(
2810
+ rootDirWithSlash,
2811
+ nuxt.options._installedModules.filter((m) => m.entryPath).map((m) => m.entryPath)
2812
+ );
2796
2813
  const tsConfig = defu(nuxt.options.typescript?.tsConfig, {
2797
2814
  compilerOptions: {
2798
2815
  forceConsistentCasingInFileNames: true,
@@ -2821,10 +2838,12 @@ async function writeTypes(nuxt) {
2821
2838
  join(relativeWithDot(nuxt.options.buildDir, nuxt.options.rootDir), "**/*"),
2822
2839
  ...nuxt.options.srcDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.srcDir), "**/*")] : [],
2823
2840
  ...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), "**/*")] : []
2841
+ ...nuxt.options.typescript.includeWorkspace && nuxt.options.workspaceDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.workspaceDir), "**/*")] : [],
2842
+ ...modules.map((m) => join(relativeWithDot(nuxt.options.buildDir, m), "runtime"))
2825
2843
  ],
2826
2844
  exclude: [
2827
2845
  ...nuxt.options.modulesDir.map((m) => relativeWithDot(nuxt.options.buildDir, m)),
2846
+ ...modules.map((m) => join(relativeWithDot(nuxt.options.buildDir, m), "runtime/server")),
2828
2847
  // nitro generate output: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/nitro.ts#L186
2829
2848
  relativeWithDot(nuxt.options.buildDir, resolve(nuxt.options.rootDir, "dist"))
2830
2849
  ]
@@ -2983,7 +3002,7 @@ function addRouteMiddleware(input, options = {}) {
2983
3002
  if (options.override === true) {
2984
3003
  app.middleware[find] = middleware;
2985
3004
  } else {
2986
- console.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`);
3005
+ logger.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`);
2987
3006
  }
2988
3007
  } else {
2989
3008
  app.middleware.push(middleware);
@@ -3003,7 +3022,7 @@ function normalizePlugin(plugin) {
3003
3022
  }
3004
3023
  const nonTopLevelPlugin = plugin.src.match(/\/plugins\/[^/]+\/index\.[^/]+$/i);
3005
3024
  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.`);
3025
+ 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/configuration/nuxt-config#plugins-1) to remove this warning.`);
3007
3026
  }
3008
3027
  plugin.src = normalize(resolveAlias(plugin.src));
3009
3028
  if (plugin.ssr) {
@@ -3069,4 +3088,4 @@ function useNitro() {
3069
3088
  return nuxt._nitro;
3070
3089
  }
3071
3090
 
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 };
3091
+ 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, 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.7.3",
3
+ "version": "3.7.4",
4
4
  "repository": "nuxt/nuxt",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,12 +34,12 @@
34
34
  "unctx": "^2.3.1",
35
35
  "unimport": "^3.3.0",
36
36
  "untyped": "^1.4.0",
37
- "@nuxt/schema": "3.7.3"
37
+ "@nuxt/schema": "3.7.4"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/hash-sum": "1.0.0",
41
41
  "@types/lodash-es": "4.17.9",
42
- "@types/semver": "7.5.1",
42
+ "@types/semver": "7.5.3",
43
43
  "lodash-es": "4.17.21",
44
44
  "nitropack": "2.6.3",
45
45
  "unbuild": "latest",