Skip to content

perf(nuxt): add vue.optionsApi and disable it for v5+ - #35791

Merged
danielroe merged 3 commits into
mainfrom
perf/options-api
Jul 22, 2026
Merged

danielroe merged 3 commits into
mainfrom
perf/options-api

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

as most users of Nuxt are probably using <script setup> rather than the Options API, this disables Options API use by default.

it's straightforward to re-enable if you are using it, and it saves ~6/7kB for people who aren't:

export default defineNuxtConfig({
  vue: {
    optionsApi: true
  }
})

@danielroe
danielroe requested a review from cernymatej July 21, 2026 23:53
@github-actions github-actions Bot added the ✨ enhancement New feature or improvement to existing functionality label Jul 21, 2026
@danielroe danielroe added discussion 5.x and removed ✨ enhancement New feature or improvement to existing functionality labels Jul 21, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35791

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35791

nuxt

npm i https://pkg.pr.new/nuxt@35791

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35791

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35791

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35791

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35791

commit: cfe8410

@danielroe danielroe changed the title feat(nuxt): add vue.optionsApi and disable it for v5+ perf(nuxt): add vue.optionsApi and disable it for v5+ Jul 22, 2026
@codspeed

codspeed Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing perf/options-api (cfe8410) with main (d2639f8)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@danielroe
danielroe added this pull request to the merge queue Jul 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 22, 2026
Base automatically changed from perf/global-fetch to main July 22, 2026 08:43
@coderabbitai

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/1.getting-started/18.upgrade.md`:
- Line 599: Update the compatibilityVersion: 5 documentation to state that Vue’s
__VUE_OPTIONS_API__ flag defaults to false, while preserving the exception that
an explicit vue.optionsApi: true setting enables it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f9a0f109-244f-4333-b4fb-43cae5fce28d

📥 Commits

Reviewing files that changed from the base of the PR and between d2639f8 and cfe8410.

📒 Files selected for processing (8)
  • docs/1.getting-started/18.upgrade.md
  • packages/schema/src/config/app.ts
  • packages/schema/src/config/vite.ts
  • packages/schema/src/types/schema.ts
  • packages/webpack/src/presets/vue.ts
  • test/bundle.test.ts
  • test/fixtures/basic/nuxt.config.ts
  • test/fixtures/runtime-compiler/nuxt.config.ts


#### What Changed

With `compatibilityVersion: 5`, Nuxt sets Vue's [`__VUE_OPTIONS_API__`](https://vuejs.org/api/compile-time-flags#VUE_OPTIONS_API) feature flag to `false`, which compiles Vue's Options API runtime out of the client bundle.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Clarify that this is the default, not an unconditional value.

The resolver preserves an explicit vue.optionsApi: true, so this should say the flag defaults to false with compatibilityVersion: 5 unless the option is explicitly enabled.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/1.getting-started/18.upgrade.md` at line 599, Update the
compatibilityVersion: 5 documentation to state that Vue’s __VUE_OPTIONS_API__
flag defaults to false, while preserving the exception that an explicit
vue.optionsApi: true setting enables it.

@danielroe
danielroe added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit b656203 Jul 22, 2026
35 checks passed
@danielroe
danielroe deleted the perf/options-api branch July 22, 2026 09:21
This was referenced Jul 22, 2026
s1gr1d added a commit to getsentry/sentry-javascript that referenced this pull request Sep 3, 2026
Nuxt 5 disables Vue's Options API by default (nuxt/nuxt#35791), which
turns `app.mixin()` into a silent no-op.

Before we replace the mixin with a runtime mechanism, this PR pins down
what it does today, so the replacement can be proven
behavior-preserving. No SDK code changes.

- Unit tests document that the root component is always tracked, per
hook (`create`, `update`, `activate`), and that spans are keyed by
operation.
- vue-3 and nuxt-4 e2e now assert the root spans (`Application Render`,
`Vue <Root>`).
- nuxt-5 drops the `vue: { optionsApi: true }` escape hatch, so it now
shows the Nuxt 5 default (tests are marked `test.fail`)

Reference: #23375
s1gr1d added a commit to getsentry/sentry-javascript that referenced this pull request Sep 22, 2026
…24174)

Nuxt 5 disables Vue's Options API by default (nuxt/nuxt#35791). That
turns `app.mixin()` into a silent no-op, and every Vue UI span comes
from that mixin: `Application Render` and `Vue <Root>` disappear with no
signal.

When the mixin is dropped, the SDK now wraps `app.mount()` and calls the
same mixin hook bodies, so the default spans stay identical. The Nuxt
SDK additionally extends the root span until `<Suspense>` resolves.

`trackComponents` still needs the Options API and warns when it is lost.
Vue 2 behavior stays unchanged (always needs Options API as it's not
possible otherwise).

Closes #23375

Docs follow-up: getsentry/sentry-docs#19290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants