unplugin / unplugin/unplugin-auto-import

Feature: Update default include regex to support query parameters in file paths

Open
#620 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Clear and concise description of the problem

Currently, the plugin's default include rule uses the regular expression /\.[tj]sx?$/. This strictly matches files ending with .js, .jsx, .ts, or .tsx.

However, in modern build tools and frameworks, it's very common for file imports to be appended with query parameters under the hood. A notable example is TanStack Router, which appends query parameters like ?tsr-split=component to file paths for its code-splitting feature (see related issue: TanStack/router#5653).

Because of the strict $ at the end of the current regex, these files with query parameters fail to match the default include rule, causing the plugin to skip them unless users manually override the configuration.

Suggested solution

I propose updating the default include regular expression to gracefully handle optional query parameters.

Changing it from:

/\.[tj]sx?$/

To:

/\.[tj]sx?(?:\?.*)?$/
Alternative

No response

Additional context

No response

Validations

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

Locate the default include regular expression in the repository and compare its current behavior for .js, .jsx, .ts, and .tsx paths. Update it to accept optional query parameters, then verify that ordinary paths still match and paths such as those with ?tsr-split=component are included.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.