这是indexloc提供的服务,不要输入任何密码
Skip to content

🧩 Asterisk subpath exports guidance #1308

@samhh

Description

@samhh

Discuss anything related to Knip

Hi there! 👋

I'm having a little trouble understanding how to configure Knip for a particular workspace in my monorepo. I can repro the behaviour with the following files:

package.json:

{
  "exports": {
    "./*": "./*.ts"
  },
  "scripts": {
    "knip": "knip --strict",
    "vitest": "vitest run"
  },
  "devDependencies": {
    "knip": "^5.66.1",
    "vitest": "^3.2.4"
  }
}

example.test.ts:

import { } from "vitest";

Output:

$ npm run knip
Unlisted dependencies (1)
vitest  example.test.ts:1:8

I can see that the issue is my asterisk subpath export definition, however that's something that the workspace in question needs to live with for the time being, as well as the interleaved source and test files. I appreciate that more granular subpath exports, or subpath imports, would be the best way to solve this problem long-term.

Alas I'm trying to figure out how to configure Knip to accept it in strict mode given the rest of my repo is green. I'm not having luck with any combination of entry and project.

Help appreciated, assuming this is possible! Thanks for Knip in any case 🏅

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions