You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hm, intresting, no sure we can't fix it, because we don't handle at all unused imports for perf reasons, maybe linter is the best solution here, but I look at this deeply
@vankop What do you think? Honestly, I'm not sure that we should process this, personally I think it's more work for a linter, because bar import is not unsed and we just drop it, so we don't generate broken code
probably original issue was closed as a stale one..
So basically idea of the warning/error here is to notify user about highly likely issues at runtime ( if exports are reachable code ), with unused imports it is not a problem. If you didn't disable optimisations in config, webpack will remove unused exports for you.
If you want to improve your source code, in this case better to use linters (e.g. eslint )
Bug report
What is the current behavior?
Setting
exportsPresence
to'error'
does not emit an error if the import is unused.If the current behavior is a bug, please provide the steps to reproduce.
git clone https://github.com/rwieruch/minimal-webpack-setup
cd minimal-webpack-setup
npx npm-check-updates -u
npm install
src/foo.js
with the following content:webpack.config.js
to includesrc/index.js
to look like:npx webpack
What is the expected behavior?
Webpack should emit an error that
bar
is an invalid import regardless of whetherconsole.log(bar)
is commented out or not.Other relevant information:
webpack version: 5.91.0
Node.js version: 21.7.1
This seems to be a regression since the same issue was reported a few years ago and allegedly resolved (#4897).
The text was updated successfully, but these errors were encountered: