Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use outside of a Sveltekit project #214

Closed
ramonmalcolm10 opened this issue Aug 25, 2023 · 14 comments · Fixed by #605
Closed

Ability to use outside of a Sveltekit project #214

ramonmalcolm10 opened this issue Aug 25, 2023 · 14 comments · Fixed by #605
Labels
status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: feature Introduction of new functionality to the application

Comments

@ramonmalcolm10
Copy link

Describe the feature in detail (code, mocks, or screenshots encouraged)

Would it be possible to allow usage outside of a Sveltekit project to supports Svelte project created with Vite or Inertia JS from Laravel. Just a point to note the React version offer this flexibility.

What type of pull request would this be?

Enhancement

Provide relevant links or additional information.

No response

@ramonmalcolm10 ramonmalcolm10 added the type: feature Introduction of new functionality to the application label Aug 25, 2023
@huntabyte
Copy link
Owner

huntabyte commented Aug 26, 2023

Is there something preventing it from working now? I don't believe there is anything SvelteKit-specific in the components themselves. As far as install guides, if someone wants to contribute, feel free!

@ramonmalcolm10
Copy link
Author

It make reference to not being able to find something Sveltekit related when you try to install. I will share the exact error in a few

@huntabyte
Copy link
Owner

Ah yes I believe I know what's causing that. I'll look into it and see how feasible it will be to support alternatives!

@ramonmalcolm10
Copy link
Author

Thanks

@huntabyte huntabyte added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Aug 27, 2023
@blcksgnota
Copy link

Any news on this issue? trying to get the package working on a Laravel and svelte project.

@huntabyte huntabyte added status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Sep 17, 2023
@ramonmalcolm10
Copy link
Author

@huntabyte was wondering if this is the line that is causing the issue package.json and if so can it be executed using the preinstall script instead.

Please see reference for guidance.

@sanieldalib
Copy link

+1 on this. Would love to make use of the CLI for a vanilla svelte project without porting over to SvelteKit.

@sanieldalib
Copy link

I got around this by saving the source code directly and referencing the utils file. The CLI calls svelte-kit commands so thats not an option to use 😕

@huntabyte
Copy link
Owner

If anyone has the cycles to dig into this, let me know and it's all yours!

@willpinha
Copy link

willpinha commented Dec 9, 2023

Why we can't use something other than SvelteKit?

What prevents the CLI from working in projects other than SvelteKit (such as Vite and Laravel) is a specific piece of code.

When we try to run npx shadcn-svelte@latest init outside the SvelteKit context, we will probably receive the following error:

Command failed with exit code 1: npx svelte-kit sync

After digging into the code, I realized that the error occurs because of the resolveConfigPaths function in packages/cli/src/utils/get-config.ts

This function attempts to load a TypeScript configuration file at .svelte-kit/tsconfig.json. If there isn't, it calls npx svelte-kit sync to create it.

As in projects other than SvelteKit we do not have .svelte-kit/tsconfig.json nor the svelte-kit dependency, the error is thrown.

The solution

To solve this problem and support other frameworks, we can remove the assumption that tsconfig.json is in .svelte-kit and instead let the user decide during startup where this file is located.

I'm interested in working on this issue. Can I be assigned to it?

@willpinha
Copy link

@huntabyte A better way to achieve this, instead of asking for user input, would be to find tsconfig.json in a sequence of actions:

  1. Search for tsconfig.json in cwd
  2. If it doesn't exist, search in ./svelte-kit/tsconfig.json
  3. If it doesn't exist, run npx svelte-kit sync

Steps 2 and 3 are already implemented. The only thing we would need to add is the first step, so that users outside of a SvelteKit project can also use the CLI

Of course this still assumes that the user is using Typescript in their project, an assumption that shadcn/ui does not make, but I think this can be discussed in another issue

@0x090909
Copy link

Would be great! +1 for this feature or bug fix lets say

@0x090909
Copy link

@willpinha can you fork this and make it work in your fork?

@lecramr
Copy link

lecramr commented Dec 30, 2023

That would be a great addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants