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

[Feature]: nuxt-layer ts compatible #1239

Open
2 tasks
XHZ360 opened this issue Aug 20, 2024 · 4 comments
Open
2 tasks

[Feature]: nuxt-layer ts compatible #1239

XHZ360 opened this issue Aug 20, 2024 · 4 comments

Comments

@XHZ360
Copy link

XHZ360 commented Aug 20, 2024

Describe the feature

I have a project that extends other layer using radix-vue.

--base-project (using radix-vue)
---nuxt.config.ts
---- modules: ["@nuxtjs/i18n", "@nuxt/image", 'radix-vue/nuxt'],
--my-project
---nuxt.config.ts
---- extends: ['../base'],

In my-project, the ts-server can't recognize the type of radix-vue component from base-project:
image

This is caused by incorrect module path, ts-server can't find radix-vue in my-project

According to nuxt-ui, the following fix may help this:

// packages/plugins/nuxt/src/resolver/index.ts
... 
  setup(options) {

    function getComponents() {
      if (typeof options.components === "object") {
        return Object.entries(components).filter(([name]) => options.components[name]).flatMap(([_, components]) => components);
      }
      if (options.components)
        return Object.values(components).flat();
      return [];
    }
+  const resolver = createResolver(import.meta.url)
+  const filePath = resolver.resolve('../..');

    for (const component of getComponents()) {
      addComponent({
        name: `${options.prefix}${component}`,
        export: component,
+      filePath: filePath
      });
    }
  }
...

I'm not sure if it's causing other issues, may other can help this.

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
@zernonia
Copy link
Member

zernonia commented Aug 20, 2024

Hmmm I believe Nuxt should detect the extended layer's types right? Wondering if <NuxtImage /> typed correctly since you are using it on layer as well?

@XHZ360
Copy link
Author

XHZ360 commented Aug 20, 2024

yes, nuxt-image is typed correctly.
the components.ts generated like this:

{
NuxtImage: typeof import("../base/nodemules/nuxt/image/.........")['default']
DropdownMenu: typeof import("radix-vue")[‘DropdownMenu‘]
}

And I have tried other ui libary like element-plus, it cant be typed correctly yet. But the nuxt-ui is typed right as same as nuxt-image.

@zernonia
Copy link
Member

zernonia commented Aug 20, 2024

Hmm this is something needs investigation, however meanwhile you should be able to workaround this by installing radix-vue on my-project app

@unovue unovue deleted a comment from XHZ360 Aug 21, 2024
@sadeghbarati
Copy link
Collaborator

I saw a duplicated comment and deleted it

I thought it would not leave a mark, sorry 🙏

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

No branches or pull requests

3 participants