closure-webpack-plugin icon indicating copy to clipboard operation
closure-webpack-plugin copied to clipboard

webpack v5 support

Open jurassix opened this issue 3 years ago • 8 comments

👋 I'm interested in using GCC with the latest version of Webpack (v5) but there seems to be an internal plugin issue. So far I've upgraded the demos to the latest dependency versions and included the error below. I've also checked to see if there is a v5 working branch but didn't see one. I'm happy to contribute to help get the latest webpack version supported but unsure if there is already work in-progress. Thanks for your time.

I get the following error after upgrading the es5-and-es6 demo:

master:~/sandbox/closure-webpack-plugin/demo/es5-and-es6$ npm run start

> [email protected] start /Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6
> webpack serve --mode=production

/Users/clint/sandbox/closure-webpack-plugin/src/closure-compiler-plugin.js:197
      compilation.dependencyTemplates.forEach((val, key) => {
                                      ^

TypeError: compilation.dependencyTemplates.forEach is not a function
    at ClosureCompilerPlugin.compilation_ (/Users/clint/sandbox/closure-webpack-plugin/src/closure-compiler-plugin.js:197:39)
    at /Users/clint/sandbox/closure-webpack-plugin/src/closure-compiler-plugin.js:159:12
    at _next31 (eval at create (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:42:1)
    at _next9 (eval at create (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:97:1)
    at Hook.eval [as call] (eval at create (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:119:1)
    at Hook.CALL_DELEGATE [as _call] (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/webpack/lib/Compiler.js:993:26)
    at /Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/webpack/lib/Compiler.js:1035:29
    at Hook.eval [as callAsync] (eval at create (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/webpack/lib/Compiler.js:1030:28)
    at /Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/webpack/lib/Watching.js:132:19
    at Hook.eval [as callAsync] (eval at create (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/tapable/lib/Hook.js:18:14)
    at run (/Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/webpack/lib/Watching.js:86:33)
    at /Users/clint/sandbox/closure-webpack-plugin/demo/es5-and-es6/node_modules/webpack/lib/Watching.js:82:6

jurassix avatar Mar 16 '21 01:03 jurassix

I've investigated this, and the API for WP5 has changed a bit, and a lot of the changes this plugin makes would be considered 'hacks' around the API. I spent a little bit hacking them back into place but honestly it would likely be better for someone to do it from scratch rather than modify this plugin.

dtzxporter avatar Mar 23 '21 16:03 dtzxporter

As you noticed, in many ways this plugin has had to work around limitations in extending webpack. Every major version update of webpack equates to many many hours of testing and dev work.

While I'd like to support webpack 5, right now I just don't have the time to devote to that endeavor.

ChadKillingsworth avatar Mar 29 '21 11:03 ChadKillingsworth

Is there anything from a webpack side of things you need help with?

evenstensberg avatar Jul 04 '21 17:07 evenstensberg

Is there any update on this?

xnerhu avatar Jul 31 '21 21:07 xnerhu

Hi, we migrated to webpack 5 and would be neat to have support of this plugin

Mistic92 avatar Sep 28 '21 09:09 Mistic92

This alternative did the trick for me: https://www.npmjs.com/package/google-closure-library-webpack-plugin

mhassan1 avatar Aug 10 '22 15:08 mhassan1

Using:

npm install --legacy-peer-deps

allows me to use webpack 5. would be nice to have this in the repo, though.

avindra avatar Aug 30 '23 19:08 avindra

https://www.npmjs.com/package/google-closure-library-webpack-plugin does not have even example of how to use it

Any updates on webpack v5?

Forux avatar Apr 25 '24 15:04 Forux