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

Problem with type imports when exported with nuxt layers #2408

Open
hugobqd opened this issue Oct 17, 2024 · 1 comment
Open

Problem with type imports when exported with nuxt layers #2408

hugobqd opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working triage

Comments

@hugobqd
Copy link

hugobqd commented Oct 17, 2024

Environment

  • Operating System: Darwin
  • Node Version: v20.9.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

v2.18.7

Reproduction

Don't know how to simulate nuxt layer in stackblitz.

  • Created a Nuxt component library using @nuxt/ui.
  • Used the alias #ui/types to import types within the library.
  • published via a private gitlab package
  • Integrated the library into another Nuxt project via Nuxt layers/extends.
  • Attempt to build or run the project.

Description

We have a Nuxt app powered by @nuxt/ui, which is a custom component library. This component library is integrated via Nuxt layers in different Nuxt projects.
When working inside the component library, we import types using the alias:

import type { Button, ButtonVariant } from '#ui/types'

However, once the library is integrated into a project via Nuxt layers/extends, the import fails with the following error:

Pre-transform error: [@vue/compiler-sfc] Failed to resolve import source "#ui/types".

Using a direct import works in the extended project but is not recognized in the current app:

import type { Button, ButtonVariant } from '@nuxt/ui/dist/runtime/types'

Is their a good way to make this import work in both the current and the layer app?

Additional context

No response

Logs

No response

@hugobqd hugobqd added bug Something isn't working triage labels Oct 17, 2024
Copy link
Member

This should work using #ui/types as it's exactly what we're doing with @nuxt/ui-pro (which is a layer).

Does your layer install the @nuxt/ui module?

I'm afraid I'm not gonna be much help without a reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants