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

perf!(nuxt3): disable global components by default #3305

Merged
merged 2 commits into from
Feb 18, 2022
Merged

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Feb 18, 2022

πŸ”— Linked issue

resolves nuxt/nuxt#12903

❓ 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

This change defaults to only using the loader to register components, rather than generating async chunks for every possible component. (This makes a huge difference with component libraries, as we don't need to compile all of their components, just the ones needed.)

This also adds a top-level components.global option to set the default value for component dirs which haven't set the global value.

πŸ‘‰ Migration

If you were relying on global registration of your components - for example, because you wanted to use a dynamically computed component name (e.g. <component :is="'icon-' + myIcon" />) then you can re-enable the previous behaviour by setting components.global:

  import { defineNuxtConfig } from 'nuxt3'
  
  export default defineNuxtConfig({
    components: {
+     global: true,
+     dirs: ['~/components']
    },
  })

πŸ“ Checklist

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

@danielroe danielroe added bug Something isn't working enhancement New feature or request nuxt3 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Feb 18, 2022
@danielroe danielroe requested a review from pi0 February 18, 2022 00:46
@danielroe danielroe self-assigned this Feb 18, 2022
@netlify
Copy link

netlify bot commented Feb 18, 2022

βœ”οΈ Deploy Preview for nuxt3-docs canceled.

πŸ”¨ Explore the source changes: 1ad8616

πŸ” Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/620eec579dc30400087cbd6e

@danielroe danielroe changed the title perf: default to locally imported components perf!: default to locally imported components Feb 18, 2022
@pi0 pi0 changed the title perf!: default to locally imported components perf!(nuxt3): disable global components by default Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x bug Something isn't working enhancement New feature or request nuxt3 🍰 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.

Unnecessary chunks are loading in production build
2 participants