@nuxt/kit 3.15.3 → 3.15.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.
Files changed (2) hide show
  1. package/dist/index.mjs +54 -45
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import { globby } from 'globby';
16
16
  import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
17
17
  import ignore from 'ignore';
18
18
  import { loadConfig } from 'c12';
19
- import { NuxtConfigSchema } from '@nuxt/schema';
19
+ import { isWindows } from 'std-env';
20
20
  import process$1 from 'node:process';
21
21
  import destr from 'destr';
22
22
  import { snakeCase, kebabCase, pascalCase } from 'scule';
@@ -24,7 +24,6 @@ import { klona } from 'klona';
24
24
  import { hash } from 'ohash';
25
25
  import { gte } from 'semver';
26
26
  import { isAbsolute as isAbsolute$1 } from 'node:path';
27
- import { isWindows } from 'std-env';
28
27
 
29
28
  const logger = consola;
30
29
  function useLogger(tag, options = {}) {
@@ -2544,13 +2543,44 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
2544
2543
  return false;
2545
2544
  }
2546
2545
 
2547
- const layerSchemaKeys = ["future", "srcDir", "rootDir", "serverDir", "dir"];
2548
- const layerSchema = /* @__PURE__ */ Object.create(null);
2549
- for (const key of layerSchemaKeys) {
2550
- if (key in NuxtConfigSchema) {
2551
- layerSchema[key] = NuxtConfigSchema[key];
2546
+ async function tryResolveModule(id, url = import.meta.url) {
2547
+ try {
2548
+ return await resolvePath$1(id, { url });
2549
+ } catch {
2550
+ }
2551
+ }
2552
+ function resolveModule(id, options) {
2553
+ return resolvePathSync(id, { url: options?.paths ?? [import.meta.url] });
2554
+ }
2555
+ async function importModule(id, opts) {
2556
+ const resolvedPath = await resolveModule(id, opts);
2557
+ return import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
2558
+ }
2559
+ function tryImportModule(id, opts) {
2560
+ try {
2561
+ return importModule(id, opts).catch(() => void 0);
2562
+ } catch {
2563
+ }
2564
+ }
2565
+ const warnings = /* @__PURE__ */ new Set();
2566
+ function requireModule(id, opts) {
2567
+ if (!warnings.has(id)) {
2568
+ console.warn("[@nuxt/kit] `requireModule` is deprecated. Please use `importModule` instead.");
2569
+ warnings.add(id);
2570
+ }
2571
+ const resolvedPath = resolveModule(id, opts);
2572
+ const jiti = createJiti(import.meta.url, {
2573
+ interopDefault: opts?.interopDefault !== false
2574
+ });
2575
+ return jiti(pathToFileURL(resolvedPath).href);
2576
+ }
2577
+ function tryRequireModule(id, opts) {
2578
+ try {
2579
+ return requireModule(id, opts);
2580
+ } catch {
2552
2581
  }
2553
2582
  }
2583
+
2554
2584
  async function loadNuxtConfig(opts) {
2555
2585
  opts.overrides = defu$1(opts.overrides, {
2556
2586
  _extends: await globby("layers/*", {
@@ -2578,6 +2608,14 @@ async function loadNuxtConfig(opts) {
2578
2608
  if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && nuxtConfig.future?.compatibilityVersion === 4 && existsSync(defaultBuildDir)) {
2579
2609
  nuxtConfig.buildDir = join(nuxtConfig.rootDir, "node_modules/.cache/nuxt/.nuxt");
2580
2610
  }
2611
+ const NuxtConfigSchema = await loadNuxtSchema(nuxtConfig.rootDir || cwd || process.cwd());
2612
+ const layerSchemaKeys = ["future", "srcDir", "rootDir", "serverDir", "dir"];
2613
+ const layerSchema = /* @__PURE__ */ Object.create(null);
2614
+ for (const key of layerSchemaKeys) {
2615
+ if (key in NuxtConfigSchema) {
2616
+ layerSchema[key] = NuxtConfigSchema[key];
2617
+ }
2618
+ }
2581
2619
  const _layers = [];
2582
2620
  const processedLayers = /* @__PURE__ */ new Set();
2583
2621
  for (const layer of layers) {
@@ -2605,6 +2643,15 @@ async function loadNuxtConfig(opts) {
2605
2643
  }
2606
2644
  return await applyDefaults(NuxtConfigSchema, nuxtConfig);
2607
2645
  }
2646
+ async function loadNuxtSchema(cwd) {
2647
+ const paths = [cwd];
2648
+ const nuxtPath = await tryResolveModule("nuxt", cwd) ?? await tryResolveModule("nuxt-nightly", cwd);
2649
+ if (nuxtPath) {
2650
+ paths.unshift(nuxtPath);
2651
+ }
2652
+ const schemaPath = await tryResolveModule("@nuxt/schema", paths) ?? "@nuxt/schema";
2653
+ return await (isWindows ? import(pathToFileURL(schemaPath).href) : import(schemaPath)).then((r) => r.NuxtConfigSchema);
2654
+ }
2608
2655
 
2609
2656
  function extendNuxtSchema(def) {
2610
2657
  const nuxt = useNuxt();
@@ -2613,44 +2660,6 @@ function extendNuxtSchema(def) {
2613
2660
  });
2614
2661
  }
2615
2662
 
2616
- async function tryResolveModule(id, url = import.meta.url) {
2617
- try {
2618
- return await resolvePath$1(id, { url });
2619
- } catch {
2620
- }
2621
- }
2622
- function resolveModule(id, options) {
2623
- return resolvePathSync(id, { url: options?.paths ?? [import.meta.url] });
2624
- }
2625
- async function importModule(id, opts) {
2626
- const resolvedPath = await resolveModule(id, opts);
2627
- return import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
2628
- }
2629
- function tryImportModule(id, opts) {
2630
- try {
2631
- return importModule(id, opts).catch(() => void 0);
2632
- } catch {
2633
- }
2634
- }
2635
- const warnings = /* @__PURE__ */ new Set();
2636
- function requireModule(id, opts) {
2637
- if (!warnings.has(id)) {
2638
- console.warn("[@nuxt/kit] `requireModule` is deprecated. Please use `importModule` instead.");
2639
- warnings.add(id);
2640
- }
2641
- const resolvedPath = resolveModule(id, opts);
2642
- const jiti = createJiti(import.meta.url, {
2643
- interopDefault: opts?.interopDefault !== false
2644
- });
2645
- return jiti(pathToFileURL(resolvedPath).href);
2646
- }
2647
- function tryRequireModule(id, opts) {
2648
- try {
2649
- return requireModule(id, opts);
2650
- } catch {
2651
- }
2652
- }
2653
-
2654
2663
  async function loadNuxt(opts) {
2655
2664
  opts.cwd = opts.cwd || opts.rootDir;
2656
2665
  opts.overrides ||= opts.config || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.15.3",
3
+ "version": "3.15.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -42,8 +42,7 @@
42
42
  "ufo": "^1.5.4",
43
43
  "unctx": "^2.4.1",
44
44
  "unimport": "^4.0.0",
45
- "untyped": "^1.5.2",
46
- "@nuxt/schema": "3.15.3"
45
+ "untyped": "^1.5.2"
47
46
  },
48
47
  "devDependencies": {
49
48
  "@rspack/core": "1.2.2",
@@ -54,7 +53,8 @@
54
53
  "unbuild": "latest",
55
54
  "vite": "6.0.11",
56
55
  "vitest": "3.0.4",
57
- "webpack": "5.96.1"
56
+ "webpack": "5.96.1",
57
+ "@nuxt/schema": "3.15.4"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=18.12.0"