Skip to content

Mangling exports #479

@boopathi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions