Skip to content

Weird behaviour with export #791

Closed

Description

@rafaeleyng

Hello

I was having trouble using this (with the Webpack loader) in my project. I ended up finding that the problem was in some files where I had code like this:

import funcA from './funcA'
import funcB from './funcB'

export {
  funcA,
  funcB,
}

With that, some other module that would try to import and use funcA would not work (would get undefined or something like it). It seems that in one point the identifiers were changed but not in the other point.

When I changed the code to this, it worked:

export { default as funcA } from './funcA'
export { default as funcB } from './funcB'

I'm ok with doing this change, but I would like to better understand whether I'm doing something wrong, and why making this change solved the problem.

Thanks!

Activity

  1. sanex3339 commented on Oct 27, 2020

    @sanex3339
    Member

    Hmm. Obfuscated code looks like that:

    import _0x99b4d7 from './funcA';
    import _0x3e429c from './funcB';
    export {
        _0x99b4d7,
        _0x3e429c
    };
    

    So it renames the imported module identifiers.
    Have to think about how to avoid this.

  2. sanex3339 commented on Oct 27, 2020

    @sanex3339
    Member

    So, the idea is to convert all exports

    export {foo};
    

    to the

    export {foo as foo};
    

    view.

    After identifiers rename this construction becomes

    const _0x485b3c = 1;
    export {_0x485b3c as foo};
    
  3. sanex3339 commented on Oct 27, 2020

    @sanex3339
    Member

    PR: #792

    Can you try it?

  4. sanex3339 commented on Oct 28, 2020

    @sanex3339
    Member

    Merged into master. Please try it from master branch.
    I'll release this fix later today.

  5. sanex3339 commented on Oct 28, 2020

    @sanex3339
    Member

    Released as 2.6.3. Please try it.

  6. rafaeleyng commented on Nov 9, 2020

    @rafaeleyng
    Author

    Sorry for the delay, somehow I messed up my notification settings and didn't see this earlier.

    I've tested the latest 2.8.0 and it works perfectly (I've reverted my code to the original and worked both with the new and old). Thanks for the quick response!

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions