Skip to content

fix(cli): support tsconfig without baseUrl#566

Open
tobigumo wants to merge 2 commits intochakra-ui:mainfrom
tobigumo:fix/cli-tsconfig-baseurl-optional
Open

fix(cli): support tsconfig without baseUrl#566
tobigumo wants to merge 2 commits intochakra-ui:mainfrom
tobigumo:fix/cli-tsconfig-baseurl-optional

Conversation

@tobigumo
Copy link
Copy Markdown
Contributor

Summary

@park-ui/cli currently fails when the user's tsconfig.json has no compilerOptions.baseUrl. This PR lifts that requirement while preserving full backwards compatibility.

Context

TypeScript 6.0 (GA) deprecates baseUrl; TypeScript 7 removes it (already rejected by @typescript/native-preview / tsgo). The recommended migration is to drop baseUrl and rely on paths alone, optionally with "*": ["./*"] for bare imports such as styled-system.

Refs #549, #540.

Changes

Two independent commits:

  1. fix(cli): make tsconfig baseUrl optional
    baseUrl becomes optional in the schema. When absent, the CLI falls back to path.dirname(tsconfigFile), matching TypeScript's own paths resolution behavior (TS 4.1+). Uses tsconfigFile already returned by tsconfck.parse(); no new dependency.

  2. fix(cli): ignore "*" catch-all path when detecting alias prefix
    With baseUrl optional, users commonly add "*": ["./*"] for bare imports. The previous getTsConfigAliasPrefix picked this catch-all as the alias prefix, producing paths like */components in components.json. The detector now ignores "*" and any key not ending in /*, so only real aliases (~/*, @/*, …) are considered.

Backwards compatibility

Projects with baseUrl defined behave identically. Only configurations that previously failed now work.

Test plan

  • bun run build, bun run lint, bunx tsc --noEmit in packages/cli — no new errors in touched files (pre-existing magicast/helpers resolution error in panda-config.ts is unrelated to this PR).
  • Sandbox A: baseUrl: "." + paths: { "~/*": ["./src/*"] } → generates into src/* (unchanged).
  • Sandbox B: no baseUrl + paths: { "*": ["./*"], "~/*": ["./app/*"] } → generates into app/* (previously failed or wrote to */theme).

🤖 Generated with Claude Code

tobigumo and others added 2 commits April 15, 2026 12:57
TypeScript 6.0 deprecates `compilerOptions.baseUrl` and it is scheduled
for removal in TypeScript 7. Previously the CLI required `baseUrl` in
the user's tsconfig.json and would fail schema validation otherwise.

Make `baseUrl` optional in the schema and fall back to the directory
containing the resolved tsconfig.json, which matches TypeScript's own
behavior when `paths` is specified without `baseUrl`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When `baseUrl` is absent, projects commonly add `"*": ["./*"]` to
`paths` so that bare imports like `styled-system` keep resolving. The
alias-prefix detector iterated all `paths` entries and picked the `"*"`
catch-all first, producing a prefix of `"*"` and writing paths like
`*/components` into components.json.

Filter out the `"*"` catch-all and any entry whose key does not end in
`/*`, so only real user aliases (`~/*`, `@/*`, ...) are considered.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant