lodash / lodash-webpack-plugin

Smaller modular Lodash builds.
Other
1.19k stars 63 forks source link

Add support for Webpack v5 #167

Closed spnc-omz closed 3 years ago

spnc-omz commented 4 years ago

https://github.com/lodash/lodash-webpack-plugin/blob/master/src/index.js#L41

This line is causing build errors for a project I'm working on. Sadly I cannot disclose the source or configuration of the project, but removing this plugin set my project back on track to working with Webpack v5.

https://github.com/webpack/webpack/blob/master/lib/NormalModuleFactory.js//#L198

Steps to reproduce:

1) Add new LodashModuleReplacementPlugin({}) to plugins array 2) run build

Expected results: plugin to not cause harm.

Actual results: `NaN% building 0/10 entries 0/9 dependencies 0/0 modules(node:7064) [DEP_WEBPACK_MAIN_TEMPLATE_RENDER_MANIFEST] DeprecationWarning: MainTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead) (node:7064) [DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_MANIFEST] DeprecationWarning: ChunkTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead) (node:7064) [DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK] DeprecationWarning: MainTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead) /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:202 throw new Error(deprecationChangedHookMessage("afterResolve")); ^

Error: NormalModuleFactory.afterResolve is no longer a waterfall hook, but a bailing hook instead. Do not return the passed object, but modify it instead. Returning false will ignore the request and results in no module created. at /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:202:14 at Hook.eval [as callAsync] (eval at create (/Users/req/code/www/project.com/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :16:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/req/code/www/project.com/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14) at /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:198:30 at eval (eval at create (/Users/req/code/www/project.com/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1) at /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:418:7 at /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:94:11 at /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:450:8 at done (/Users/req/code/www/project.com/node_modules/neo-async/async.js:2931:13) at /Users/req/code/www/project.com/node_modules/webpack/lib/NormalModuleFactory.js:624:14 at finishResolved (/Users/req/code/www/project.com/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:113:11) at /Users/req/code/www/project.com/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:172:25 at /Users/req/code/www/project.com/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:247:24 at eval (eval at create (/Users/req/code/www/project.com/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1) at done (/Users/req/code/www/project.com/node_modules/webpack/lib/cache/ResolverCachePlugin.js:237:12) at /Users/req/code/www/project.com/node_modules/webpack/lib/cache/ResolverCachePlugin.js:184:29 at /Users/req/code/www/project.com/node_modules/webpack/lib/HookWebpackError.js:69:3 at Hook.eval [as callAsync] (eval at create (/Users/req/code/www/project.com/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1) at Cache.store (/Users/req/code/www/project.com/node_modules/webpack/lib/Cache.js:107:20) at /Users/req/code/www/project.com/node_modules/webpack/lib/cache/ResolverCachePlugin.js:172:14 at jobDone (/Users/req/code/www/project.com/node_modules/webpack/lib/FileSystemInfo.js:736:5) at /Users/req/code/www/project.com/node_modules/webpack/lib/FileSystemInfo.js:1073:7 at /Users/req/code/www/project.com/node_modules/webpack/lib/util/AsyncQueue.js:280:5 at Hook.eval [as callAsync] (eval at create (/Users/req/code/www/project.com/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at AsyncQueue._handleResult (/Users/req/code/www/project.com/node_modules/webpack/lib/util/AsyncQueue.js:253:21) at /Users/req/code/www/project.com/node_modules/webpack/lib/util/AsyncQueue.js:236:11 at /Users/req/code/www/project.com/node_modules/webpack/lib/FileSystemInfo.js:1739:5 at /Users/req/code/www/project.com/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:97:15`

relates to, but not the exact same as https://github.com/lodash/lodash-webpack-plugin/pull/142

TomFoyster commented 4 years ago

Added some info here - https://github.com/lodash/lodash-webpack-plugin/issues/174#issuecomment-708505613

If anyone's available to help on the test issue that'd be awesome

thaoms commented 4 years ago

Any update? This is blocking us to upgrade to webpack 5

kachkaev commented 3 years ago

@bnjmnt4n out of curiosity, how does d241458ae639f1cc2f2ecc479d546660714fe6ae close this issue? The deprecated afterResolve is still used, according to the diff.

bnjmnt4n commented 3 years ago

The issue title is a little misleading; here's the relevant part of the error message:

Error: NormalModuleFactory.afterResolve is no longer a waterfall hook, but a bailing hook instead. Do not return the passed object, but modify it instead. Returning false will ignore the request and results in no module created.
bnjmnt4n commented 3 years ago

Also, just an update: I've released v0.11.6 with the patch, do let me know if there are any issues.