sveltejs / cli

The Svelte CLI
MIT License
156 stars 4 forks source link

Deno support #214

Open Malix-Labs opened 14 hours ago

Malix-Labs commented 14 hours ago

Hey folks !

It would be awesome if the Svelte CLI could also support Deno

Also see https://github.com/denoland/deno/issues/17248

benmccann commented 12 hours ago

I think it mostly does support it. Let us know if there's some particular difficulty you're having

The only issue I'm aware of is https://github.com/denoland/deno/issues/25342

Malix-Labs commented 11 hours ago

I did not find the equivalent of npx sv create for Deno

Something that would end up working just like Node, out of the box

AdrianGonz97 commented 11 hours ago

Could you be a bit more specific? To execute the CLI in Deno, you run deno run -A npm:sv create which seemingly works well.

Is the issue that deno is missing in the package manager selection prompt? Or that we're possibly missing some scaffolding bits for Deno specific projects (judging by my brief skim of the linked thread referring to the imports field in deno.json)?

Testing it out, all seems to be working perfectly fine, including running the dev server:

➜ deno run -A npm:sv@latest create deno-project
┌  Welcome to the Svelte CLI! (v0.5.7)
│
◇  Which template would you like?
│  SvelteKit demo
│
◇  Add type checking with Typescript?
│  Yes, using Typescript syntax
│
◆  Project created
│
◇  What would you like to add to your project?
│  prettier, eslint
│
◇  Which package manager do you want to install dependencies with?
│  None
│
◆  Successfully setup integrations
│
    ...
│
└  You're all set!

➜  cd deno-project
➜  deno install
    ...
➜  deno task dev
Task dev vite dev
  VITE v5.4.10  ready in 1266 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

(note: for now, selecting None and manually installing deps with deno install is required as we're waiting on Deno to implement a user_agent in the process's env)

Malix-Labs commented 10 hours ago

To execute the CLI in Deno, you run deno run -A npm:sv create

Thanks !

I think it should also be documented (see GitHub Search - org:sveltejs "npx sv create")

Is the issue that deno is missing in the package manager selection prompt? Or that we're possibly missing some scaffolding bits for Deno specific projects

Both indeed

Using deno.json instead of package.json, and deno install too

Maybe also a potential official deno adapter which might have better performance than Deno's node compatibility layer ?

Community adapters :

for now, selecting None and manually installing deps with deno install is required as we're waiting on Deno to implement a user_agent in the process's env

Thanks for this information !

Could you please link the related issue ?

What is planned for the svelte cli when that related issue will be closed ? A new deno option choice in the package manager input ?

The proposed dev and build commands also need to be updated

lts20050703 commented 8 hours ago

Could you please link the related issue ?

@Malix-Labs https://github.com/denoland/deno/issues/25342

zoaha commented 7 hours ago

would it be possible to omit the 2 tsconfig files at some point when choosing the deno option?

Trying it myself, seems $lib is the only thing that breaks, at least in my tiny test project.

Malix-Labs commented 7 hours ago

that would be nice too indeed. Also, some imports need to be imported or mapped, such as node process env

Malix-Labs commented 3 hours ago

This one is particularly annoying and would need to be fixed :

Error in svelte.config.js Syntax Error: Cannot use import statement outside a module

https://stackoverflow.com/questions/70588096/error-in-svelte-config-js-syntax-error-cannot-use-import-statement-outside-a-mo

Workaround

package.json

{
    "type": "module"
}

+ Restart the LSP

Malix-Labs commented 3 hours ago

would it be possible to omit the 2 tsconfig files at some point when choosing the deno option?

Trying it myself, seems $lib is the only thing that breaks, at least in my tiny test project.

@zoaha $env also doesn't work

Have you found a workaround for $* imports ?