mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): enable injectAtEnd
to reduce circular auto-imports (#28822)
This commit is contained in:
parent
69d7448980
commit
ada1e49f5a
@ -22,6 +22,7 @@ export function createTransformPlugin (nuxt: Nuxt, getComponents: getComponentsT
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
virtualImports: ['#components'],
|
virtualImports: ['#components'],
|
||||||
|
injectAtEnd: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
function getComponentsImports (): Import[] {
|
function getComponentsImports (): Import[] {
|
||||||
|
@ -40,6 +40,7 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
|
|||||||
|
|
||||||
// Create a context to share state between module internals
|
// Create a context to share state between module internals
|
||||||
const ctx = createUnimport({
|
const ctx = createUnimport({
|
||||||
|
injectAtEnd: true,
|
||||||
...options,
|
...options,
|
||||||
addons: {
|
addons: {
|
||||||
vueTemplate: options.autoImport,
|
vueTemplate: options.autoImport,
|
||||||
|
@ -18,6 +18,7 @@ describe('imports:transform', () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
const ctx = createUnimport({
|
const ctx = createUnimport({
|
||||||
|
injectAtEnd: true,
|
||||||
imports,
|
imports,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ describe('components:transform', () => {
|
|||||||
|
|
||||||
const code = await transform('import { Foo, Bar } from \'#components\'', '/app.vue')
|
const code = await transform('import { Foo, Bar } from \'#components\'', '/app.vue')
|
||||||
expect(code).toMatchInlineSnapshot(`
|
expect(code).toMatchInlineSnapshot(`
|
||||||
"import Foo from '/Foo.vue';
|
"
|
||||||
|
import Foo from '/Foo.vue';
|
||||||
import { Bar } from '/Bar.vue';
|
import { Bar } from '/Bar.vue';
|
||||||
"
|
"
|
||||||
`)
|
`)
|
||||||
@ -28,7 +29,8 @@ describe('components:transform', () => {
|
|||||||
|
|
||||||
const code = await transform('import { Foo, LazyFoo } from \'#components\'', '/app.vue')
|
const code = await transform('import { Foo, LazyFoo } from \'#components\'', '/app.vue')
|
||||||
expect(code).toMatchInlineSnapshot(`
|
expect(code).toMatchInlineSnapshot(`
|
||||||
"import Foo from '/Foo.vue?nuxt_component=server&nuxt_component_name=Foo&nuxt_component_export=default';
|
"
|
||||||
|
import Foo from '/Foo.vue?nuxt_component=server&nuxt_component_name=Foo&nuxt_component_export=default';
|
||||||
import LazyFoo from '/Foo.vue?nuxt_component=server,async&nuxt_component_name=Foo&nuxt_component_export=default';
|
import LazyFoo from '/Foo.vue?nuxt_component=server,async&nuxt_component_name=Foo&nuxt_component_export=default';
|
||||||
"
|
"
|
||||||
`)
|
`)
|
||||||
@ -54,7 +56,8 @@ describe('components:transform', () => {
|
|||||||
|
|
||||||
const code = await transform('import { Foo, LazyFoo } from \'#components\'', '/app.vue')
|
const code = await transform('import { Foo, LazyFoo } from \'#components\'', '/app.vue')
|
||||||
expect(code).toMatchInlineSnapshot(`
|
expect(code).toMatchInlineSnapshot(`
|
||||||
"import Foo from '/Foo.vue?nuxt_component=client&nuxt_component_name=Foo&nuxt_component_export=default';
|
"
|
||||||
|
import Foo from '/Foo.vue?nuxt_component=client&nuxt_component_name=Foo&nuxt_component_export=default';
|
||||||
import LazyFoo from '/Foo.vue?nuxt_component=client,async&nuxt_component_name=Foo&nuxt_component_export=default';
|
import LazyFoo from '/Foo.vue?nuxt_component=client,async&nuxt_component_name=Foo&nuxt_component_export=default';
|
||||||
"
|
"
|
||||||
`)
|
`)
|
||||||
|
Loading…
Reference in New Issue
Block a user