Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(babel-plugin-export-metadata): add case for export default memo() #1417

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

yoo2001818
Copy link
Contributor

Description

babel-plugin-export-metadata currently doesn't handle using call expression inside export default, such as:

export default React.memo(Component)

This means it won't include __filemeta in the default export, so <Props> won't work correctly because it can't resolve the file path.

It resolves such case by separating expression and export default, to allow injecting __filemeta correctly.

const __DOCZ_DUMMY_EXPORT_DEFAULT = React.memo(Component)
export default __DOCZ_DUMMY_EXPORT_DEFAULT

@yoo2001818
Copy link
Contributor Author

I wasn't able to reproduce this problem in development build, probably because hot loader already rewrites code like this. However, production build doesn't include __filemeta.

Before 9d5b129#diff-5cc2196461930cb24939fb44764d656b, lack of __filemeta simply ended up not showing Props (Because componentName was null). However, after that commit, it broke production build - it threw an error.

The reason was somewhat weird - pascal-case package throws an error when null is passed. At first, I tried to resolve the problem by adding simple null check like pascalCase(componentName || ''), but I thought it was better to fix the fundamental problem.

@rakannimer
Copy link
Contributor

Thanks @yoo2001818 for the PR !

@rakannimer rakannimer merged commit 31ebd08 into doczjs:master Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants