Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper exports when auto-import is turned off #288

Open
lukasaric opened this issue Oct 6, 2024 · 4 comments
Open

Add proper exports when auto-import is turned off #288

lukasaric opened this issue Oct 6, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@lukasaric
Copy link

lukasaric commented Oct 6, 2024

🆒 Your use case

If Nuxt project has autoImports turned off, when you want to import some composable from nuxt/scripts you need to do something like this:

import { useScriptGoogleTagManager } from '@nuxt/scripts/dist/runtime/registry/google-tag-manager'

Which also does not work and it leads to this error:

Image

🆕 The solution you'd like

Add Nuxt aliases or something similar so the developer can easily import composable or components explicitly.

Example:

// re-export everything through the root index barrel file
import { useScriptGoogleTagManager } from '@nuxt/scripts

// re-export just for certain folder index barrel file
import { useScriptGoogleTagManager } from '@nuxt/scripts/registry

// or avoid using barrel files due to performance issues and use at least Nuxt alias and directly import file
import useScriptGoogleTagManager from '@nuxt/scripts/registry/google-tag-manager.ts

🔍 Alternatives you've considered

No response

ℹ️ Additional info

No response

@lukasaric lukasaric added the enhancement New feature or request label Oct 6, 2024
@harlan-zw
Copy link
Collaborator

Hi, I believe the correct usage here is to just import explicitly from #imports

import { useScriptGoogleTagManager } from '#imports'

I'm open to adding a domain-specific alias for the registry scripts as I'm already using a few, but would need a valid use case.

  • #nuxt-scripts -> types
  • #nuxt-scripts-utils -> utils
  • #nuxt-scripts-validator -> valibot or mock

@lukasaric
Copy link
Author

lukasaric commented Oct 15, 2024

Hi, I believe the correct usage here is to just import explicitly from #imports

import { useScriptGoogleTagManager } from '#imports'
I'm open to adding a domain-specific alias for the registry scripts as I'm already using a few, but would need a valid use case.

  • #nuxt-scripts -> types
  • #nuxt-scripts-utils -> utils
  • #nuxt-scripts-validator -> valibot or mock

When you import it from #imports it imports the wrong one 🙈 .
Other than that, there are multiple issues in general with #imports (e.g go to definition etc) so there are a lot reasons why it would be good improve imports and add aliases as you suggested. @harlan-zw

Image

@lukasaric
Copy link
Author

@harlan-zw Hey!
Is there any resolution here? :)

@rpauls-scayle
Copy link

Or is the anything we can do to support, e.g. creating a draft pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants