-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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: exportName metadata for JSXMemberExpressions that use named imports #4403
fix: exportName metadata for JSXMemberExpressions that use named imports #4403
Conversation
🦋 Changeset detectedLatest commit: ae9f82f The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -205,7 +205,8 @@ export default function astroJSX(): PluginObj { | |||
break; | |||
} | |||
if (namespace.at(0) === local) { | |||
path.setData('import', { name: imported, path: source }); | |||
const name = imported === '*' ? imported : tagName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Components that use an ImportNamespaceSpecifier
will have their import name
set to '*'
, which is handled here:
astro/packages/astro/src/jsx/babel.ts
Lines 71 to 73 in dfa3519
if (meta.name === '*') { | |
meta.name = getTagName(node).split('.').slice(1).join('.')!; | |
} |
In other cases, we'll just use the tag name, which will be resolved in the same way that the namespace is. That happens here:
astro/packages/astro/src/runtime/server/astro-island.ts
Lines 72 to 75 in dfa3519
this.Component = componentModule; | |
for (const part of componentExport.split('.')) { | |
this.Component = this.Component[part] | |
} |
Note that @natemoo-re is going to work on this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix, looks great!
Changes
Fix for issue described in: #4389
Components declared using
JSXMemberExpression
nodes were not hydrating properly, due to how thecomponent-export
attribute was being determined in theastroJSX
Babel plugin.Example:
The
component-export
attribute for this component (<Namespace.SampleComponent client:load />
) was'SampleComponent'
, but will now be'Namespace.SampleComponent'
, which can be resolved properly via the hydration logic here:astro/packages/astro/src/runtime/server/astro-island.ts
Lines 72 to 75 in dfa3519
Testing
Tested locally. I also added to the existing
e2e/namespaced-component.test.js
.Docs
No documentation updates needed. This is a minor bug fix.