carbon-components-vue icon indicating copy to clipboard operation
carbon-components-vue copied to clipboard

<cv-file-uploader> Failed to resolve import

Open krko12345 opened this issue 1 year ago • 7 comments

Failed to resolve import

Detailed description

Describe in detail the issue you're having.

CvFileUploader throws error when used in my project. The error is "Failed to resolve import", which is related to CvForm component import in the file-uploader component.

In my env.d.ts I have declared the path as "declare module '@carbon/vue/src/components/*'", and I tried with different variations as well.

Still getting error: image

What works for me is to modify the CvFileUploader component and remove the CvForm wrapper inside, but of course that's not permanent solution.

Any recommendation? Is this a bug?

Is this a feature request (new component, new icon), a bug, or a general issue? issue

Is this issue related to a specific component? CvFileUploader

What did you expect to happen? What happened instead? What would you like to see changed? Expected the component to load, instead it throws error.

What browser are you working in? Edge

What version of the Carbon Design System are you using? 3.0.12

What offering/product do you work on? Any pressing ship or release dates we should be aware of?

Steps to reproduce the issue

  1. Step one
  2. Step two
  3. Step three
  4. etc.

Additional information

  • Screenshots or code
  • Notes

krko12345 avatar Feb 17 '24 15:02 krko12345

The problem seems to move to next line if I modify it to use parent directory path (instead of current directory) for the import

image

krko12345 avatar Feb 17 '24 15:02 krko12345

Hmm I cannot reproduce this. I think you are correct that its may have something to do with 'env.d.ts' file. What happens if you remove the "declare module " statement?

davidnixon avatar Mar 10 '24 21:03 davidnixon

@davidnixon Error remained even after removal of all declarations from "env.d.ts". It wouldn't be a solution anyway because without declarations the code would fail to compile from typescript.

I also must say that I use there practically all carbon components, and cv-file-uploader is the only one having this issue.

krko12345 avatar Apr 04 '24 19:04 krko12345

This issue has been marked as stale because it has required additional info or a response from the author for over 14 days. When you get the chance, please comment with the additional info requested. Otherwise, this issue will be closed in 14 days.

github-actions[bot] avatar Jun 10 '24 17:06 github-actions[bot]

Not sure what more should I include in my response. The problem still persists as described.

I only managed to avoid the problem by having a modified copy of CvFileUploader component, where I have removed the CvForm wrapper. As mentioned, other carbon components work for me as expected.

krko12345 avatar Jun 15 '24 19:06 krko12345

I do not think I fully understand the use case but I think I do see the issue. Several index files import like this:

import CvForm from './CvForm';

Notice the lack of ".vue" extension! I updated those places to import like this:

import CvForm from './CvForm.vue';

Could you try this patch? carbon-vue-3.0.16-5f775.tgz

npm remove @carbon/vue 
npm add ./carbon-vue-3.0.16-5f775.tgz

Another possible fix. Can you remove "declare module '@carbon/vue/src/components/*'"? I think maybe your use case is related to an issue @OlkaB resolved in April. #1578 which nows allow you to import individual components. So this should work without the declare module.

import { CvFileUploader } from '@carbon/vue';

davidnixon avatar Jun 18 '24 17:06 davidnixon

@davidnixon I confirm, the CvFileUploader component worked as expected while using carbon-vue-3.0.16-5f775.tgz

krko12345 avatar Jun 19 '24 20:06 krko12345

This issue has been marked as stale because it has required additional info or a response from the author for over 14 days. When you get the chance, please comment with the additional info requested. Otherwise, this issue will be closed in 14 days.

github-actions[bot] avatar Jul 07 '24 08:07 github-actions[bot]

Fixed in #1606

davidnixon avatar Jul 11 '24 08:07 davidnixon