@nuxt/webpack-builder-nightly 5.0.0-29740135.daae2228 → 5.0.0-29740294.24eec37d

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 +38 -7
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from "node:module";
2
2
  import pify from "pify";
3
3
  import { defu } from "defu";
4
- import { pathToFileURL } from "node:url";
5
- import { basename, isAbsolute, join, normalize, relative, resolve } from "pathe";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from "pathe";
6
6
  import { joinURL, withTrailingSlash } from "ufo";
7
7
  import { bundlerDiagnostics, configDiagnostics, directoryToURL, logger, resolveAlias, setBuildOutput, useNitro, useNuxt } from "@nuxt/kit";
8
8
  import { createUnplugin } from "unplugin";
@@ -16,6 +16,8 @@ import { Volume, createFsFromVolume } from "memfs";
16
16
  import querystring from "node:querystring";
17
17
  import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
18
18
  import { defineEnv } from "unenv";
19
+ import { parseNodeModulePath } from "mlly";
20
+ import { resolveModulePath } from "exsolve";
19
21
  import TimeFixPlugin from "time-fix-plugin";
20
22
  import FriendlyErrorsWebpackPlugin from "@nuxt/friendly-errors-webpack-plugin";
21
23
  import escapeRegExp from "escape-string-regexp";
@@ -23,12 +25,10 @@ import { EsbuildPlugin } from "esbuild-loader";
23
25
  import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
24
26
  import createResolver from "postcss-import-resolver";
25
27
  import { createJiti } from "jiti";
26
- import { resolveModulePath } from "exsolve";
27
28
  import { mkdir, writeFile } from "node:fs/promises";
28
29
  import { normalizeWebpackManifest, precomputeDependencies } from "vue-bundle-renderer";
29
30
  import { hash } from "ohash";
30
31
  import { serialize } from "seroval";
31
- import { parseNodeModulePath } from "mlly";
32
32
  //#region src/plugins/dynamic-base.ts
33
33
  const ENTRY_RE = /import ["']#build\/css["'];/;
34
34
  const DynamicBasePlugin = createUnplugin(() => {
@@ -765,8 +765,39 @@ function baseAlias(ctx) {
765
765
  ctx.alias["nitropack/runtime"] = resolve(ctx.nuxt.options.buildDir, "nitro.client.mjs");
766
766
  }
767
767
  }
768
+ /**
769
+ * The `node_modules` directories that hold a package's dependencies, given a file
770
+ * resolved inside it. Covers both the isolated pnpm layout (dependencies are symlinked
771
+ * into the package's `.pnpm` group) and the hoisted/workspace layout (dependencies live
772
+ * in the package's own `node_modules`).
773
+ */
774
+ function packageDependencyDirs(entry) {
775
+ if (!entry) return [];
776
+ const dirs = /* @__PURE__ */ new Set();
777
+ const groupDir = parseNodeModulePath(entry).dir;
778
+ if (groupDir) dirs.add(resolve(groupDir));
779
+ let dir = dirname(entry);
780
+ while (dir !== dirname(dir)) {
781
+ if (existsSync(resolve(dir, "package.json"))) {
782
+ dirs.add(resolve(dir, "node_modules"));
783
+ break;
784
+ }
785
+ dir = dirname(dir);
786
+ }
787
+ return [...dirs].filter((dir) => existsSync(dir));
788
+ }
789
+ const builderModulesDirs = packageDependencyDirs(fileURLToPath(import.meta.url));
768
790
  function baseResolve(ctx) {
769
- const webpackModulesDir = ["node_modules"].concat(ctx.options.modulesDir);
791
+ const webpackModulesDir = ["node_modules", ...ctx.options.modulesDir];
792
+ const from = ctx.options.modulesDir.map(directoryToURL);
793
+ const runtimeModulesDirs = ["nuxt/package.json", "@nuxt/nitro-server/package.json"].flatMap((id) => packageDependencyDirs(resolveModulePath(id, {
794
+ from,
795
+ try: true
796
+ })));
797
+ const resolveModules = [...webpackModulesDir];
798
+ for (const dir of [...runtimeModulesDirs, ...builderModulesDirs]) if (!resolveModules.includes(dir)) resolveModules.push(dir);
799
+ const resolveLoaderModules = [...webpackModulesDir];
800
+ for (const dir of builderModulesDirs) if (!resolveLoaderModules.includes(dir)) resolveLoaderModules.push(dir);
770
801
  ctx.config.resolve = {
771
802
  extensions: [
772
803
  ".wasm",
@@ -779,12 +810,12 @@ function baseResolve(ctx) {
779
810
  ".tsx"
780
811
  ],
781
812
  alias: ctx.alias,
782
- modules: webpackModulesDir,
813
+ modules: resolveModules,
783
814
  fullySpecified: false,
784
815
  ...ctx.config.resolve
785
816
  };
786
817
  ctx.config.resolveLoader = {
787
- modules: webpackModulesDir,
818
+ modules: resolveLoaderModules,
788
819
  ...ctx.config.resolveLoader
789
820
  };
790
821
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder-nightly",
3
- "version": "5.0.0-29740135.daae2228",
3
+ "version": "5.0.0-29740294.24eec37d",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
29
- "@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29740135.daae2228",
29
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29740294.24eec37d",
30
30
  "@vue/compiler-sfc": "3.5.40",
31
31
  "autoprefixer": "^10.5.4",
32
32
  "css-loader": "^7.1.4",
@@ -71,7 +71,7 @@
71
71
  "webpackbar": "^7.0.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-29740135.daae2228",
74
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-29740294.24eec37d",
75
75
  "@rspack/core": "2.1.4",
76
76
  "@types/webpack-bundle-analyzer": "4.7.0",
77
77
  "@types/webpack-hot-middleware": "2.25.12",
@@ -82,7 +82,7 @@
82
82
  "vue": "3.5.40"
83
83
  },
84
84
  "peerDependencies": {
85
- "nuxt": "npm:nuxt-nightly@5.0.0-29740135.daae2228",
85
+ "nuxt": "npm:nuxt-nightly@5.0.0-29740294.24eec37d",
86
86
  "vue": "^3.3.4"
87
87
  },
88
88
  "engines": {