@nuxt/kit-nightly 4.4.3-29608489.ff42fe25 → 4.4.3-29618876.1bd346ee

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 +16 -3
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -605,6 +605,8 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
605
605
  nuxt._moduleOptionsFunctions ||= /* @__PURE__ */ new Map();
606
606
  const resolvedModules = [];
607
607
  const modulesByMetaName = /* @__PURE__ */ new Map();
608
+ const moduleLoadCache = /* @__PURE__ */ new Map();
609
+ for (const [key] of modulesToInstall) moduleLoadCache.set(key, loadNuxtModuleInstance(key, nuxt));
608
610
  const inlineConfigKeys = new Set(await Promise.all([...modulesToInstall].map(async ([mod]) => {
609
611
  if (typeof mod === "string") return;
610
612
  const meta = await Promise.resolve(mod.getMeta?.());
@@ -617,7 +619,7 @@ async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useN
617
619
  let error;
618
620
  const dependencyMap = /* @__PURE__ */ new Map();
619
621
  for (const [key, options] of modulesToInstall) {
620
- const res = await loadNuxtModuleInstance(key, nuxt).catch((err) => {
622
+ const res = await (moduleLoadCache.get(key) || loadNuxtModuleInstance(key, nuxt)).catch((err) => {
621
623
  if (dependencyMap.has(key) && typeof key === "string") err.cause = `Could not resolve \`${key}\` (specified as a dependency of ${dependencyMap.get(key)}).`;
622
624
  throw err;
623
625
  });
@@ -762,6 +764,16 @@ function resolveModuleWithOptions(definition, nuxt) {
762
764
  options
763
765
  };
764
766
  }
767
+ let _jitiCache;
768
+ function getSharedJiti(nuxt) {
769
+ _jitiCache ||= /* @__PURE__ */ new WeakMap();
770
+ let jiti = _jitiCache.get(nuxt);
771
+ if (!jiti) {
772
+ jiti = createJiti(nuxt.options.rootDir, { alias: nuxt.options.alias });
773
+ _jitiCache.set(nuxt, jiti);
774
+ }
775
+ return jiti;
776
+ }
765
777
  async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
766
778
  let buildTimeModuleMeta = {};
767
779
  if (typeof nuxtModule === "function") return {
@@ -769,7 +781,7 @@ async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
769
781
  buildTimeModuleMeta
770
782
  };
771
783
  if (typeof nuxtModule !== "string") throw new TypeError(`Nuxt module should be a function or a string to import. Received: ${nuxtModule}.`);
772
- const jiti = createJiti(nuxt.options.rootDir, { alias: nuxt.options.alias });
784
+ const jiti = getSharedJiti(nuxt);
773
785
  nuxtModule = resolveAlias(nuxtModule, nuxt.options.alias);
774
786
  if (isRelative(nuxtModule)) nuxtModule = resolve(nuxt.options.rootDir, nuxtModule);
775
787
  try {
@@ -926,6 +938,7 @@ async function loadNuxtConfig(opts) {
926
938
  cwd: opts.cwd || process.cwd()
927
939
  })).map((d) => withTrailingSlash(d)).sort((a, b) => b.localeCompare(a));
928
940
  opts.overrides = defu(opts.overrides, { _extends: localLayers });
941
+ const schemaPromise = loadNuxtSchema(opts.cwd || process.cwd());
929
942
  const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await withDefineNuxtConfig(() => loadConfig({
930
943
  name: "nuxt",
931
944
  configFile: "nuxt.config",
@@ -951,7 +964,7 @@ async function loadNuxtConfig(opts) {
951
964
  }
952
965
  const defaultBuildDir = join(nuxtConfig.rootDir, ".nuxt");
953
966
  if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && existsSync(defaultBuildDir)) nuxtConfig.buildDir = join(nuxtConfig.rootDir, "node_modules/.cache/nuxt/.nuxt");
954
- const NuxtConfigSchema = await loadNuxtSchema(nuxtConfig.rootDir || cwd || process.cwd());
967
+ const NuxtConfigSchema = await schemaPromise;
955
968
  const layerSchemaKeys = [
956
969
  "future",
957
970
  "srcDir",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit-nightly",
3
- "version": "4.4.3-29608489.ff42fe25",
3
+ "version": "4.4.3-29618876.1bd346ee",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -41,7 +41,7 @@
41
41
  "untyped": "^2.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.3-29608489.ff42fe25",
44
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.3-29618876.1bd346ee",
45
45
  "@rspack/core": "1.7.8",
46
46
  "@types/semver": "7.7.1",
47
47
  "hookable": "6.1.0",