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

addImports does not support . in from #23930

Closed
GerryWilko opened this issue Oct 25, 2023 · 6 comments
Closed

addImports does not support . in from #23930

GerryWilko opened this issue Oct 25, 2023 · 6 comments

Comments

@GerryWilko
Copy link

GerryWilko commented Oct 25, 2023

Environment

  • Operating System: Darwin
  • Node Version: v18.16.1
  • Nuxt Version: 3.6.2
  • Nitro Version: 2.5.2
  • Package Manager: pnpm@8.7.6
  • Builder: vite
  • User Config: runtimeConfig, modules, build, auth, i18n, css, postcss, imports
  • Runtime Modules: nuxt-icon@0.5.0, @nuxtjs/i18n@8.0.0-beta.13, @pinia/nuxt@0.4.11, @nuxt/devtools@0.6.7, @formkit/nuxt@0.19.2, @sidebase/nuxt-auth@0.6.0-beta.5, @vueuse/nuxt@10.5.0, @nuxt/ui@2.9.0
  • Build Modules: -

Reproduction

image

Add any import with a . in the from argument (here I'm using chart.js.

Describe the bug

The generated imports.d.ts looks like this:
image

Note the .js has been removed. I presume as there is something in the import generator that tries to exclude file extensions.

I have tried a number of work arounds including escaping the . which lets me get the dot to come through but nothing quite worked.

Adding a trailing / generates the import ok but then I get a Vite import error when running the application as there are no named exports of the package.

Additional context

No response

Logs

No response

@GerryWilko
Copy link
Author

Trying to isolate where the issue comes from it appears to be a problem with unimport.

In the utils.ts file:
image

However it looks like this should just be taking the from parameter without changing it. I can't see where the extension is dropped.

@GerryWilko
Copy link
Author

Found it https://github.com/unjs/unimport/blob/7df98d0a6a7b53437514eb078c295dfc5ec86087/src/utils.ts#L121

This strips all extensions. Found a work around for now... use uppercase letters 😄

Changing my from: to chart.JS sorts this issue for now.

@manniL
Copy link
Member

manniL commented Oct 25, 2023

@GerryWilko great debugging! Could you raise an issue in unimport instead ☺️?

@GerryWilko
Copy link
Author

Yes sir! unjs/unimport#290

@danielroe
Copy link
Member

Thank you ❤️

Let's track there.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
@GerryWilko
Copy link
Author

Just a note for anyone that tries the workaround it may not be successful in CI as both my GitHub builds and Vercel builds fail to find chart.JS due to casing of the JS.

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

No branches or pull requests

3 participants