Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

perf(nuxt)!: remove legacy app context#5630

Merged
pi0 merged 5 commits intomainfrom
fix/legacy-app
Jul 6, 2022
Merged

perf(nuxt)!: remove legacy app context#5630
pi0 merged 5 commits intomainfrom
fix/legacy-app

Conversation

@danielroe
Copy link
Member

@danielroe danielroe commented Jun 27, 2022

🔗 Linked issue

resolves nuxt/nuxt#14002

❓ 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

We are currently including a legacy plugin that creates a proxy converting the Nuxt 3 app interface to a Nuxt 2 compatible context. This is probably not needed in majority of new apps, but it is still included in bundle.

This PR completely removes the legacy context feature.

👉 Migration

If you are using plugins (perhaps injected by a module) that are relying on the Nuxt 2 format of (context, inject) => void then it needs to be updated to the new Nuxt 3 format of (nuxtApp) => void: https://v3.nuxtjs.org/guide/directory-structure/plugins#creating-plugins

Moreover, if you are relying on the globally available legacy-format window.$nuxt you will need to inject it yourself.

📝 Checklist

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

@danielroe danielroe added enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Jun 27, 2022
@danielroe danielroe requested a review from pi0 June 27, 2022 10:27
@danielroe danielroe self-assigned this Jun 27, 2022
@netlify
Copy link

netlify bot commented Jun 27, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit 7fca057
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62c36bbc8d3e8a000942a83b

@pi0
Copy link
Member

pi0 commented Jun 27, 2022

Do you have a benchmark of prod bundle size impact and percentage savings? It is considerably large, I see no reason to even keep backward-compatible code into the final release.

@danielroe
Copy link
Member Author

This PR will mean by default this plugin is not included in the bundle. The impact was ~4/92 kB of uncompressed JS (saving approx 4%). Worth mentioning that previously because the components plugin was not wrapped in defineNuxtPlugin, by default the legacy app plugin was always running.

@pi0
Copy link
Member

pi0 commented Jun 27, 2022

Then let's remove it as soon as possible to avoid misleading behavior. 4.5Kb is considerable (although gzip is probably much less in entry bundle). I initially added it for vue devtool and with intention of supporting Nuxt 2 compatible modules injecting a plugin but today it seems we need to migrate them anyway. It wouldn't worth to continue experimenting...

@danielroe
Copy link
Member Author

Sounds good to me! Will update 👍

@danielroe
Copy link
Member Author

Note to self: an example of a plugin that does require this is https://github.com/moritzsternemann/vue-plausible/blob/main/src/nuxt-plugin.ts.

@danielroe danielroe changed the title perf(nuxt)!: require explicit opt-in for legacy app context normalization perf(nuxt)!: remove legacy app context Jul 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce compatibility layer via feature flag

2 participants