bridge icon indicating copy to clipboard operation
bridge copied to clipboard

TypeError for bridge:{autoImports} in nuxt.config.ts

Open stephenjason89 opened this issue 3 years ago • 9 comments
trafficstars

Environment



Reproduction

Add this to nuxt.config.ts

    bridge: {
        autoImports: {
            dirs: [
                // Scan composables from nested directories
                'composables/**',
            ],
        },
    },

Describe the bug

image

Additional context

No response

Logs

No response

stephenjason89 avatar Jul 27 '22 11:07 stephenjason89

You can set autoimports only false or true.

antlionguard avatar Jul 27 '22 11:07 antlionguard

@antlionguard is this only applicable for nuxt 3? image

stephenjason89 avatar Jul 27 '22 11:07 stephenjason89

@antlionguard is this only applicable for nuxt 3? image

No but you using wrong. You need to put directly inside the defineConfig not the bridge object.

antlionguard avatar Jul 27 '22 11:07 antlionguard

@antlionguard Thank you for pointing it out. I am trying it out now. I would suggest however to group all autoImport related to that object.

so instead of

    // Auto import components (https://go.nuxtjs.dev/config-components)
    components: true,

we can maybe do it like

    autoImports: {
        components: true,
        composables:{
            dirs: [
                // Scan composables from nested directories
                'composables/**',
            ]
        }
    },

stephenjason89 avatar Jul 27 '22 13:07 stephenjason89

@antlionguard Thank you for pointing it out. It works like a charm. I would suggest however to group all autoImport related to that object.

so instead of

    // Auto import components (https://go.nuxtjs.dev/config-components)
    components: true,

we can maybe do it like

    autoImports: {
        components: true,
        composables:{
            dirs: [
                // Scan composables from nested directories
                'composables/**',
            ]
        }
    },

I think it might too. You should open new discussion for this suggestion and you feel free closing this issue.

antlionguard avatar Jul 27 '22 13:07 antlionguard

@antlionguard I'm sorry, i thought it was working image image

image

stephenjason89 avatar Jul 27 '22 13:07 stephenjason89

This problem should have been resolved with #145 but i guess it still is. @danielroe

antlionguard avatar Jul 28 '22 07:07 antlionguard

Ah, yes. This was an upstream change in unimport. Please see this migration guide. It is for Nuxt 3 but applies in this case.

danielroe avatar Jul 28 '22 09:07 danielroe

@danielroe image

for non named exports(default) should i do it like export { default as useToast } from './utils/useToast'

stephenjason89 avatar Jul 28 '22 15:07 stephenjason89

To be clear, bridge.imports (we've recently renamed it) should be set to true/false. Configuration is provided in a top-level imports key.

danielroe avatar Sep 15 '22 09:09 danielroe