Skip to content

fix: Export 'useState' from 'nuxt/app' instead of '#imports' #782

Closed as not planned
@guaijie

Description

@guaijie

🐛 The bug

Image

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2025-02-07',
  hooks: {
    'imports:sources'(presets) {
      const index = presets.findIndex(
        (preset) => preset.from === '#app/composables/state'
      );
      presets.splice(index, 1);
    },
  },
});

As you can see from the configuration file, I removed 'useState' from autoImports.
This is normal behavior because developers can choose which modules to remove from autoImports.
So you shouldn't import modules from '#imports' anyway.

🛠️ To reproduce

https://stackblitz.com/edit/github-vrre2hcu?file=nuxt.config.ts

🌈 Expected behavior

no response

ℹ️ Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions