-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use human-readable variable names instead of $a3b86e0361d88a0cf0c1608dc4320503$$interop$default
#6092
Comments
I'm curious what the output looks like with Webpack's module concatenation mode... |
heh, related 2018 closed request webpack/webpack#5691 Input changed to avoid being detected as a noop: export default function square ( x ) {
console.log(x * x);
}
However, incredibly, once I let it minify it:
(()=>{"use strict";console.log(1)})(); |
As a direct comparison:
(function () {
function $c85f682ae4f0d253760e24f58010a7ef$export$default(x) {
console.log(x * x);
}
$c85f682ae4f0d253760e24f58010a7ef$export$default(1);
})(); Already much better than Webpack 👆 🙌 although the variable names do seem more obfuscated
!function(){var o;o=1,console.log(o*o)}(); |
I've also dreamt about this when debugging unminified builds. But parcel's scope hoisting is so awesome that I haven't dared to complain 😁 |
These two use a module registry at runtime These two perform module concatentation/scope hoisting: |
In most cases, this doesn't matter because the code will be run through a minifier later anyway. Variables are only renamed in production builds, so dev builds don't have this problem. I would say the main use case for this is when building libraries, where you aren't running a minifier. So I see this as a different kind of "optimization" (for readability as opposed to size). I think an optimizer plugin could possibly be built to do this. Source maps should have enough information - each mapping has an optional I don't think it's possible in the current architecture to keep the original names from the beginning, because files are processed in parallel and there's no way to know when a collision might occur. |
I think simply moving the hexadecimal portion of the generated name to the end would go a long way to improve stack trace readability. In situations where sourcemaps aren't available, I think the generated names are descriptive enough, it's just the hex portion at the beginning that throws me off as I'm scanning through a stack trace or stepping through code. The real pain is needing to scroll horizontally just to get an idea of what function or variable name is being used. |
I ran into this while bundling TS files into standalone browser scripts that expose functions and variables in global scope (legacy codebase, includes plain JS). When Parcel changes variables names in global scope, it prevents other code from accessing those things. I switched to the TSC transformer which doesn't change variable names. |
I'm also being impacted by this issue. Stack traces throughout my infrastructure are displaying hashed function names for functions exported from intermediate/bundled-in modules when running Node executables deployed from a Parcel build, e.g.
While it is possible to trace this back correctly thanks to the sourcemap, it is often possible for a devops engineer to diagnose an issue instantly when the function names are readable, rather than have to search the codebase. I would propose that the long export hash be modified so at the very least it includes the name of the original exported function.
For the record, switching to the TSC transformer as suggested here may help in some cases but it does not stop Parcel from mangling the names of intermediate ES module exports when building a bundle. |
Hi @devongovett, what is the current way to create a dev build? I searched around and found: NODE_ENV=development parcel build <entrypoint> --no-minify
I also tested |
As discussed in #4687
Also possibly related: #5862
🙋 feature request
Parcel generates long variable names for imported modules, presumably to avoid conflict. Rollup however avoids conflict and still preserves the original variable names where possible: example. Can this be done in Parcel too?
🤔 Expected Behavior
Should generate something like:
😯 Current Behavior
… instead it generates something like:
💁 Possible Solution
Rollup’s code might have answers, but I'm not familiar with it.
🔦 Context
My extension has been suddenly rejected by the Chrome Extension Store due to "obfuscation". I'm trying to resolve this issue with them and I'll probably temporarily use variable name mangling as an interim solution, but mangled variable names aren't particularly human-readable either.
Also, generally speaking, readable variable names can help during development, where minification doesn't apply.
The text was updated successfully, but these errors were encountered: