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 a117600dff
This commit is contained in:
Katerina Koukiou 2021-11-08 11:47:57 +01:00 committed by Justin Stephenson
parent abc5922946
commit 03a5445b35

View file

@ -15,7 +15,8 @@ const builddir = process.env.SRCDIR || __dirname;
const distdir = builddir + path.sep + "dist"; const distdir = builddir + path.sep + "dist";
const section = process.env.ONLYDIR || null; const section = process.env.ONLYDIR || null;
const libdir = path.resolve(srcdir, "lib") 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 */ /* A standard nodejs and webpack pattern */
var production = process.env.NODE_ENV === "production"; var production = process.env.NODE_ENV === "production";