Skip to content

Mangling exports #479

Open
Open

Description

@boopathi

Bug: Babili mangles exports

Possible solutions:

// case 1
// in
export const LongName=foo
// out
const a=foo; export {a as LongName}

// case 2 single reference - export statement
// in
const LongName=foo;export {LongName}
// out
const a=foo;export {a as LongName}

// also in case 2,
// DCE could have combined the declaration and the export statement
// as export declarations are statically analysed
// it doesn't matter where it is placed in the file (with ref.loc >= defn.loc)
// replacing const x = foo; with export const x = foo; is a safe replacement

const LongName=foo;export {LongName}
export const LongName=foo;

// case 3 referenced multiple times
// in
const LongName=foo;const Long2Name=()=>LongName(bar)+LongName(baz);export {LongName};export {Long2Name}
// out 1
const a=foo;const b=()=>a(bar)+a(baz);export {a as LongName};export {b as Long2Name}
// out 2
export const LongName=foo;export const Long2Name=()=>LongName(bar)+LongName(baz)

/cc @jdalton

Activity

  1. added
    bug
    on Mar 17, 2017
  2. probins commented on Mar 22, 2017

    @probins
    Contributor

    perhaps worth stressing that this is only an issue for named exports; default export names can be mangled without problem (as at present). As mentioned in #394, the logic should be similar with imports: default import names can be mangled without problem; named imports could be mangled by using import {longName as a}.

  3. added this to the 1.0 milestone on Apr 8, 2017
  4. added and removed
    bug
    on May 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions