Skip to content

RC-8 composables auto-imports regression for /composables/<folder>/index.ts #14576

Closed

Description

@Kapcash

Environment

(I ran this on stackblitz, but I reproduce on local with a more "complex" setup)

RootDir: /home/projects/github-cqsm6q-nwppro
Nuxt project info:


  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: css
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. Creates a file following this path format: /composables/afolder/index.ts
  2. Export at least one member (variable, functions...)
  3. Use any exported member of this module in a nuxt page / plugin / component
    -> Nuxt will complain this doesn't exists, but it should be auto-imported.

The exported members of this file isn't present in the .nuxt/imports.d.ts nor .nuxt/auto-imports.d.ts.

https://stackblitz.com/edit/github-cqsm6q-nwppro?file=pages/index.vue

Describe the bug

The exported members of modules under /composables/<any-folder>/index.[jt]s are not auto-imported anymore.

Additional context

Replacing the nuxt dependency from 3.0.0-rc.8 to 3.0.0-rc.3 makes the project work as expected.

Logs

No response

Activity

  1. DamianGlowala commented on Aug 14, 2022

    @DamianGlowala
    Member

    Have a look at the following PR introduced in the RC 7: nuxt/framework#6025

  2. HomWang commented on Aug 15, 2022

    @HomWang
    Contributor
  3. added a commit that references this issue on Aug 15, 2022
  4. HomWang commented on Aug 15, 2022

    @HomWang
    Contributor

    in nuxt.config.ts add

    import { defineNuxtConfig } from 'nuxt';
    
    export default defineNuxtConfig({
      css: ['~/assets/main.css'],
      autoImports: {
        dirs: [
          'composables', // top-level modules
          'composables/*/index.{ts,js,mjs,mts}', // one level directories's index.js,
          //'composables/**', // Scan all nested directories
        ],
      },
    });
    
    
  5. Kapcash commented on Aug 15, 2022

    @Kapcash
    ContributorAuthor

    Thank you! I missed the changed on the documentation / migration guide indeed.
    I just updated my nuxt.config and it's working fine :)

  6. transferred this issue fromnuxt/frameworkon Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions