packages/core/parcel-bundler/src/scope-hoisting/mangler.js
function mangleScope(scope) {
  let newNames = new Set();

  // Sort bindings so that more frequently referenced bindings get shorter names.
  let sortedBindings = Object.keys(scope.bindings).sort(
    (a, b) =>
      scope.bindings[b].referencePaths.length -
      scope.bindings[a].referencePaths.length
  );

  for (let oldName of sortedBindings) {
    let i = 0;
    let newName = '';

    do {
      newName = getIdentifier(i++);
    } while (
      newNames.has(newName) ||
      !canRename(scope, scope.bindings[oldName], newName)
    );

    rename(scope, oldName, newName);
    newNames.add(newName);
  }
}
function mangleScope(scope) {
  let newNames = new Set();

  // Sort bindings so that more frequently referenced bindings get shorter names.
  let sortedBindings = Object.keys(scope.bindings).sort(
    (a, b) =>
      scope.bindings[b].referencePaths.length -
      scope.bindings[a].referencePaths.length
  );

  for (let oldName of sortedBindings) {
    let i = 0;
    let newName = '';

    do {
      newName = getIdentifier(i++);
    } while (
      newNames.has(newName) ||
      !canRename(scope, scope.bindings[oldName], newName)
    );

    rename(scope, oldName, newName);
    newNames.add(newName);
  }
}
function mangleScope ( scope ) { let newNames = new Set ( ) ; // Sort bindings so that more frequently referenced bindings get shorter names. let sortedBindings = Object . keys ( scope . bindings ) . sort ( ( a , b ) => scope . bindings [ b ] . referencePaths . length - scope . bindings [ a ] . referencePaths . length ) ; for ( let oldName of sortedBindings ) { let i = 0 ; let newName = '' ; do { newName = getIdentifier ( i ++ ) ; } while ( newNames . has ( newName ) || ! canRename ( scope , scope . bindings [ oldName ] , newName ) ) ; rename ( scope , oldName , newName ) ; newNames . add ( newName ) ; } }
This is a very specialized mangler designer to mangle only names in the top-level scope.
Mangling of names in other scopes happens at a file level inside workers, but we can't
mangle the top-level scope until scope hoisting is complete in the packager.

Based on code from babel-minify!
https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/charset.js
This is a very specialized mangler designer to mangle only names in the top - level scope . Mangling of names in other scopes happens at a file level inside workers but we can t mangle the top - level scope until scope hoisting is complete in the packager .