johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 136 forks source link

[del] Some internal modules are deprecated. #209

Open stein2nd opened 1 month ago

stein2nd commented 1 month ago

npm warn deprecated rimraf@2.7.1: Rimraf versions prior to v4 are no longer supported del@4 1 1

npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported rimraf@2 7 1

timmkuehle commented 1 month ago

Unfortunately i can add another, seemingly more serious, deprecation to that:

npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.

error

@johnagan Since you still have a huge userbase with nearly 2 million downloads per week, it would be much appreciated if you could fix these dependencies. I could also try to tackle this myself and open a PR, but i sadly have very little spare time at the moment and no experience in working with del which seems to be the root cause of those dependancy issues.

By the way, you're plugin is still working great in all of the projects that I'm using it in (even with webpack 5 and NodeJS 18) and i assume it also does for many others, so it might be worth the effort. Thanks in advance!

johnagan commented 1 month ago

I’d be open to reviewing a PR to address it, but it’s unlikely I’ll have time to resolve this myself.

stein2nd commented 1 month ago

For verification, I temporarily modernised package.json by running 'ncu' and 'ncu -u' under the 'clean-webpack-plugin' installation folder. @babelpreset-typescript

After running 'npm install --force', several internal modules still show a deprecated warning.

npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported temp-sandbox@4 0 1

npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported babel-jest@29 7 0

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. Pasted Graphic 1

npm warn deprecated codecov@3.8.3: https://about.codecov.io/blog/codecov-uploader-deprecation-plan/ Pasted Graphic 5

npm warn deprecated argv@0.0.2: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. codecov@3 8 3

timmkuehle commented 1 month ago

I'm afraid, I wont be able to solve this issue.

I forked the project and tried to update the del dependency manually. When using the updated package in one of my projects, I get an error, telling me I can't use require() to import an ESM module:

[webpack-cli] Failed to load '~/my-project/Code/webpack.config.js' config
[webpack-cli] Error [ERR_REQUIRE_ESM]: require() of ES Module ~/clean-webpack-plugin/Coding/node_modules/del/index.js from ~/clean-webpack-plugin/Coding/dist/clean-webpack-plugin.js not supported.
Instead change the require of index.js in ~/clean-webpack-plugin/dist/clean-webpack-plugin.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (~/clean-webpack-plugin/dist/clean-webpack-plugin.js:7:12)
    at async WebpackCLI.tryRequireThenImport (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:232:34)
    at async loadConfigByPath (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:1406:27)
    at async WebpackCLI.loadConfig (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:1515:38)
    at async WebpackCLI.createCompiler (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:1781:22)
    at async WebpackCLI.runWebpack (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:1877:20)
    at async Command.<anonymous> (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:944:21)
    at async Command.parseAsync (~/my-project/Code/node_modules/webpack-cli/node_modules/commander/lib/command.js:935:5)
    at async Command.<anonymous> (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:1356:13)
    at async Command.parseAsync (~/my-project/Code/node_modules/webpack-cli/node_modules/commander/lib/command.js:935:5)
    at async WebpackCLI.run (~/my-project/Code/node_modules/webpack-cli/lib/webpack-cli.js:1360:9)
    at async runCLI (~/my-project/Code/node_modules/webpack-cli/lib/bootstrap.js:9:9) {
  code: 'ERR_REQUIRE_ESM'
}

This is caused by the plugin's build system, that transpiles import statements into require() functions. The updated del package does not seem to provide an export that can be used with the require() syntax.

Maybe using a dynamic import() could fix this, but there seems to be no way to use that synchronously, which in turn disqualifies this as an easy fix.

So I guess, the only option to solve this, would be to adjust the whole build system. Sadly i don't have any experience in using @babel/cli, since I always worked with webpack's own cli and I don't really have the time to dig any deeper at this point.

Maybe someone with more experience can help here. Otherwise I think we're stuck with using the plugin in it's current state. This hopefully won't be overly dramatic, since it is only ever used during transpilation and not in production.