babel / babel/minify

Mangling exports

Open
#479 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

Bug: Babili mangles exports

Possible solutions:

```js
// 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

Contributor guide

Open the contributing guide

Research direction

Start by tracing Babili's export-mangling path using the three cases in the issue as behavioral examples. Verify how exported declarations, single-reference exports, dead-code elimination, and multiply referenced exports are handled; done means exported names remain stable while eligible local bindings are shortened without changing the examples' semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.