mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
perf!(nuxt3): disable global components by default (#3305)
This commit is contained in:
parent
3d258d304e
commit
87eb7d0d39
@ -68,6 +68,7 @@ export default defineNuxtModule<ComponentsOptions>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
global: componentOptions.global,
|
||||||
...dirOptions,
|
...dirOptions,
|
||||||
// TODO: https://github.com/nuxt/framework/pull/251
|
// TODO: https://github.com/nuxt/framework/pull/251
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
@ -28,7 +28,7 @@ export const componentsTemplate = {
|
|||||||
getContents ({ options }: { options: ComponentsTemplateOptions }) {
|
getContents ({ options }: { options: ComponentsTemplateOptions }) {
|
||||||
return `import { defineAsyncComponent } from 'vue'
|
return `import { defineAsyncComponent } from 'vue'
|
||||||
|
|
||||||
const components = ${genObjectFromRawEntries(options.components.filter(c => c.global !== false).map((c) => {
|
const components = ${genObjectFromRawEntries(options.components.filter(c => c.global === true).map((c) => {
|
||||||
const exp = c.export === 'default' ? 'c.default || c' : `c['${c.export}']`
|
const exp = c.export === 'default' ? 'c.default || c' : `c['${c.export}']`
|
||||||
const comment = createImportMagicComments(c)
|
const comment = createImportMagicComments(c)
|
||||||
|
|
||||||
|
@ -92,5 +92,16 @@ export interface ComponentsDir extends ScanDir {
|
|||||||
|
|
||||||
export interface ComponentsOptions {
|
export interface ComponentsOptions {
|
||||||
dirs: (string | ComponentsDir)[]
|
dirs: (string | ComponentsDir)[]
|
||||||
|
/**
|
||||||
|
* The default value for whether to globally register components.
|
||||||
|
*
|
||||||
|
* When components are registered globally, they will still be directly imported where used,
|
||||||
|
* but they can also be used dynamically, for example `<component :is="`icon-${myIcon}`">`.
|
||||||
|
*
|
||||||
|
* This can be overridden by an individual component directory entry.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
global?: boolean
|
||||||
loader?: boolean
|
loader?: boolean
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user