webpack-contrib / closure-webpack-plugin

Webpack Google Closure Compiler and Closure Library plugin -
https://developers.google.com/closure/
MIT License
433 stars 60 forks source link

webpack v5 support #161

Open jurassix opened 3 years ago

jurassix commented 3 years ago

👋 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

> es5-and-es6@1.0.0 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
dtzxporter commented 3 years ago

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.

ChadKillingsworth commented 3 years ago

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.

evenstensberg commented 3 years ago

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

xnerhu commented 3 years ago

Is there any update on this?

Mistic92 commented 2 years ago

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

mhassan1 commented 2 years ago

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

avindra commented 1 year ago

Using:

npm install --legacy-peer-deps

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

Forux commented 4 months ago

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?