From c069132a86d0830292f9cbe8ab750be054c53d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 26 May 2026 11:23:14 +0200 Subject: [PATCH] fix(cli): suppress protobufjs/inquire dynamic require warning in bundler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since protobufjs 7.5.9, the @protobufjs/inquire utility is no longer called with dynamic module names (replaced by bundler-safe lookups in protobufjs/protobuf.js#2254). However, webpack/rspack still statically analyzes the inquire source and emits a "Critical dependency" warning for its require(moduleName) pattern. This is a false positive — the code path is dead in practice. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .../src/lib/bundler/config.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/cli-module-build/src/lib/bundler/config.ts b/packages/cli-module-build/src/lib/bundler/config.ts index d3e5f01eac..e2de9ef2c8 100644 --- a/packages/cli-module-build/src/lib/bundler/config.ts +++ b/packages/cli-module-build/src/lib/bundler/config.ts @@ -394,16 +394,25 @@ export async function createConfig( }), }, plugins, - ...(options.moduleFederationRemote && { + ignoreWarnings: [ + // @protobufjs/inquire uses require(moduleName) with a dynamic argument. + // Since protobufjs >=7.5.9 this code path is never exercised (the + // bundler-safe optional module lookups backport replaced all call sites), + // but webpack/rspack still statically analyzes the source and emits a + // "Critical dependency" warning. Safe to suppress. + // See https://github.com/protobufjs/protobuf.js/issues/2057 + { module: /@protobufjs[\\/]inquire/ }, // TODO: remove this warning skipping as soon as the corresponding bundler limitation // described in issue https://github.com/web-infra-dev/rspack/issues/13635 is fixed // when PR: https://github.com/web-infra-dev/rspack/pull/13636 is merged. - ignoreWarnings: [ - { - message: - /No version specified and unable to automatically determine one\. No version in description file/, - }, - ], - }), + ...(options.moduleFederationRemote + ? [ + { + message: + /No version specified and unable to automatically determine one\. No version in description file/, + }, + ] + : []), + ], }; }