stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.93k stars 171 forks source link

support install deno #1608

Open mfulton26 opened 6 days ago

mfulton26 commented 6 days ago

Describe the bug

Attempting to install Deno fails immediately:

❯ curl -sL https://deno.land/install.sh | sh
curl: socket hang up

Inspecting network traffic for the browser document via DevTools reveals that the first issue is a CORS issue:

Access to fetch at 'https://deno.land/install.sh' from origin 'https://something.w-credentialless-staticblitz.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I then tried pasting the contents of https://deno.land/install.sh into a file and running it directly:

❯ sh install.sh
install.sh: line 7: unsupported shell syntax

For reference (and as the install.sh script might change with time), here is line 7:

if ! command -v unzip >/dev/null && ! command -v 7z >/dev/null; then

The shell (/bin/jsh/) appears to have limited functionality but as Stackblitz supports Node.js it seems to me that supporting Deno should also be feasible.

Does this require some specific work on Stackblitz's side to support Deno? (I'm sure folks would like Bun too.)

Link to the blitz that caused the error

https://stackblitz.com/~/github.com/denoland/std

Steps to reproduce

  1. Open a repo.
  2. Create a file named install.sh.
  3. Copy the content from https://deno.land/install.sh and paste them into install.sh.
  4. Run sh install.sh

Expected behavior

Deno is successfully installed.

Parity with Local

Screenshots

No response

Platform

Version = 1.84.0
Hash = 3b0b7194bc6b567c2eaf4c96a5759098469dcf59
WebContainer = d3acb9e1

Browser name  = Chrome
Full version  = 131.0.0.0
Major version = 131
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 88494600,
  "usedJSHeapSize": 80563792,
  "jsHeapSizeLimit": 4294705152
}

Additional context

An alternative to supporting Deno installation would be for it to be installed out-of-the-box like Node.js is. This might be simpler in some ways but I'd want a way to specify which Deno version to load.