jelmervdl / translatelocally-web-ext

TranslateLocally for the Browser is a web-extension that enables client side in-page translations for web browsers.
https://addons.mozilla.org/en-GB/firefox/addon/translatelocally-for-firefox/
Mozilla Public License 2.0
65 stars 3 forks source link

Rebranding to TranslateLocally #48

Closed jelmervdl closed 1 year ago

jelmervdl commented 1 year ago

I'm gonna need an issue to keep track of the issues regarding this seemingly simple task:

I've attempted this yesterday for like 6 hours but webpack is just a terrible experience.

I've figured out that using DefinePlugin I can make the if-statement that contains the bits always evaluate to false. This would then cause Terser, webpack's built-in minimizer/minifier to drop that code altogether. But I don't really want it to mangle all of my code. Ideally it would keep it readable. Okay, that's an option (sort of, it still strips all whitespace… the "beautifier" has been deprecated).

But it also mangles the var Modules = {} bit of code in there which then causes the imported WASM binding code to fail. And it doesn't seem possible to mention in the source code itself that that particular variable should be left alone. So I can't use webpack's minifier to tree-shake that particular if-statement.

And now I'm wondering how hard it would be to add a small plugin that just removes that particular if-statement from the parse tree because webpack has access to the full AST!

jelmervdl commented 1 year ago

Done! https://addons.mozilla.org/en-GB/firefox/addon/translatelocally-for-firefox/