javascript-obfuscator / webpack-obfuscator

javascript-obfuscator plugin for Webpack
https://github.com/javascript-obfuscator/javascript-obfuscator
BSD 2-Clause "Simplified" License
870 stars 82 forks source link

Plugin may not work in webpack 5 #94

Closed jakebailey closed 3 years ago

jakebailey commented 3 years ago

webpack 5 is due to be released pretty shortly; this plugin works fine in webpack 5 at the moment but may not in the future due to deprecations in the API. Running the plugin shows me:

(node:90055) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
    Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
    Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
(Use `node --trace-deprecation ...` to show where the warning was created)

Because the obfuscator plugin appears to be modifying the assets directly. I don't know quite enough about webpack to know what all is involved.

sanex3339 commented 3 years ago

I released webpack-obfuscator@3.0.0-beta.0 with the support of webpack@5, but I dropped the support of webpack@4. javascript-obfuscator now is a peerDependency. I'll release webpack-obfuscator@2.6.0 with the support of webpack@4 and javascript-obfuscator as a peerDependency today too.

jakebailey commented 3 years ago

Thanks; I've tested it and it appears to work!

I'm not sure that this will play nicely with TS, but if you didn't want to completely drop webpack v4 support, I know that some support both and do checks to switch between implementations. For example, webpack-cli uses this to switch between behaviors: https://github.com/webpack/webpack-cli/blob/master/packages/utils/src/isWebpack5.ts

sanex3339 commented 3 years ago

Support both 4 and 5 more complicated. The problem starts with the typings and ends with different API.

jakebailey commented 3 years ago

Unfortunate. Hopefully people are content to stay on v2 for webpack 4, then. (Clearly I'm already on 5. 🙂)

sanex3339 commented 3 years ago

For @4 i'll publish version 2.6.0.

sanex3339 commented 3 years ago

Released version 2.6.0 for webpack@4. This is the version with a long lifecycle

sanex3339 commented 3 years ago

Need more tests of 3.0.0-beta.0 version. If everything will be ok, I release a stable version in a few days.