fix: suppress OpenTelemetry critical dependency warnings in webpack#3246
fix: suppress OpenTelemetry critical dependency warnings in webpack#3246YasminTeles wants to merge 5 commits intocanary-v2from
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (2)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds three webpack warning suppressors to Next.js config, adds an npmrc pointing the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
Oi @YasminTeles! Testei a versão gerada pelo codesandbox em uma loja teste. Os logs de erros não foram suprimidos quando rodei o dev/build da loja. Exemplo rodando Será que faltou algo no ignoreWarnings ou simplesmente o webpack ignorou ele? |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/next.config.js`:
- Around line 82-91: The ignoreWarnings change won’t stop module-not-found
errors; update the Next.js webpack config (the same config object where
config.ignoreWarnings is set) to alias optional OpenTelemetry modules to an
empty shim or false so webpack won’t attempt to resolve them (e.g., add entries
under config.resolve.alias for modules like "@opentelemetry/instrumentation-koa"
and any other optional OTel packages); ensure the aliases are added in the
exported Next.js config’s webpack function so resolution uses the shim and the
build no longer fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f2d49853-b412-4a53-942e-c1245c162537
📒 Files selected for processing (1)
packages/core/next.config.js
| // Suppress "Critical dependency" warnings from OpenTelemetry's dynamic requires | ||
| config.ignoreWarnings = [ | ||
| ...(config.ignoreWarnings || []), | ||
| { module: /require-in-the-middle/, message: /Critical dependency/ }, | ||
| { | ||
| module: /@opentelemetry\/instrumentation/, | ||
| message: /Critical dependency/, | ||
| }, | ||
| { module: /@vtex\/diagnostics-nodejs/, message: /Critical dependency/ }, | ||
| ] |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does webpack's ignoreWarningssuppress only warnings, or can it also suppressModule not found: Can't resolve ... compilation errors?
💡 Result:
Webpack’s ignoreWarnings only suppresses warnings; it does not suppress compilation errors like “Module not found: Can't resolve …”. The ignoreWarnings option is documented specifically as “ignore specific warnings” and its matching functions/selectors operate on the “raw warning instance” (WebpackError + Compilation) that represents warnings, not errors. Therefore, if the “Module not found: Can't resolve …” is produced as an error (which it usually is), ignoreWarnings will not prevent the build from failing. If you need to handle missing/optional modules, you typically need a different approach (e.g., IgnorePlugin to prevent bundling specific requests, or restructure/alias/externals so the resolver never attempts to resolve missing modules).
Citations:
- 1: https://webpack.js.org/configuration/other-options/
- 2: https://docs.webpack.js.org/configuration/stats
- 3: Prevent warnings for optional modules webpack/webpack.js.org#1876
- 4: IgnorePlugin: Cannot Found Module Error webpack/webpack#10866
- 5: https://docs.webpack.js.org/plugins/ignore-plugin
ignoreWarnings won't suppress the reported Module not found compilation errors
The ignoreWarnings configuration suppresses warnings only, not errors like Can't resolve '@opentelemetry/instrumentation-koa'. The reported build failure will persist with this change alone.
Suggested fix (handle optional OTel modules via webpack alias)
webpack: (config, { isServer, dev }) => {
+ config.resolve = config.resolve || {}
+ config.resolve.alias = {
+ ...(config.resolve.alias || {}),
+ '@opentelemetry/instrumentation-koa': false,
+ }
// Suppress "Critical dependency" warnings from OpenTelemetry's dynamic requires
config.ignoreWarnings = [
...(config.ignoreWarnings || []),
{ module: /require-in-the-middle/, message: /Critical dependency/ },
{
module: /@opentelemetry\/instrumentation/,
message: /Critical dependency/,
},
{ module: /@vtex\/diagnostics-nodejs/, message: /Critical dependency/ },
]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/core/next.config.js` around lines 82 - 91, The ignoreWarnings change
won’t stop module-not-found errors; update the Next.js webpack config (the same
config object where config.ignoreWarnings is set) to alias optional
OpenTelemetry modules to an empty shim or false so webpack won’t attempt to
resolve them (e.g., add entries under config.resolve.alias for modules like
"@opentelemetry/instrumentation-koa" and any other optional OTel packages);
ensure the aliases are added in the exported Next.js config’s webpack function
so resolution uses the shim and the build no longer fails.
d8c07ca to
a9396d7
Compare
Summary by CodeRabbit