huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://shadcn-svelte.com
MIT License
4.99k stars 307 forks source link

SvelteKit - [CLI Error]: Failed to find tsconfig.json (or jsconfig.json). See: https://www.shadcn-svelte.com/docs/installation#opt-out-of-typescript #1282

Open imme-emosol opened 3 days ago

imme-emosol commented 3 days ago

Change Type

Addition

Proposed Changes

When the project does not have either-or {t,j}sconfig.json, depending on the (optional) components.json#typescript value, either

[CLI Error]: Failed to find tsconfig.json. See: https://www.shadcn-svelte.com/docs/installation#opt-out-of-typescript

or

[CLI Error]: Failed to find jsconfig.json. See: https://www.shadcn-svelte.com/docs/installation#opt-out-of-typescript

will be shown.

This can be resolved by adding either-or {t,j}sconfig.json with content:

{
        "extends": "./.svelte-kit/tsconfig.json"
}

Perhaps this can/should be added to sites/docs/src/content/installation/sveltekit.md.


Another option might be to change packages/cli/src/utils/sveltekit.ts.

However, this is posted as Docs Issue, since posting as feature-request will not be considered here :

This feature already exists in shadcn/ui - if not, it won't be considered here so don't continue with your issue. * This project's goal is to remain aligned with shadcn/ui. If the feature you are requesting is not in the original shadcn/ui, it will not be considered here.


Yet another thing that can be observed, is that the link in the error-message points to #opt-out-of-typescript, even when there is no components.json (yet) and also when components.json contains "typescript": false (which is what is mentioned at that anchor).

imme-emosol commented 3 days ago

Given that the current 'step 4' "Setup path aliases" is conditional, it could perhaps be changed into a suggestion at the end of 'step 3' "Install dependencies" ?

And the code example can perhaps be replaced by a [<a>/reference][sk-c-alias]?

A rephrasing might also be useful, to reflect that this optional task also relates to specifying a location for the components and utils, next to being related to an (optionally) changed [$lib][sk-m-lib]. For instance :

By default, shadcn-svelte uses the [$lib alias][sk-m-lib] to locate its components and utils. When other import aliases are to be used, the next step uses [SvelteKit's alias][sk-c-alias] to resolve those import aliases to a path/location for the components and utils

Additional context, used references ###### Additional context Also mentioned in [pull request 284][gh-shadcn-svelte-pr-284]: > the entire step [adding aliases to the configuration] could be removed Adding 'step 4' "Setup path aliases" seems to originate from [pull request 180][gh-shadcn-svelte-pr-180], which resolved [issue 165][gh-shadcn-svelte-is-165]. --- ###### references (cialnum-sorted:{0-9,[Aa]-[Zz]}): - [sk-c-alias] - [sk-m-lib] - [gh-shadcn-svelte-pr-180] - [gh-shadcn-svelte-pr-284] - [gh-shadcn-svelte-is-165] --- [gh-shadcn-svelte-is-165]: https://github.com/huntabyte/shadcn-svelte/issues/165 [gh-shadcn-svelte-pr-180]: https://github.com/huntabyte/shadcn-svelte/pull/180 [gh-shadcn-svelte-pr-284]: https://github.com/huntabyte/shadcn-svelte/pull/284 [sk-m-lib]: https://kit.svelte.dev/docs/modules#$lib "SvelteKit's `$lib` import alias" [sk-c-alias]: https://kit.svelte.dev/docs/configuration#alias "SvelteKit import alias configuration"