@nuxt/kit 4.3.0 → 4.4.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/README.md CHANGED
@@ -1,15 +1,15 @@
1
- [![Nuxt banner](https://github.com/nuxt/nuxt/blob/main/.github/assets/banner.svg)](https://nuxt.com)
1
+ <a href="https://nuxt.com"><img width="830" height="213" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/banner.svg" alt="Nuxt banner"></a>
2
2
 
3
3
  # Nuxt
4
4
 
5
5
  <p>
6
- <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
7
- <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
6
+ <a href="https://npmx.dev/package/nuxt"><img src="https://npmx.dev/api/registry/badge/version/nuxt" alt="Version"></a>
7
+ <a href="https://npmx.dev/package/nuxt"><img src="https://npmx.dev/api/registry/badge/downloads/nuxt" alt="Downloads"></a>
8
8
  <a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
9
9
  <a href="https://nuxt.com/modules"><img src="https://img.shields.io/badge/dynamic/json?url=https://nuxt.com/api/v1/modules&query=$.stats.modules&label=Modules&style=flat&colorA=18181B&colorB=28CF8D" alt="Modules"></a>
10
10
  <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
11
11
  <a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
12
- <a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
12
+ <a href="https://securityscorecards.dev/viewer/?uri=github.com/nuxt/nuxt"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
13
13
  <a href="https://deepwiki.com/nuxt/nuxt"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
14
14
  </p>
15
15
 
@@ -111,7 +111,7 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
111
111
  ## <a name="follow-us">🔗 Follow Us</a>
112
112
 
113
113
  <p valign="center">
114
- <a href="https://go.nuxt.com/discord"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/x"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/github"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/bluesky"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
114
+ <a href="https://go.nuxt.com/discord"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/x"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/github"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/bluesky"><img width="20" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
115
115
  </p>
116
116
 
117
117
  ## <a name="license">⚖️ License</a>
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ConsolaInstance, ConsolaOptions } from "consola";
2
2
  import { UseContext } from "unctx";
3
- import "pkg-types";
4
3
  import { GlobOptions } from "tinyglobby";
5
4
  import { LoadConfigOptions } from "c12";
6
5
  import { Component, ComponentsDir, ModuleDefinition, ModuleMeta, ModuleOptions, Nuxt, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, NuxtConfig, NuxtHooks, NuxtMiddleware, NuxtModule, NuxtOptions, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, NuxtTemplate, NuxtTypeTemplate, ResolvedNuxtTemplate, SchemaDefinition } from "@nuxt/schema";
@@ -501,7 +500,7 @@ declare function addServerImportsDir(dirs: string | string[], opts?: {
501
500
  }): void;
502
501
  /**
503
502
  * Add directories to be scanned by Nitro. It will check for subdirectories,
504
- * which will be registered just like the `~/server` folder is.
503
+ * which will be registered just like the `~~/server` folder is.
505
504
  */
506
505
  declare function addServerScanDir(dirs: string | string[], opts?: {
507
506
  prepend?: boolean;
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { createDefu, defu } from "defu";
3
3
  import { applyDefaults } from "untyped";
4
4
  import { consola } from "consola";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
- import { createContext, getContext } from "unctx";
6
+ import { getContext } from "unctx";
7
7
  import satisfies from "semver/functions/satisfies.js";
8
8
  import { readPackageJSON, resolvePackageJSON } from "pkg-types";
9
9
  import { existsSync, lstatSync, promises, readFileSync } from "node:fs";
@@ -26,13 +26,11 @@ import { kebabCase, pascalCase, snakeCase } from "scule";
26
26
  import { klona } from "klona";
27
27
  import { hash } from "ohash";
28
28
  import { isAbsolute as isAbsolute$1 } from "node:path";
29
-
30
29
  //#region src/logger.ts
31
30
  const logger = consola;
32
31
  function useLogger(tag, options = {}) {
33
32
  return tag ? logger.create(options).withTag(tag) : logger;
34
33
  }
35
-
36
34
  //#endregion
37
35
  //#region src/context.ts
38
36
  /**
@@ -41,7 +39,7 @@ function useLogger(tag, options = {}) {
41
39
  */
42
40
  const nuxtCtx = getContext("nuxt");
43
41
  /** async local storage for the name of the current nuxt instance */
44
- const asyncNuxtStorage = createContext({
42
+ const asyncNuxtStorage = getContext("asyncNuxtStorage", {
45
43
  asyncContext: true,
46
44
  AsyncLocalStorage
47
45
  });
@@ -79,7 +77,6 @@ function tryUseNuxt() {
79
77
  function runWithNuxtContext(nuxt, fn) {
80
78
  return asyncNuxtStorage.call(nuxt, fn);
81
79
  }
82
-
83
80
  //#endregion
84
81
  //#region src/compatibility.ts
85
82
  const SEMANTIC_VERSION_RE = /-\d+\.[0-9a-f]+/;
@@ -176,12 +173,11 @@ function getNuxtVersion(nuxt = useNuxt()) {
176
173
  if (typeof rawVersion !== "string") throw new TypeError("Cannot determine nuxt version! Is current instance passed?");
177
174
  return rawVersion.replace(NUXT_VERSION_RE, "");
178
175
  }
179
-
180
176
  //#endregion
181
177
  //#region src/module/define.ts
182
178
  function defineNuxtModule(definition) {
183
179
  if (definition) return _defineNuxtModule(definition);
184
- return { with: (definition$1) => _defineNuxtModule(definition$1) };
180
+ return { with: (definition) => _defineNuxtModule(definition) };
185
181
  }
186
182
  function _defineNuxtModule(definition) {
187
183
  if (typeof definition === "function") return _defineNuxtModule({ setup: definition });
@@ -220,12 +216,19 @@ function _defineNuxtModule(definition) {
220
216
  }
221
217
  const _options = await getOptions(inlineOptions, nuxt);
222
218
  if (module.hooks) nuxt.hooks.addHooks(module.hooks);
219
+ const moduleName = uniqueKey || module.meta.name || "<no name>";
220
+ nuxt._perf?.startPhase(`module:${moduleName}`);
223
221
  const start = performance.now();
224
- const res = await module.setup?.call(null, _options, nuxt) ?? {};
222
+ let res = {};
223
+ try {
224
+ res = await module.setup?.call(null, _options, nuxt) ?? {};
225
+ } finally {
226
+ nuxt._perf?.endPhase(`module:${moduleName}`);
227
+ }
225
228
  const perf = performance.now() - start;
226
229
  const setupTime = Math.round(perf * 100) / 100;
227
- if (setupTime > 5e3 && uniqueKey !== "@nuxt/telemetry") logger.warn(`Slow module \`${uniqueKey || "<no name>"}\` took \`${setupTime}ms\` to setup.`);
228
- else if (nuxt.options.debug && nuxt.options.debug.modules) logger.info(`Module \`${uniqueKey || "<no name>"}\` took \`${setupTime}ms\` to setup.`);
230
+ if (setupTime > 5e3 && uniqueKey !== "@nuxt/telemetry") logger.warn(`Slow module \`${moduleName}\` took \`${setupTime}ms\` to setup.`);
231
+ else if (nuxt.options.debug && nuxt.options.debug.modules) logger.info(`Module \`${moduleName}\` took \`${setupTime}ms\` to setup.`);
229
232
  if (res === false) return false;
230
233
  return defu(res, { timings: { setup: setupTime } });
231
234
  }
@@ -236,7 +239,6 @@ function _defineNuxtModule(definition) {
236
239
  normalizedModule.onUpgrade = module.onUpgrade;
237
240
  return normalizedModule;
238
241
  }
239
-
240
242
  //#endregion
241
243
  //#region src/internal/trace.ts
242
244
  const distURL = import.meta.url.replace(/\/dist\/.*$/, "/");
@@ -257,7 +259,6 @@ function warn(warning) {
257
259
  warnings.add(warning);
258
260
  }
259
261
  }
260
-
261
262
  //#endregion
262
263
  //#region src/layers.ts
263
264
  const layerMap = /* @__PURE__ */ new WeakMap();
@@ -297,7 +298,6 @@ function getLayerDirectories(nuxt = useNuxt()) {
297
298
  function withTrailingSlash$2(dir) {
298
299
  return dir.replace(/[^/]$/, "$&/");
299
300
  }
300
-
301
301
  //#endregion
302
302
  //#region src/ignore.ts
303
303
  function createIsIgnored(nuxt = tryUseNuxt()) {
@@ -342,17 +342,16 @@ function resolveIgnorePatterns(relativePath) {
342
342
  */
343
343
  function resolveGroupSyntax(group) {
344
344
  let groups = [group];
345
- while (groups.some((group$1) => group$1.includes("{"))) groups = groups.flatMap((group$1) => {
346
- const [head, ...tail] = group$1.split("{");
345
+ while (groups.some((group) => group.includes("{"))) groups = groups.flatMap((group) => {
346
+ const [head, ...tail] = group.split("{");
347
347
  if (tail.length) {
348
348
  const [body = "", ...rest] = tail.join("{").split("}");
349
349
  return body.split(",").map((part) => `${head}${part}${rest.join("")}`);
350
350
  }
351
- return group$1;
351
+ return group;
352
352
  });
353
353
  return groups;
354
354
  }
355
-
356
355
  //#endregion
357
356
  //#region src/utils.ts
358
357
  /** @since 3.9.0 */
@@ -371,7 +370,6 @@ function filterInPlace(array, predicate) {
371
370
  }
372
371
  const MODE_RE = /\.(server|client)(\.\w+)*$/;
373
372
  const distDirURL = new URL(".", import.meta.url);
374
-
375
373
  //#endregion
376
374
  //#region src/resolve.ts
377
375
  /**
@@ -470,8 +468,8 @@ async function _resolvePathGranularly(path, opts = { type: "file" }) {
470
468
  const _path = path;
471
469
  path = normalize(path);
472
470
  if (isAbsolute(path)) {
473
- const res$1 = await _resolvePathType(path, opts);
474
- if (res$1 && res$1.type === opts.type) return res$1;
471
+ const res = await _resolvePathType(path, opts);
472
+ if (res && res.type === opts.type) return res;
475
473
  }
476
474
  const nuxt = tryUseNuxt();
477
475
  const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
@@ -534,7 +532,6 @@ async function resolveFiles(path, pattern, opts = {}) {
534
532
  })) if (!isIgnored(p)) files.push(p);
535
533
  return files.sort();
536
534
  }
537
-
538
535
  //#endregion
539
536
  //#region src/internal/esm.ts
540
537
  function directoryToURL(dir) {
@@ -585,7 +582,6 @@ function tryRequireModule(id, opts) {
585
582
  return requireModule(id, opts);
586
583
  } catch {}
587
584
  }
588
-
589
585
  //#endregion
590
586
  //#region src/module/install.ts
591
587
  const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
@@ -608,7 +604,16 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
608
604
  }
609
605
  nuxt._moduleOptionsFunctions ||= /* @__PURE__ */ new Map();
610
606
  const resolvedModules = [];
611
- const inlineConfigKeys = new Set(await Promise.all([...modulesToInstall].map(([mod]) => typeof mod !== "string" && Promise.resolve(mod.getMeta?.())?.then((r) => r?.configKey))));
607
+ const modulesByMetaName = /* @__PURE__ */ new Map();
608
+ const inlineConfigKeys = new Set(await Promise.all([...modulesToInstall].map(async ([mod]) => {
609
+ if (typeof mod === "string") return;
610
+ const meta = await Promise.resolve(mod.getMeta?.());
611
+ if (meta?.name) modulesByMetaName.set(meta.name, mod);
612
+ if (meta?.configKey) {
613
+ if (meta.configKey !== meta.name) modulesByMetaName.set(meta.configKey, mod);
614
+ return meta.configKey;
615
+ }
616
+ })));
612
617
  let error;
613
618
  const dependencyMap = /* @__PURE__ */ new Map();
614
619
  for (const [key, options] of modulesToInstall) {
@@ -619,7 +624,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
619
624
  const dependencyMeta = await res.nuxtModule.getModuleDependencies?.(nuxt) || {};
620
625
  for (const [name, value] of Object.entries(dependencyMeta)) {
621
626
  if (!value.overrides && !value.defaults && !value.version && value.optional) continue;
622
- const resolvedModule = resolveModuleWithOptions(name, nuxt);
627
+ const resolvedModule = modulesByMetaName.has(name) ? resolveModuleWithOptions(modulesByMetaName.get(name), nuxt) : resolveModuleWithOptions(name, nuxt);
623
628
  const moduleToAttribute = typeof key === "string" ? `\`${key}\`` : "a module in `nuxt.options`";
624
629
  if (!resolvedModule?.module) {
625
630
  const message = `Could not resolve \`${name}\` (specified as a dependency of ${moduleToAttribute}).`;
@@ -628,7 +633,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
628
633
  }
629
634
  if (value.version) {
630
635
  const pkg = await readPackageJSON(name, { from: [res.resolvedModulePath, ...nuxt.options.modulesDir].filter(Boolean) }).catch(() => null);
631
- if (pkg?.version && !semver.satisfies(pkg.version, value.version)) {
636
+ if (pkg?.version && !semver.satisfies(pkg.version, value.version, { includePrerelease: true })) {
632
637
  const message = `Module \`${name}\` version (\`${pkg.version}\`) does not satisfy \`${value.version}\` (requested by ${moduleToAttribute}).`;
633
638
  error = new TypeError(message);
634
639
  }
@@ -662,12 +667,12 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
662
667
  if (error) throw error;
663
668
  for (const { nuxtModule, meta = {}, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions } of resolvedModules) {
664
669
  const configKey = meta.configKey;
665
- const optionsFns = [
670
+ const optionsFns = new Set([
666
671
  ...nuxt._moduleOptionsFunctions.get(moduleToInstall) || [],
667
672
  ...meta?.name ? nuxt._moduleOptionsFunctions.get(meta.name) || [] : [],
668
673
  ...configKey ? nuxt._moduleOptionsFunctions.get(configKey) || [] : []
669
- ];
670
- if (optionsFns.length > 0) {
674
+ ]);
675
+ if (optionsFns.size > 0) {
671
676
  const overrides = [];
672
677
  const defaults = [];
673
678
  for (const fn of optionsFns) {
@@ -867,7 +872,6 @@ async function callModule(nuxt, nuxtModule, moduleOptions = {}, options) {
867
872
  entryPath
868
873
  });
869
874
  }
870
-
871
875
  //#endregion
872
876
  //#region src/module/compatibility.ts
873
877
  function resolveNuxtModuleEntryName(m) {
@@ -908,7 +912,6 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
908
912
  }
909
913
  return false;
910
914
  }
911
-
912
915
  //#endregion
913
916
  //#region src/loader/config.ts
914
917
  const merger = createDefu((obj, key, value) => {
@@ -991,7 +994,7 @@ async function loadNuxtConfig(opts) {
991
994
  });
992
995
  return await applyDefaults(NuxtConfigSchema, nuxtConfig);
993
996
  }
994
- async function loadNuxtSchema(cwd) {
997
+ function loadNuxtSchema(cwd) {
995
998
  const url = directoryToURL(cwd);
996
999
  const urls = [url];
997
1000
  const nuxtPath = resolveModuleURL("nuxt", {
@@ -1002,7 +1005,7 @@ async function loadNuxtSchema(cwd) {
1002
1005
  from: url
1003
1006
  });
1004
1007
  if (nuxtPath) urls.unshift(nuxtPath);
1005
- return await import(resolveModuleURL("@nuxt/schema", {
1008
+ return import(resolveModuleURL("@nuxt/schema", {
1006
1009
  try: true,
1007
1010
  from: urls
1008
1011
  }) ?? "@nuxt/schema").then((r) => r.NuxtConfigSchema);
@@ -1022,7 +1025,6 @@ async function withDefineNuxtConfig(fn) {
1022
1025
  if (!globalSelf[key].count) delete globalSelf[key];
1023
1026
  }
1024
1027
  }
1025
-
1026
1028
  //#endregion
1027
1029
  //#region src/loader/schema.ts
1028
1030
  function extendNuxtSchema(def) {
@@ -1030,37 +1032,34 @@ function extendNuxtSchema(def) {
1030
1032
  schemas.push(typeof def === "function" ? def() : def);
1031
1033
  });
1032
1034
  }
1033
-
1034
1035
  //#endregion
1035
1036
  //#region src/loader/nuxt.ts
1036
1037
  async function loadNuxt(opts) {
1037
1038
  opts.cwd = resolve(opts.cwd || opts.rootDir || ".");
1038
1039
  opts.overrides ||= opts.config || {};
1039
1040
  opts.overrides.dev = !!opts.dev;
1040
- const resolvedPath = ["nuxt-nightly", "nuxt"].reduce((resolvedPath$1, pkg) => {
1041
+ const resolvedPath = ["nuxt-nightly", "nuxt"].reduce((resolvedPath, pkg) => {
1041
1042
  const path = resolveModulePath(pkg, {
1042
1043
  try: true,
1043
1044
  from: [directoryToURL(opts.cwd)]
1044
1045
  });
1045
- return path && path.length > resolvedPath$1.length ? path : resolvedPath$1;
1046
+ return path && path.length > resolvedPath.length ? path : resolvedPath;
1046
1047
  }, "");
1047
1048
  if (!resolvedPath) throw new Error(`Cannot find any nuxt version from ${opts.cwd}`);
1048
- const { loadNuxt: loadNuxt$1 } = await import(pathToFileURL(resolvedPath).href).then((r) => interopDefault(r));
1049
- return await loadNuxt$1(opts);
1049
+ const { loadNuxt } = await import(pathToFileURL(resolvedPath).href).then((r) => interopDefault(r));
1050
+ return await loadNuxt(opts);
1050
1051
  }
1051
1052
  async function buildNuxt(nuxt) {
1052
1053
  const rootURL = directoryToURL(nuxt.options.rootDir);
1053
1054
  const { build } = await tryImportModule("nuxt-nightly", { url: rootURL }) || await importModule("nuxt", { url: rootURL });
1054
1055
  return runWithNuxtContext(nuxt, () => build(nuxt));
1055
1056
  }
1056
-
1057
1057
  //#endregion
1058
1058
  //#region src/head.ts
1059
1059
  function setGlobalHead(head) {
1060
1060
  const nuxt = useNuxt();
1061
1061
  nuxt.options.app.head = defu(head, nuxt.options.app.head);
1062
1062
  }
1063
-
1064
1063
  //#endregion
1065
1064
  //#region src/imports.ts
1066
1065
  function addImports(imports) {
@@ -1078,7 +1077,6 @@ function addImportsSources(presets) {
1078
1077
  for (const preset of toArray(presets)) _presets.push(preset);
1079
1078
  });
1080
1079
  }
1081
-
1082
1080
  //#endregion
1083
1081
  //#region src/nitro.ts
1084
1082
  const HANDLER_METHOD_RE = /\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/;
@@ -1172,7 +1170,7 @@ function addServerImportsDir(dirs, opts = {}) {
1172
1170
  }
1173
1171
  /**
1174
1172
  * Add directories to be scanned by Nitro. It will check for subdirectories,
1175
- * which will be registered just like the `~/server` folder is.
1173
+ * which will be registered just like the `~~/server` folder is.
1176
1174
  */
1177
1175
  function addServerScanDir(dirs, opts = {}) {
1178
1176
  useNuxt().hook("nitro:config", (config) => {
@@ -1180,7 +1178,6 @@ function addServerScanDir(dirs, opts = {}) {
1180
1178
  for (const dir of toArray(dirs)) config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
1181
1179
  });
1182
1180
  }
1183
-
1184
1181
  //#endregion
1185
1182
  //#region src/runtime-config.ts
1186
1183
  /**
@@ -1236,7 +1233,6 @@ function _expandFromEnv(value, env = process.env) {
1236
1233
  return env[key] || match;
1237
1234
  });
1238
1235
  }
1239
-
1240
1236
  //#endregion
1241
1237
  //#region src/build.ts
1242
1238
  const extendWebpackCompatibleConfig = (builder) => (fn, options = {}) => {
@@ -1346,7 +1342,6 @@ function addBuildPlugin(pluginFactory, options) {
1346
1342
  if (pluginFactory.webpack) addWebpackPlugin(pluginFactory.webpack, options);
1347
1343
  if (pluginFactory.rspack) addRspackPlugin(pluginFactory.rspack, options);
1348
1344
  }
1349
-
1350
1345
  //#endregion
1351
1346
  //#region src/components.ts
1352
1347
  /**
@@ -1423,7 +1418,6 @@ function normalizeComponent(opts) {
1423
1418
  ...opts
1424
1419
  };
1425
1420
  }
1426
-
1427
1421
  //#endregion
1428
1422
  //#region src/template.ts
1429
1423
  /**
@@ -1510,7 +1504,7 @@ function normalizeTemplate(template, buildDir) {
1510
1504
  * You can pass a filter within the options to selectively regenerate a subset of templates.
1511
1505
  */
1512
1506
  async function updateTemplates(options) {
1513
- return await tryUseNuxt()?.hooks.callHook("builder:generateApp", options);
1507
+ await tryUseNuxt()?.hooks.callHook("builder:generateApp", options);
1514
1508
  }
1515
1509
  function resolveLayerPaths(dirs, projectBuildDir) {
1516
1510
  const relativeRootDir = relativeWithDot(projectBuildDir, dirs.root);
@@ -1616,22 +1610,22 @@ async function _generateTypes(nuxt) {
1616
1610
  }
1617
1611
  const modulePaths = await resolveNuxtModule(rootDirWithSlash, moduleEntryPaths);
1618
1612
  for (const path of modulePaths) {
1619
- const relative$1 = relativeWithDot(nuxt.options.buildDir, path);
1613
+ const relative = relativeWithDot(nuxt.options.buildDir, path);
1620
1614
  if (!path.includes("node_modules") && path.startsWith(rootDirWithSlash)) {
1621
- include.add(join(relative$1, "runtime"));
1622
- include.add(join(relative$1, "dist/runtime"));
1623
- nodeInclude.add(join(relative$1, "*.*"));
1615
+ include.add(join(relative, "runtime"));
1616
+ include.add(join(relative, "dist/runtime"));
1617
+ nodeInclude.add(join(relative, "*.*"));
1624
1618
  }
1625
- legacyInclude.add(join(relative$1, "runtime"));
1626
- legacyInclude.add(join(relative$1, "dist/runtime"));
1627
- nodeExclude.add(join(relative$1, "runtime"));
1628
- nodeExclude.add(join(relative$1, "dist/runtime"));
1629
- exclude.add(join(relative$1, "runtime/server"));
1630
- exclude.add(join(relative$1, "dist/runtime/server"));
1631
- exclude.add(join(relative$1, "*.*"));
1632
- exclude.add(join(relative$1, "dist/*.*"));
1633
- legacyExclude.add(join(relative$1, "runtime/server"));
1634
- legacyExclude.add(join(relative$1, "dist/runtime/server"));
1619
+ legacyInclude.add(join(relative, "runtime"));
1620
+ legacyInclude.add(join(relative, "dist/runtime"));
1621
+ nodeExclude.add(join(relative, "runtime"));
1622
+ nodeExclude.add(join(relative, "dist/runtime"));
1623
+ exclude.add(join(relative, "runtime/server"));
1624
+ exclude.add(join(relative, "dist/runtime/server"));
1625
+ exclude.add(join(relative, "*.*"));
1626
+ exclude.add(join(relative, "dist/*.*"));
1627
+ legacyExclude.add(join(relative, "runtime/server"));
1628
+ legacyExclude.add(join(relative, "dist/runtime/server"));
1635
1629
  }
1636
1630
  const nestedModulesDirs = [];
1637
1631
  for (const dir of [...nuxt.options.modulesDir].sort()) {
@@ -1799,18 +1793,18 @@ async function _generateTypes(nuxt) {
1799
1793
  include: [...tsConfig.include, ...legacyInclude],
1800
1794
  exclude: [...legacyExclude]
1801
1795
  });
1802
- async function resolveConfig(tsConfig$1) {
1803
- for (const alias in tsConfig$1.compilerOptions.paths) {
1804
- const paths = tsConfig$1.compilerOptions.paths[alias];
1805
- tsConfig$1.compilerOptions.paths[alias] = [...new Set(await Promise.all(paths.map(async (path) => {
1796
+ async function resolveConfig(tsConfig) {
1797
+ for (const alias in tsConfig.compilerOptions.paths) {
1798
+ const paths = tsConfig.compilerOptions.paths[alias];
1799
+ tsConfig.compilerOptions.paths[alias] = [...new Set(await Promise.all(paths.map(async (path) => {
1806
1800
  if (!isAbsolute(path)) return path;
1807
1801
  const stats = await promises.stat(path).catch(() => null);
1808
1802
  return relativeWithDot(nuxt.options.buildDir, stats?.isFile() ? path.replace(EXTENSION_RE, "") : path);
1809
1803
  })))];
1810
1804
  }
1811
- sortTsPaths(tsConfig$1.compilerOptions.paths);
1812
- tsConfig$1.include = [...new Set(tsConfig$1.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
1813
- tsConfig$1.exclude = [...new Set(tsConfig$1.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
1805
+ sortTsPaths(tsConfig.compilerOptions.paths);
1806
+ tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
1807
+ tsConfig.exclude = [...new Set(tsConfig.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
1814
1808
  }
1815
1809
  await Promise.all([
1816
1810
  resolveConfig(tsConfig),
@@ -1819,20 +1813,14 @@ async function _generateTypes(nuxt) {
1819
1813
  resolveConfig(legacyTsConfig)
1820
1814
  ]);
1821
1815
  const declaration = [
1822
- ...references.map((ref) => {
1823
- if ("path" in ref && isAbsolute(ref.path)) ref.path = relative(nuxt.options.buildDir, ref.path);
1824
- return `/// <reference ${renderAttrs(ref)} />`;
1825
- }),
1816
+ ...references.map((ref) => renderReference(ref, nuxt.options.buildDir)),
1826
1817
  ...declarations,
1827
1818
  "",
1828
1819
  "export {}",
1829
1820
  ""
1830
1821
  ].join("\n");
1831
1822
  const nodeDeclaration = [
1832
- ...nodeReferences.map((ref) => {
1833
- if ("path" in ref && isAbsolute(ref.path)) ref.path = relative(nuxt.options.buildDir, ref.path);
1834
- return `/// <reference ${renderAttrs(ref)} />`;
1835
- }),
1823
+ ...nodeReferences.map((ref) => renderReference(ref, nuxt.options.buildDir)),
1836
1824
  "",
1837
1825
  "export {}",
1838
1826
  ""
@@ -1841,10 +1829,7 @@ async function _generateTypes(nuxt) {
1841
1829
  declaration,
1842
1830
  sharedTsConfig,
1843
1831
  sharedDeclaration: [
1844
- ...sharedReferences.map((ref) => {
1845
- if ("path" in ref && isAbsolute(ref.path)) ref.path = relative(nuxt.options.buildDir, ref.path);
1846
- return `/// <reference ${renderAttrs(ref)} />`;
1847
- }),
1832
+ ...sharedReferences.map((ref) => renderReference(ref, nuxt.options.buildDir)),
1848
1833
  "",
1849
1834
  "export {}",
1850
1835
  ""
@@ -1882,13 +1867,8 @@ function sortTsPaths(paths) {
1882
1867
  paths[pathKey] = pathValue;
1883
1868
  }
1884
1869
  }
1885
- function renderAttrs(obj) {
1886
- const attrs = [];
1887
- for (const key in obj) attrs.push(renderAttr(key, obj[key]));
1888
- return attrs.join(" ");
1889
- }
1890
- function renderAttr(key, value) {
1891
- return value ? `${key}="${value}"` : "";
1870
+ function renderReference(ref, baseDir) {
1871
+ return `/// <reference ${"path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`} />`;
1892
1872
  }
1893
1873
  const RELATIVE_WITH_DOT_RE = /^([^.])/;
1894
1874
  function relativeWithDot(from, to) {
@@ -1897,7 +1877,6 @@ function relativeWithDot(from, to) {
1897
1877
  function withTrailingSlash$1(dir) {
1898
1878
  return dir.replace(/[^/]$/, "$&/");
1899
1879
  }
1900
-
1901
1880
  //#endregion
1902
1881
  //#region src/layout.ts
1903
1882
  const LAYOUT_RE = /["']/g;
@@ -1923,7 +1902,6 @@ const strippedAtAliases = {
1923
1902
  "@": "",
1924
1903
  "@@": ""
1925
1904
  };
1926
-
1927
1905
  //#endregion
1928
1906
  //#region src/pages.ts
1929
1907
  function extendPages(cb) {
@@ -1952,7 +1930,6 @@ function addRouteMiddleware(input, options = {}) {
1952
1930
  }
1953
1931
  });
1954
1932
  }
1955
-
1956
1933
  //#endregion
1957
1934
  //#region src/plugin.ts
1958
1935
  /**
@@ -2000,6 +1977,5 @@ function addPluginTemplate(plugin, opts = {}) {
2000
1977
  src: addTemplate(plugin).dst
2001
1978
  }, opts);
2002
1979
  }
2003
-
2004
1980
  //#endregion
2005
- export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
1981
+ export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "4.3.0",
3
+ "version": "4.4.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -28,30 +28,30 @@
28
28
  "ignore": "^7.0.5",
29
29
  "jiti": "^2.6.1",
30
30
  "klona": "^2.0.6",
31
- "mlly": "^1.8.0",
31
+ "mlly": "^1.8.1",
32
32
  "ohash": "^2.0.11",
33
33
  "pathe": "^2.0.3",
34
34
  "pkg-types": "^2.3.0",
35
- "rc9": "^2.1.2",
35
+ "rc9": "^3.0.0",
36
36
  "scule": "^1.3.0",
37
- "semver": "^7.7.3",
37
+ "semver": "^7.7.4",
38
38
  "tinyglobby": "^0.2.15",
39
39
  "ufo": "^1.6.3",
40
40
  "unctx": "^2.5.0",
41
41
  "untyped": "^2.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@rspack/core": "1.7.2",
44
+ "@rspack/core": "1.7.8",
45
45
  "@types/semver": "7.7.1",
46
- "hookable": "5.5.3",
47
- "nitro": "3.0.1-alpha.1",
46
+ "hookable": "6.0.1",
47
+ "nitro": "3.0.1-alpha.2",
48
48
  "nitropack": "2.13.1",
49
- "obuild": "0.4.14",
50
- "unimport": "5.6.0",
49
+ "obuild": "0.4.32",
50
+ "unimport": "6.0.1",
51
51
  "vite": "7.3.1",
52
- "vitest": "3.2.4",
53
- "webpack": "5.104.1",
54
- "@nuxt/schema": "4.3.0"
52
+ "vitest": "4.0.18",
53
+ "webpack": "5.105.4",
54
+ "@nuxt/schema": "4.4.1"
55
55
  },
56
56
  "engines": {
57
57
  "node": ">=18.12.0"