Closed adl-g closed 5 years ago
The original names should be exported for both cases (default and named exports), it's covered by following tests: transform-named-export-function and transform-default-export-named-function. As you can see from the output it respects the original names:
export { foo };
export { foo as default };
Could you create a repo to reproduce your issue? it will help us to investigate the issue.
I created a repository for it: https://github.com/ADL-dev/babel-plugin-rewire-exports-issue-20
see comments in src/Title.js
.
uncomment the second version in Title.js
file and you will see the tests failing.
@ADL-dev, your example is missing .babelrc
, but I got it working. Thanks, I'll take a look.
oh sorry, added .babelrc
file now
@ADL-dev, could you please try the new pre-release version?
npm install -D babel-plugin-rewire-exports@alpha
I'll release a new stable version once I run more tests on it.
@asapach I tried it and it is working great! thanks you!
I encounter a problem when trying to use named export / default export of React functional component.
it only happens if I export and define my component at the same line. it only happens if I export functional component, not occur for class component.
if i export my component this way:
or with default export this way:
then my tests fails because they try to find a component with the name
Foo
, but the component is imported as_Foo
so the render output is:<_Foo>...</_Foo>
btw, I'm using Mocha, Chai, Enzymebut if I export the component after its declaration like this:
or with default export this way:
then my tests work as expected and
Foo
is rendered as<Foo>
Is there something I missed? Can you fix it?
Thanks a lot!