Skip to content

feat: Migrate to Webpack Built-in Infrastructure Logger with Backward… - #738

Merged
valscion merged 4 commits into
webpack:mainfrom
ronakmaheshwari:main
Sep 17, 2026
Merged

valscion merged 4 commits into
webpack:mainfrom
ronakmaheshwari:main

Conversation

@ronakmaheshwari

@ronakmaheshwari ronakmaheshwari commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request updates the logging system of the webpack-bundle-analyzer plugin to integrate with Webpack's native infrastructure logger when available. It introduces a new adapter for compatibility, deprecates the plugin's logLevel option in favor of Webpack's infrastructureLogging, and updates documentation and type annotations accordingly.

Logging integration and deprecation:

  • The plugin now uses Webpack's infrastructure logger via compiler.getInfrastructureLogger('webpack-bundle-analyzer') when available, providing better integration with Webpack's logging system.
  • The logLevel option is deprecated in favor of Webpack's infrastructureLogging.level, with documentation and type comments updated to reflect this change. A deprecation warning is shown if logLevel is used. [1] [2] [3] [4] [5]

Logger implementation and type updates:

  • Introduces InfrastructureLoggerAdapter in Logger.js to bridge between the plugin's logger interface and Webpack's infrastructure logger, supporting log level filtering and deprecation warnings. [1] [2] [3]
  • Updates type annotations throughout the codebase (src/analyzer.js, src/utils.js, src/viewer.js) to accept either the custom Logger or Webpack's infrastructure logger for improved type safety and compatibility. [1] [2] [3] [4] [5] [6] [7]

These changes ensure that logging is consistent with Webpack's ecosystem and prepare for the eventual removal of the plugin's custom logLevel option compatibility

#358

@valscion if you can review it

Summary by CodeRabbit

  • New Features
    • Uses Webpack’s infrastructure logger when available, providing consistent logging across builds.
    • Falls back to the existing logging behavior when infrastructure logging is unavailable.
  • Deprecations
    • The logLevel option is deprecated. Configure logging levels through Webpack’s native infrastructureLogging settings instead.
  • Documentation
    • Updated plugin options and logger documentation to explain infrastructure logging support and the logLevel deprecation.

@changeset-bot

changeset-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7b4490d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-bundle-analyzer Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ronakmaheshwari / name: ronak maheshwari (ad3efed)

@valscion

Copy link
Copy Markdown
Collaborator

Thanks! Could you follow the pull request template?

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.75%. Comparing base (21ab1c1) to head (7b4490d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #738      +/-   ##
==========================================
+ Coverage   85.35%   86.75%   +1.40%     
==========================================
  Files          17       17              
  Lines        1065     1110      +45     
  Branches      387      406      +19     
==========================================
+ Hits          909      963      +54     
+ Misses        142      134       -8     
+ Partials       14       13       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ronakmaheshwari

Copy link
Copy Markdown
Contributor Author

Will do it today it self

Comment thread test/Logger.js Outdated
@valscion

Copy link
Copy Markdown
Collaborator

Also check the coverage report, some methods seem to bail out and not be tested

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this improvement

@ronakmaheshwari

Copy link
Copy Markdown
Contributor Author

Hii @valscion I have made the changes Can you review it please

@ronakmaheshwari

Copy link
Copy Markdown
Contributor Author

@valscion Any updates for me

@valscion

Copy link
Copy Markdown
Collaborator

CI seems to be failing now that I triggered it to run. Is it this PR cause?

@ronakmaheshwari

Copy link
Copy Markdown
Contributor Author

@valscion It was the duplicate code. I have fixed it we are good to go

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Walkthrough

The plugin now uses Webpack’s infrastructure logger when the compiler provides it. A logger adapter preserves deprecated logLevel behavior, filters level methods, supports child loggers, and emits deprecation warnings. Logger type declarations now accept Webpack infrastructure loggers. Documentation marks logLevel as deprecated. Unit and integration tests cover adapter behavior, server startup, logger selection, and fallback behavior.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 7b449

Changing the deprecated log level at runtime does not affect child loggers created afterward, so their messages may be filtered incorrectly. Fix this small compatibility gap before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 7 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: migration to Webpack's built-in infrastructure logger. The truncated backward-compatibility wording does not obscure the primary change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 7 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/BundleAnalyzerPlugin.js

ESLint failed to execute (timeout).

src/Logger.js

ESLint skipped: the matched ESLint configuration already failed (timeout).

src/analyzer.js

ESLint skipped: the matched ESLint configuration already failed (timeout).

  • 4 others

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b4233e54-d4e7-479d-90e8-bae43eaf8463

📥 Commits

Reviewing files that changed from the base of the PR and between 21ab1c1 and 7b4490d.

📒 Files selected for processing (9)
  • .changeset/use-webpack-infrastructure-logger.md
  • README.md
  • src/BundleAnalyzerPlugin.js
  • src/Logger.js
  • src/analyzer.js
  • src/utils.js
  • src/viewer.js
  • test/Logger.js
  • test/plugin.js

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/Logger.js
return (/** @type {string | (() => string)} */ name) =>
Logger.createInfrastructureLoggerAdapter(
target.getChildLogger(name),
userLogLevel,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the current log level for new child loggers.

setLogLevel updates activeLevels, but getChildLogger passes the original userLogLevel. For example, after changing "error" to "warn", a new child logger still suppresses warnings.

Track the current level and pass it to createInfrastructureLoggerAdapter. Add a test that creates a child after setLogLevel.

Proposed fix
-    const levelIndex = LEVELS.indexOf(userLogLevel);
+    let currentLevel = userLogLevel;
+    const levelIndex = LEVELS.indexOf(currentLevel);

         if (prop === "setLogLevel") {
           return (/** `@type` {Level} */ level) => {
             const idx = LEVELS.indexOf(level);

             if (idx === -1) {
               throw new Error(
                 `Invalid log level "${level}". Use one of these: ${LEVELS.join(", ")}`,
               );
             }

+            currentLevel = level;
             activeLevels.clear();

             for (const [i, l] of LEVELS.entries()) {
               if (i >= idx) activeLevels.add(l);
             }
           };
         }

             Logger.createInfrastructureLoggerAdapter(
               target.getChildLogger(name),
-              userLogLevel,
+              currentLevel,
               true,
             );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like a code flow which users should be using. So this is a false positive.

@valscion valscion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this looks good to me! Thanks!

@valscion
valscion merged commit 7470242 into webpack:main Sep 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants