@nuxt/kit-nightly 4.1.4-29330724.5589a44a → 4.1.4-29331062.94e6fbb7

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 +30 -14
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -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-29330724.5589a44a",
3
+ "version": "4.1.4-29331062.94e6fbb7",
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-29330724.5589a44a",
50
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.4-29331062.94e6fbb7",
51
51
  "@rspack/core": "1.5.8",
52
52
  "@types/semver": "7.7.1",
53
53
  "hookable": "5.5.3",