unplugin / unplugin/unplugin-auto-import
Package name with dot is not imported properly
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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