cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.6k stars 674 forks source link

Feature request: Support Deno #6049

Closed kensukesaito closed 3 months ago

kensukesaito commented 3 months ago

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

3.60.3 [wrangler]

What version of Node are you using?

Deno 1.44.2 (latest)

What operating system and version are you using?

macOS Sonoma 14.5 (latest)

Describe the Bug

Observed behavior

$ deno run npm:wrangler

error: unexpected argument '--no-warnings' found

  tip: a similar argument exists: '--no-config'

Usage: deno run --allow-all --no-config [SCRIPT_ARG]...

For more information, try '--help'.

Expected behavior

Same as npx wrangler

Steps to reproduce

Install Deno: $ curl -fsSL https://deno.land/install.sh | sh

Run: $ deno run npm:wrangler

Cause

https://github.com/cloudflare/workers-sdk/blob/c643a8193a3c0739b33d3c0072ae716bc8f1565b/packages/wrangler/bin/wrangler.js#L34

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

threepointone commented 3 months ago

We don't officially support deno (or any other runtime) as a runner for wrangler (and I don't think there are immediate plans to do so), but we'd be happy to discuss. Is there a reason you cannot use node?

kensukesaito commented 3 months ago

@threepointone

Thank you for your response.

While it is possible for us to use Node.js, there are several compelling reasons why supporting Deno would be highly beneficial:

Deno offers several advantages over Node.js, including enhanced security, native TypeScript support, simpler module management, built-in standard modules, a modern API design, and a streamlined distribution model. These features make Deno particularly attractive for new projects or those that prioritize security.

1. Security

Deno is designed with security in mind. By default, it restricts access to the file system, network, and environment variables. This minimizes the risk of unintended side effects on the system by running scripts. Access permissions must be explicitly granted via flags, allowing for fine-grained control.

2. TypeScript Support

Deno natively supports TypeScript without the need for additional configuration or tools. This allows developers to write type-safe code easily, improving code quality and reducing errors.

3. Module Management

Deno does not rely on a package.json file or a centralized repository like npm. Instead, it uses a simple mechanism for importing modules via URLs. This simplifies dependency management and allows for explicit version specification.

4. Standard Modules

Deno includes a set of standard modules that provide common functionalities out of the box. This reduces the reliance on external libraries for basic tasks. Moreover, standard modules are released alongside Deno, ensuring compatibility and reducing issues.

5. Simple and Modern API

Deno's API is designed to be simple and modern, utilizing async/await for asynchronous operations. Additionally, it aims to have the same code run both in the browser and on the server, promoting code reuse.

6. Single Executable

Deno is distributed as a single executable file, which eliminates the need for dependency management. This makes installation and distribution straightforward.

7. Adoption of Best Practices

Deno incorporates many best practices learned from Node.js. This includes the removal of deprecated features and minimizing global objects, leading to a cleaner and more predictable environment.

Given these reasons, we strongly hope you will consider supporting Deno. This support would not only enhance the development experience but also bring substantial benefits to the broader developer community.

Thank you for your consideration.

threepointone commented 3 months ago

None of those benefits apply to using a tool like wrangler as a CLI for local development; particularly for development/deployment for another runtime (Workers). I'm going to close this issue, but we'll be happy to revisit it in the future if the need becomes more common.

folliehiyuki commented 3 months ago

@threepointone can you reconsider this issue again?

Is there a reason you cannot use node?

I have a project using Lume, a static site generator for Deno. It would be weird to use both NodeJS (having package.json file and running npx/npm commands) and Deno at the same time. Meanwhile, after the project is built, I still want to publish it to Cloudflare Pages using wrangler. It will be convenient if I can invoke wrangler directly using deno run command, as I can pin wrangler dependency inside Deno's lockfile.

I think the problem here is that Deno doesn't understand Node's specific arguments. Would those arguments be removed somehow inside wrangler script?

threepointone commented 3 months ago

I"m happy to reopen the issue, and I'll leave it to the team to decide, but I strongly suspect they won't. It becomes another target to maintain, and test against, and guarantee compliance with. It's non-trivial.

In your specific case, you can get around the need for a package.json / npx by installing it globally (with npm install wrangler -g), a bunch of our users already do that.