Skip to content

feat: warn when modules are automatically converted to strict mode #19628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

3ru
Copy link
Contributor

@3ru 3ru commented Jun 25, 2025

warn users when webpack automatically converts their modules to strict mode.

Rel #17121

What kind of change does this PR introduce?

Feature - adds a new opt-in plugin to help developers identify when their modules are automatically converted to strict mode

Did you add tests for your changes?

yes

Does this PR introduce a breaking change?

no

How to use

const WarnStrictModeModulesPlugin = require("webpack/lib/WarnStrictModeModulesPlugin");

module.exports = {
  plugins: [
    new WarnStrictModeModulesPlugin()
  ]
};

@3ru 3ru marked this pull request as ready for review June 25, 2025 16:54
@3ru
Copy link
Contributor Author

3ru commented Jun 25, 2025

I'm not sure if this matches the original intent of the TODO, so I'd appreciate your review and guidance.

Copy link

codspeed-hq bot commented Jun 25, 2025

CodSpeed Performance Report

Merging #19628 will degrade performances by 69.58%

Comparing 3ru:feat/warn-strict-mode-conversion (5318930) with main (10fb556)

Summary

⚡ 2 improvements
❌ 2 regressions
✅ 129 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 34.9 ms 11.8 ms ×3
benchmark "many-chunks-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 53.9 ms 61.6 ms -12.53%
benchmark "many-modules-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 11.2 ms 9.8 ms +14.26%
benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 10.8 ms 35.6 ms -69.58%

@3ru 3ru force-pushed the feat/warn-strict-mode-conversion branch from 9a68b97 to bca8a2b Compare June 26, 2025 03:27
- Add WarnStrictModeModulesPlugin to detect modules converted to strict mode

- Track modules with explicit 'use strict' to avoid false warnings

- Plugin is opt-in to avoid breaking existing builds
@3ru 3ru force-pushed the feat/warn-strict-mode-conversion branch from bca8a2b to 5318930 Compare June 26, 2025 03:52
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.

1 participant