From 03a5445b351d9504c1d539e8200766839e11c02f Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 8 Nov 2021 11:47:57 +0100 Subject: [PATCH] webpack: Use relative resolve path for npm 7 compatibility npm 7 changed how it resolves dependencies, and cockpit-machines fails to build with lots of unresolved peer dependencies of PatternFly. With an absolute path, `resolve.modules` will only look in that directory; the default is a relative path "node_modules" that just works [1]. We need to keep the `$SRCDIR` support, but convert the path to a relative one to keep the old recursive search behaviour. This magically fixes the label alignment in dialogs, update the pixel test references accordingly. [1] https://webpack.js.org/configuration/resolve/#resolvemodules See also https://github.com/cockpit-project/cockpit/commit/a117600dfffe8311ec6286cf060c80cd35a8a84c --- webpack.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 1cd081e..c5a1f53 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,7 +15,8 @@ const builddir = process.env.SRCDIR || __dirname; const distdir = builddir + path.sep + "dist"; const section = process.env.ONLYDIR || null; const libdir = path.resolve(srcdir, "lib") -const nodedir = path.resolve(process.env.SRCDIR || __dirname, "node_modules"); +// absolute path disables recursive module resolution, so build a relative one +const nodedir = path.relative(process.cwd(), path.resolve((process.env.SRCDIR || __dirname), "node_modules")); /* A standard nodejs and webpack pattern */ var production = process.env.NODE_ENV === "production";