diff --git a/graylog2-web-interface/webpack.preflight.ts b/graylog2-web-interface/webpack.preflight.ts index bb209a2ffc60..fdc0128fd45f 100644 --- a/graylog2-web-interface/webpack.preflight.ts +++ b/graylog2-web-interface/webpack.preflight.ts @@ -51,7 +51,7 @@ const baseConfig = { resolve: { // you can now require('file') instead of require('file.coffee') extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'], - modules: [APP_PATH, path.resolve(ROOT_PATH, 'node_modules'), path.resolve(ROOT_PATH, 'public')], + modules: [APP_PATH, 'node_modules', path.resolve(ROOT_PATH, 'node_modules'), path.resolve(ROOT_PATH, 'public')], }, module: { rules: core.rules(TARGET, supportedBrowsers), diff --git a/graylog2-web-interface/webpack/core.js b/graylog2-web-interface/webpack/core.js index 6eaeb8a8924c..d97e22cd7da1 100644 --- a/graylog2-web-interface/webpack/core.js +++ b/graylog2-web-interface/webpack/core.js @@ -134,7 +134,10 @@ const config = (target, appPath, rootPath, webInterfaceRoot, supportedBrowsers) resolve: { // you can now require('file') instead of require('file.coffee') extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'], - modules: [appPath, path.resolve(rootPath, 'node_modules'), path.resolve(rootPath, 'public')], + // The bare `node_modules` entry makes webpack walk up from the importing module like node does. + // Without it only the hoisted top-level copy is ever found, so nested versions kept apart on + // purpose get flattened into one, which can turn peer dependencies into require cycles. + modules: [appPath, 'node_modules', path.resolve(rootPath, 'node_modules'), path.resolve(rootPath, 'public')], alias: { '@graylog/server-api': path.resolve(webInterfaceRoot, 'target', 'api'), },