[x] … and wait for human validation. Regarding that bit:
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!
I'm gonna need an issue to keep track of the issues regarding this seemingly simple task:
eval()
during build process (they're only there for NodeJS support).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!