unplugin / unplugin/unplugin-auto-import

Package name with dot is not imported properly

Open
#463 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

need reproduction
Dominant language
TypeScript
Stars
3.8k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

When I try to import twin.macro:

AutoImport({
  dirs: [],
  imports: [
    "react",
    "react-router-dom",
    {
      ...,
      "twin.macro": [["default", "tw"], "css", "styled", "theme"],
    },
  ],
  eslintrc: {
    enabled: true,
  },
}), 

it generates the following code:

// Should be 'twin.macro'
const styled: typeof import('twin')['styled']
const theme: typeof import('twin')['theme']
const tw: typeof import('twin')['default']
const css: typeof import('twin')['css']

As you can see, it removes the dot and the following string.

Reproduction

https://stackblitz.com/edit/vitejs-vite-nercgp?file=auto-imports.d.ts

System Info
System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 11.30 GB / 31.71 GB
  Binaries:
    Node: 18.18.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.11.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.91)
    Internet Explorer: 11.0.22621.1
Used Package Manager

pnpm

Validations
  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the import configuration shown in the issue and reproduce the generated auto-imports.d.ts using the linked StackBlitz example. Trace how the package name is converted into the generated type imports, then add a regression test showing that twin.macro remains intact and passes with the expected generated declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.