@nuxt/kit-nightly 4.1.4-29331135.2311b272 → 4.2.0-29331188.9ad35781

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
@@ -501,6 +501,8 @@ interface ResolveModuleOptions {
501
501
  /** @deprecated use `url` with URLs pointing at a file - never a directory */
502
502
  paths?: string | string[];
503
503
  url?: URL | URL[];
504
+ /** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
505
+ extensions?: string[];
504
506
  }
505
507
  declare function directoryToURL(dir: string): URL;
506
508
  /**
package/dist/index.d.ts CHANGED
@@ -501,6 +501,8 @@ interface ResolveModuleOptions {
501
501
  /** @deprecated use `url` with URLs pointing at a file - never a directory */
502
502
  paths?: string | string[];
503
503
  url?: URL | URL[];
504
+ /** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
505
+ extensions?: string[];
504
506
  }
505
507
  declare function directoryToURL(dir: string): URL;
506
508
  /**
package/dist/index.mjs CHANGED
@@ -235,7 +235,7 @@ function resolveModule(id, options) {
235
235
  return resolveModulePath(id, {
236
236
  // eslint-disable-next-line @typescript-eslint/no-deprecated
237
237
  from: options?.url ?? options?.paths ?? [import.meta.url],
238
- extensions: [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
238
+ extensions: options?.extensions ?? [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
239
239
  });
240
240
  }
241
241
  async function importModule(id, opts) {
@@ -843,20 +843,19 @@ async function loadNuxtConfig(opts) {
843
843
  cwd: opts.cwd || process.cwd()
844
844
  })).map((d) => d.endsWith("/") ? d.substring(0, d.length - 1) : d).sort((a, b) => b.localeCompare(a));
845
845
  opts.overrides = defu$1(opts.overrides, { _extends: localLayers });
846
- const globalSelf = globalThis;
847
- globalSelf.defineNuxtConfig = (c) => c;
848
- const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await loadConfig({
849
- name: "nuxt",
850
- configFile: "nuxt.config",
851
- rcFile: ".nuxtrc",
852
- extend: { extendKey: ["theme", "_extends", "extends"] },
853
- dotenv: true,
854
- globalRc: true,
855
- // @ts-expect-error TODO: fix type in c12, it should accept createDefu directly
856
- merger,
857
- ...opts
858
- });
859
- delete globalSelf.defineNuxtConfig;
846
+ const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await withDefineNuxtConfig(
847
+ () => loadConfig({
848
+ name: "nuxt",
849
+ configFile: "nuxt.config",
850
+ rcFile: ".nuxtrc",
851
+ extend: { extendKey: ["theme", "_extends", "extends"] },
852
+ dotenv: true,
853
+ globalRc: true,
854
+ // @ts-expect-error TODO: fix type in c12, it should accept createDefu directly
855
+ merger,
856
+ ...opts
857
+ })
858
+ );
860
859
  nuxtConfig.rootDir ||= cwd;
861
860
  nuxtConfig._nuxtConfigFile = configFile;
862
861
  nuxtConfig._nuxtConfigFiles = [configFile];
@@ -924,6 +923,23 @@ async function loadNuxtSchema(cwd) {
924
923
  const schemaPath = resolveModuleURL("@nuxt/schema", { try: true, from: urls }) ?? "@nuxt/schema";
925
924
  return await import(schemaPath).then((r) => r.NuxtConfigSchema);
926
925
  }
926
+ async function withDefineNuxtConfig(fn) {
927
+ const key = "defineNuxtConfig";
928
+ const globalSelf = globalThis;
929
+ if (!globalSelf[key]) {
930
+ globalSelf[key] = (c) => c;
931
+ globalSelf[key].count = 0;
932
+ }
933
+ globalSelf[key].count++;
934
+ try {
935
+ return await fn();
936
+ } finally {
937
+ globalSelf[key].count--;
938
+ if (!globalSelf[key].count) {
939
+ delete globalSelf[key];
940
+ }
941
+ }
942
+ }
927
943
 
928
944
  function extendNuxtSchema(def) {
929
945
  const nuxt = useNuxt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit-nightly",
3
- "version": "4.1.4-29331135.2311b272",
3
+ "version": "4.2.0-29331188.9ad35781",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -47,7 +47,7 @@
47
47
  "untyped": "^2.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.4-29331135.2311b272",
50
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29331188.9ad35781",
51
51
  "@rspack/core": "1.5.8",
52
52
  "@types/semver": "7.7.1",
53
53
  "hookable": "5.5.3",