@nuxt/kit 3.21.0 → 3.21.2

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,4 +1,4 @@
1
- import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
1
+ import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, ResolvedNuxtTemplate, NuxtTypeTemplate } from '@nuxt/schema';
2
2
  import { LoadConfigOptions } from 'c12';
3
3
  import { Import, InlinePreset } from 'unimport';
4
4
  import { WebpackPluginInstance, Configuration } from 'webpack';
@@ -489,7 +489,7 @@ declare function addServerImportsDir(dirs: string | string[], opts?: {
489
489
  }): void;
490
490
  /**
491
491
  * Add directories to be scanned by Nitro. It will check for subdirectories,
492
- * which will be registered just like the `~/server` folder is.
492
+ * which will be registered just like the `~~/server` folder is.
493
493
  */
494
494
  declare function addServerScanDir(dirs: string | string[], opts?: {
495
495
  prepend?: boolean;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
1
+ import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, ResolvedNuxtTemplate, NuxtTypeTemplate } from '@nuxt/schema';
2
2
  import { LoadConfigOptions } from 'c12';
3
3
  import { Import, InlinePreset } from 'unimport';
4
4
  import { WebpackPluginInstance, Configuration } from 'webpack';
@@ -489,7 +489,7 @@ declare function addServerImportsDir(dirs: string | string[], opts?: {
489
489
  }): void;
490
490
  /**
491
491
  * Add directories to be scanned by Nitro. It will check for subdirectories,
492
- * which will be registered just like the `~/server` folder is.
492
+ * which will be registered just like the `~~/server` folder is.
493
493
  */
494
494
  declare function addServerScanDir(dirs: string | string[], opts?: {
495
495
  prepend?: boolean;
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { applyDefaults } from 'untyped';
5
5
  import { dirname, resolve, relative, join, normalize, isAbsolute, basename, parse } from 'pathe';
6
6
  import { consola } from 'consola';
7
7
  import { AsyncLocalStorage } from 'node:async_hooks';
8
- import { getContext, createContext } from 'unctx';
8
+ import { getContext } from 'unctx';
9
9
  import satisfies from 'semver/functions/satisfies.js';
10
10
  import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
11
11
  import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
@@ -34,7 +34,7 @@ function useLogger(tag, options = {}) {
34
34
  }
35
35
 
36
36
  const nuxtCtx = getContext("nuxt");
37
- const asyncNuxtStorage = createContext({
37
+ const asyncNuxtStorage = getContext("asyncNuxtStorage", {
38
38
  asyncContext: true,
39
39
  AsyncLocalStorage
40
40
  });
@@ -2576,8 +2576,23 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2576
2576
  }
2577
2577
  nuxt._moduleOptionsFunctions ||= /* @__PURE__ */ new Map();
2578
2578
  const resolvedModules = [];
2579
+ const modulesByMetaName = /* @__PURE__ */ new Map();
2579
2580
  const inlineConfigKeys = new Set(
2580
- await Promise.all([...modulesToInstall].map(([mod]) => typeof mod !== "string" && Promise.resolve(mod.getMeta?.())?.then((r) => r?.configKey)))
2581
+ await Promise.all([...modulesToInstall].map(async ([mod]) => {
2582
+ if (typeof mod === "string") {
2583
+ return;
2584
+ }
2585
+ const meta = await Promise.resolve(mod.getMeta?.());
2586
+ if (meta?.name) {
2587
+ modulesByMetaName.set(meta.name, mod);
2588
+ }
2589
+ if (meta?.configKey) {
2590
+ if (meta.configKey !== meta.name) {
2591
+ modulesByMetaName.set(meta.configKey, mod);
2592
+ }
2593
+ return meta.configKey;
2594
+ }
2595
+ }))
2581
2596
  );
2582
2597
  let error;
2583
2598
  const dependencyMap = /* @__PURE__ */ new Map();
@@ -2593,7 +2608,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2593
2608
  if (!value.overrides && !value.defaults && !value.version && value.optional) {
2594
2609
  continue;
2595
2610
  }
2596
- const resolvedModule = resolveModuleWithOptions(name, nuxt);
2611
+ const resolvedModule = modulesByMetaName.has(name) ? resolveModuleWithOptions(modulesByMetaName.get(name), nuxt) : resolveModuleWithOptions(name, nuxt);
2597
2612
  const moduleToAttribute = typeof key === "string" ? `\`${key}\`` : "a module in `nuxt.options`";
2598
2613
  if (!resolvedModule?.module) {
2599
2614
  const message = `Could not resolve \`${name}\` (specified as a dependency of ${moduleToAttribute}).`;
@@ -2603,7 +2618,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2603
2618
  if (value.version) {
2604
2619
  const resolvePaths = [res.resolvedModulePath, ...nuxt.options.modulesDir].filter(Boolean);
2605
2620
  const pkg = await readPackageJSON(name, { from: resolvePaths }).catch(() => null);
2606
- if (pkg?.version && !semver.satisfies(pkg.version, value.version)) {
2621
+ if (pkg?.version && !semver.satisfies(pkg.version, value.version, { includePrerelease: true })) {
2607
2622
  const message = `Module \`${name}\` version (\`${pkg.version}\`) does not satisfy \`${value.version}\` (requested by ${moduleToAttribute}).`;
2608
2623
  error = new TypeError(message);
2609
2624
  }
@@ -2643,15 +2658,15 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2643
2658
  if (error) {
2644
2659
  throw error;
2645
2660
  }
2646
- for (const { nuxtModule, meta = {}, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions: inlineOptions2 } of resolvedModules) {
2661
+ for (const { nuxtModule, meta = {}, moduleToInstall, buildTimeModuleMeta, resolvedModulePath, inlineOptions } of resolvedModules) {
2647
2662
  const configKey = meta.configKey;
2648
- const optionsFns = [
2663
+ const optionsFns = /* @__PURE__ */ new Set([
2649
2664
  ...nuxt._moduleOptionsFunctions.get(moduleToInstall) || [],
2650
2665
  ...meta?.name ? nuxt._moduleOptionsFunctions.get(meta.name) || [] : [],
2651
2666
  // TODO: consider dropping options functions keyed by config key
2652
2667
  ...configKey ? nuxt._moduleOptionsFunctions.get(configKey) || [] : []
2653
- ];
2654
- if (optionsFns.length > 0) {
2668
+ ]);
2669
+ if (optionsFns.size > 0) {
2655
2670
  const overrides = [];
2656
2671
  const defaults = [];
2657
2672
  for (const fn of optionsFns) {
@@ -2665,10 +2680,10 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2665
2680
  }
2666
2681
  const isDisabled = configKey && !ignoredConfigKeys.has(configKey) && nuxt.options[configKey] === false;
2667
2682
  if (!isDisabled) {
2668
- await callLifecycleHooks(nuxtModule, meta, inlineOptions2, nuxt);
2683
+ await callLifecycleHooks(nuxtModule, meta, inlineOptions, nuxt);
2669
2684
  }
2670
2685
  const path = typeof moduleToInstall === "string" ? moduleToInstall : void 0;
2671
- await callModule(nuxt, nuxtModule, inlineOptions2, {
2686
+ await callModule(nuxt, nuxtModule, inlineOptions, {
2672
2687
  meta: defu({ disabled: isDisabled }, meta, buildTimeModuleMeta),
2673
2688
  nameOrPath: path,
2674
2689
  modulePath: resolvedModulePath || path,
@@ -2677,7 +2692,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
2677
2692
  }
2678
2693
  delete nuxt._moduleOptionsFunctions;
2679
2694
  }
2680
- async function installModule(moduleToInstall, inlineOptions2, nuxt = useNuxt()) {
2695
+ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2681
2696
  const { nuxtModule, buildTimeModuleMeta, resolvedModulePath } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
2682
2697
  const localLayerModuleDirs = [];
2683
2698
  for (const dirs of getLayerDirectories(nuxt)) {
@@ -2686,7 +2701,7 @@ async function installModule(moduleToInstall, inlineOptions2, nuxt = useNuxt())
2686
2701
  }
2687
2702
  }
2688
2703
  const meta = await nuxtModule.getMeta?.();
2689
- let mergedOptions = inlineOptions2;
2704
+ let mergedOptions = inlineOptions;
2690
2705
  const configKey = meta?.configKey;
2691
2706
  if (configKey && nuxt._moduleOptionsFunctions) {
2692
2707
  const optionsFns = [
@@ -2701,7 +2716,7 @@ async function installModule(moduleToInstall, inlineOptions2, nuxt = useNuxt())
2701
2716
  overrides.push(options.overrides);
2702
2717
  defaults.push(options.defaults);
2703
2718
  }
2704
- mergedOptions = defu(inlineOptions2, ...overrides, nuxt.options[configKey], ...defaults);
2719
+ mergedOptions = defu(inlineOptions, ...overrides, nuxt.options[configKey], ...defaults);
2705
2720
  nuxt.options[configKey] = mergedOptions;
2706
2721
  }
2707
2722
  }
@@ -2798,7 +2813,7 @@ const normalizeModuleTranspilePath = (p) => {
2798
2813
  return getDirectory(p).split("node_modules/").pop();
2799
2814
  };
2800
2815
  const MissingModuleMatcher = /Cannot find module\s+['"]?([^'")\s]+)['"]?/i;
2801
- async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions2, nuxt = useNuxt()) {
2816
+ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions, nuxt = useNuxt()) {
2802
2817
  if (!meta.name || !meta.version) {
2803
2818
  return;
2804
2819
  }
@@ -2811,7 +2826,7 @@ async function callLifecycleHooks(nuxtModule, meta = {}, inlineOptions2, nuxt =
2811
2826
  if (!previousVersion) {
2812
2827
  await nuxtModule.onInstall?.(nuxt);
2813
2828
  } else if (semver.gt(meta.version, previousVersion)) {
2814
- await nuxtModule.onUpgrade?.(nuxt, inlineOptions2, previousVersion);
2829
+ await nuxtModule.onUpgrade?.(nuxt, inlineOptions, previousVersion);
2815
2830
  }
2816
2831
  if (previousVersion !== meta.version) {
2817
2832
  update(
@@ -2829,7 +2844,7 @@ async function callModule(nuxt, nuxtModule, moduleOptions = {}, options) {
2829
2844
  const modulePath = options.modulePath;
2830
2845
  const nameOrPath = options.nameOrPath;
2831
2846
  const localLayerModuleDirs = options.localLayerModuleDirs;
2832
- const fn = () => isNuxtMajorVersion(2, nuxt) ? nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : nuxt.options.experimental?.debugModuleMutation && nuxt._asyncLocalStorageModule ? nuxt._asyncLocalStorageModule.run(nuxtModule, () => nuxtModule(moduleOptions, nuxt)) : nuxtModule(moduleOptions, nuxt);
2847
+ const fn = () => isNuxtMajorVersion(2, nuxt) ? nuxtModule.call(nuxt.moduleContainer, moduleOptions, nuxt) : nuxt.options.experimental?.debugModuleMutation && nuxt._asyncLocalStorageModule ? nuxt._asyncLocalStorageModule.run(nuxtModule, () => nuxtModule(moduleOptions, nuxt)) : nuxtModule(moduleOptions, nuxt);
2833
2848
  const res = options.meta.disabled ? false : await fn();
2834
2849
  let entryPath;
2835
2850
  if (typeof modulePath === "string") {
@@ -2981,7 +2996,7 @@ async function loadNuxtConfig(opts) {
2981
2996
  }
2982
2997
  return await applyDefaults(NuxtConfigSchema, nuxtConfig);
2983
2998
  }
2984
- async function loadNuxtSchema(cwd) {
2999
+ function loadNuxtSchema(cwd) {
2985
3000
  const url = directoryToURL(cwd);
2986
3001
  const urls = [url];
2987
3002
  const nuxtPath = resolveModuleURL("nuxt", { try: true, from: url }) ?? resolveModuleURL("nuxt-nightly", { try: true, from: url });
@@ -2989,7 +3004,7 @@ async function loadNuxtSchema(cwd) {
2989
3004
  urls.unshift(nuxtPath);
2990
3005
  }
2991
3006
  const schemaPath = resolveModuleURL("@nuxt/schema", { try: true, from: urls }) ?? "@nuxt/schema";
2992
- return await import(schemaPath).then((r) => r.NuxtConfigSchema);
3007
+ return import(schemaPath).then((r) => r.NuxtConfigSchema);
2993
3008
  }
2994
3009
  async function withDefineNuxtConfig(fn) {
2995
3010
  const key = "defineNuxtConfig";
@@ -3486,7 +3501,7 @@ function normalizeTemplate(template, buildDir) {
3486
3501
  return template;
3487
3502
  }
3488
3503
  async function updateTemplates(options) {
3489
- return await tryUseNuxt()?.hooks.callHook("builder:generateApp", options);
3504
+ await tryUseNuxt()?.hooks.callHook("builder:generateApp", options);
3490
3505
  }
3491
3506
  const EXTENSION_RE = /\b(?:\.d\.[cm]?ts|\.\w+)$/g;
3492
3507
  const excludedAlias = [/^@vue\/.*$/, /^#internal\/nuxt/];
@@ -3676,12 +3691,7 @@ async function _generateTypes(nuxt) {
3676
3691
  tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
3677
3692
  tsConfig.exclude = [...new Set(tsConfig.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
3678
3693
  const declaration = [
3679
- ...references.map((ref) => {
3680
- if ("path" in ref && isAbsolute(ref.path)) {
3681
- ref.path = relative(nuxt.options.buildDir, ref.path);
3682
- }
3683
- return `/// <reference ${renderAttrs(ref)} />`;
3684
- }),
3694
+ ...references.map((ref) => renderReference(ref, nuxt.options.buildDir)),
3685
3695
  ...declarations,
3686
3696
  "",
3687
3697
  "export {}",
@@ -3713,15 +3723,9 @@ function sortTsPaths(paths) {
3713
3723
  }
3714
3724
  }
3715
3725
  }
3716
- function renderAttrs(obj) {
3717
- const attrs = [];
3718
- for (const key in obj) {
3719
- attrs.push(renderAttr(key, obj[key]));
3720
- }
3721
- return attrs.join(" ");
3722
- }
3723
- function renderAttr(key, value) {
3724
- return value ? `${key}="${value}"` : "";
3726
+ function renderReference(ref, baseDir) {
3727
+ const stuff = "path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`;
3728
+ return `/// <reference ${stuff} />`;
3725
3729
  }
3726
3730
  const RELATIVE_WITH_DOT_RE = /^([^.])/;
3727
3731
  function relativeWithDot(from, to) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.21.0",
3
+ "version": "3.21.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -33,32 +33,32 @@
33
33
  "jiti": "^2.6.1",
34
34
  "klona": "^2.0.6",
35
35
  "knitwork": "^1.3.0",
36
- "mlly": "^1.8.0",
36
+ "mlly": "^1.8.1",
37
37
  "ohash": "^2.0.11",
38
38
  "pathe": "^2.0.3",
39
39
  "pkg-types": "^2.3.0",
40
- "rc9": "^2.1.2",
40
+ "rc9": "^3.0.0",
41
41
  "scule": "^1.3.0",
42
- "semver": "^7.7.3",
42
+ "semver": "^7.7.4",
43
43
  "tinyglobby": "^0.2.15",
44
44
  "ufo": "^1.6.3",
45
45
  "unctx": "^2.5.0",
46
46
  "untyped": "^2.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@rspack/core": "1.7.2",
49
+ "@rspack/core": "1.7.8",
50
50
  "@types/lodash-es": "4.17.12",
51
51
  "@types/semver": "7.7.1",
52
52
  "hookable": "5.5.3",
53
- "lodash-es": "4.17.22",
54
- "nitro": "3.0.1-alpha.1",
53
+ "lodash-es": "4.17.23",
54
+ "nitro": "3.0.1-alpha.2",
55
55
  "nitropack": "2.13.1",
56
56
  "unbuild": "3.6.1",
57
- "unimport": "5.6.0",
57
+ "unimport": "6.0.1",
58
58
  "vite": "7.3.1",
59
- "vitest": "3.2.4",
60
- "webpack": "5.104.1",
61
- "@nuxt/schema": "3.21.0"
59
+ "vitest": "4.0.18",
60
+ "webpack": "5.105.4",
61
+ "@nuxt/schema": "3.21.2"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=18.12.0"