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: allow use with script tag #956

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Conversation

wattanx
Copy link
Collaborator

@wattanx wattanx commented Nov 3, 2023

πŸ”— Linked issue

Fixes: #952

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

When using script setup in Vue 2, there may be cases where the script tag is used in conjunction.
If export default is declared in script, then

<script setup>
definePageMeta({
  middleware: ['test']
})
</script>

<script>
export default {
  name: 'Test'
}
</script>

transformed(vite):

const __default__ = {
  name: "Test"
}

export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  setup(__props) {
    definePageMeta({
      middleware: ["test"]
    });
    return { __sfc: true };
  }
});

The content of export default is SpreadElement and there is no key.
So I fixed it to check if there is a key or not.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@wattanx wattanx changed the title fix: allow use with script tags fix: allow use with script tag Nov 3, 2023
@danielroe danielroe merged commit f225b80 into main Nov 3, 2023
9 checks passed
@danielroe danielroe deleted the fix/page-meta-setup-and-script branch November 3, 2023 22:26
This was referenced Nov 3, 2023
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.

definePageMeta does not work in some cases.
2 participants