Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Mangling exports #479

Open
boopathi opened this issue Mar 17, 2017 · 1 comment
Open

Mangling exports #479

boopathi opened this issue Mar 17, 2017 · 1 comment
Milestone

Comments

@boopathi
Copy link
Member

boopathi commented Mar 17, 2017

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

@boopathi boopathi added the bug Confirmed bug label Mar 17, 2017
@probins
Copy link
Contributor

probins commented Mar 22, 2017

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}.

@boopathi boopathi added this to the 1.0 milestone Apr 8, 2017
boopathi added a commit that referenced this issue May 4, 2017
+ Ref #479

This completes one part of the problem where now Named exports are no
more mangled. But the other part, where we can convert

```js
const foo = bar;
export {foo};
```

to

```js
export const foo = bar;
```

is yet to be explored in DCE or other plugins.
boopathi added a commit that referenced this issue May 5, 2017
+ Ref #479

This completes one part of the problem where now Named exports are no
more mangled. But the other part, where we can convert

```js
const foo = bar;
export {foo};
```

to

```js
export const foo = bar;
```

is yet to be explored in DCE or other plugins.
@boopathi boopathi added enhancement and removed bug Confirmed bug labels May 9, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants