Skip to content

Can I tell babel-minify to mangle top level variables? #721

Description

@FezVrasta

I have a library that sets some variables inside my module files.

const isBrowser =
  typeof window !== 'undefined' && typeof window.document !== 'undefined';

export default class MyLib {
  constructor() {
    return isBorwser;
  }
}

When babel-minify minifies the code, it becomes:

// minify test.js | prettier
const isBrowser =
  "undefined" != typeof window && "undefined" != typeof window.document;
export default class MyLib {
  constructor() {
    return isBorwser;
  }
}

As you can see, the isBrowser variable name is not mangled.

Can I tell babel-minify to mangle this variable name? It is defined inside a module, so it's not going to get exposed to the global scope, and even if, I would anyway like to mangle it because I know it's not going to be used by anyone else.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions