Skip to content

feat: add hmr support for compound components #518

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Newbie012
Copy link

closes #493

Copy link
Member

@ArnaudBarre ArnaudBarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this and adding the test!
I don't think we need to logic twice, I think this can be done like this:

if (isLikelyComponentType(exportValue)) {
  register(...)
} else if (/* is obj & all keys are component */ ) {
      for (const subKey in exportValue) {
        register(
          exportValue[subKey],
          filename + ' export ' + key + '$' + subKey,
        )
      }
}

@@ -545,6 +555,13 @@ function isLikelyComponentType(type) {
}
}

function isPlainObject(obj) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we need this?
typeof obj === "object" && obj !== null should be enough no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but in your condition, values such as Date, [], Map, etc will return true as well, which is not what we want. Or maybe it's an oversight on my end?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum true, it will still be possible to loop over keys but it's cleaner to not do it for these so we can keep this

@Newbie012
Copy link
Author

I'll check and keep you posted

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.

Add HMR Support for Compound Component Pattern
2 participants