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