Skip to content

Commit

Permalink
fix(vue-component-meta): prevent reference error when using re-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
larsrickert committed Mar 4, 2024
1 parent ba80f3c commit 9e01244
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion code/frameworks/vue3-vite/src/plugins/vue-component-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ export async function vueComponentMeta(): Promise<PluginOption> {
// we can only add the "__docgenInfo" to variables that are actually defined in the current file
// so e.g. re-exports like "export { default as MyComponent } from './MyComponent.vue'" must be ignored
// to prevent runtime errors
if (new RegExp(`export {.*${name}.*}`).test(src)) {
if (
new RegExp(`export {.*${name}.*}`).test(src) ||
new RegExp(`export \\* from ['"]\\S*${name}['"]`).test(src) ||
// when using re-exports, some exports might be resolved via checker.getExportNames
// but are not directly exported inside the current file so we need to ignore them too
!src.includes(name)
) {
return;
}

Expand Down

0 comments on commit 9e01244

Please sign in to comment.