Skip to content

Avoid using <script setup nuxt> #101

Closed
nuxt/framework
#579

Description

@pi0

Discussing with @yyx990803, it is preferred to not introduce new attributes to <script setup> while we used nuxt keyword to add defineNuxtComponent wrapper that allows using asyncData without await and handles enqueued promises but wrapping every component also doesn't make sense since usually, only some components have data fetching logic and the additional ticks overhead to the rest of components affects overall performance as we introduce more logic into defineNuxtComponent.

Some ideas:

  • Keep using nuxt
  • Use <script setup> and wrap all (ignore perf)
  • Use <script setup async> (new convention adding to SFCs)
  • Auto-detect wrapper requirement based on syntax usage ([useAsyncData,useFetch] -- extendable) and require explicit await for composables
  • Introduce additional await nuxtPromises() utility to be used at the end of the file

Discussing with the team (@atinux @antfu and @danielroe) auto detect and using <script setup> again is best option so far. Yet we can think of other aspects.


On a related topic, @yyx990803 also mentioned it is more preferred if we keep using <script setup> (over options API) in the examples. We can only use explicit defineNuxtComponent with options API in sections that need backward compatibility and automated migration scripts in order to keep supporting legacy options like asyncData, fetch, transition, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions