denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.33k stars 5.36k forks source link

Support SolidStart (SolidJS/Vite based) #20604

Closed birkskyum closed 6 months ago

birkskyum commented 1 year ago

Platform

Darwin 22.6.0 arm64 arm

Version

deno 1.37.0

Repro

Expected

Dev server start

Actual

➜ deno task dev
Warning Currently only basic package.json `scripts` are supported. Programs like `rimraf` or `cross-env` will not work correctly. This will be fixed in an upcoming release.
Task dev solid-start dev
 solid-start dev 
 version  0.3.5
TypeError: worker.unref is not a function
    at startWorkerThreadService (file:///Users/admin/repos/deno-kitchensink/my-solidstart-app/node_modules/.deno/esbuild@0.17.19/node_modules/esbuild/lib/main.js:2292:10)
    at Object.transformSync (file:///Users/admin/repos/deno-kitchensink/my-solidstart-app/node_modules/.deno/esbuild@0.17.19/node_modules/esbuild/lib/main.js:2040:29)
    at Router.createRouteConfig (file:///Users/admin/repos/deno-kitchensink/my-solidstart-app/node_modules/.deno/solid-start@0.3.5/node_modules/solid-start/fs-router/router.js:188:19)

Related to:

birkskyum commented 10 months ago

I tried this with the latest version of solid start (same repro instructions), and got a new output:

➜ deno task dev
Task dev vinxi dev
TypeError: Cannot read properties of undefined (reading 'cwd')
    at defineConfig (data::54:59)
    at data::3:26
    at data::6:4
    at evalModule (file:///Users/admin/repos/solidstart-app/node_modules/.deno/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:256697)
    at Object.jiti (file:///Users/admin/repos/solidstart-app/node_modules/.deno/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:254625)
    at resolveConfig (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/c12/dist/index.mjs:288:24)
    at loadConfig (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/c12/dist/index.mjs:116:40)
    at loadApp (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/vinxi/lib/load-app.js:35:29)
    at async Object.run (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/vinxi/bin/cli.mjs:65:17)
    at async runCommand (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/citty/dist/index.mjs:316:16)
    at async runCommand (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/citty/dist/index.mjs:307:11)
    at async runMain (file:///Users/admin/repos/solidstart-app/node_modules/.deno/vinxi@0.0.52/node_modules/citty/dist/index.mjs:441:7)
birkskyum commented 8 months ago

This one is also a blocker for the new solid-start which is built on vinxi:

birkskyum commented 8 months ago

SolidStart 0.6.0 is out (release notes)

Running the basic example gives:

➜ deno task dev        
error: npm package 'uWebSockets.js' does not exist.

Same error as:

It seems the depencency chain is vinxi (installed in all solid start projects) -> listhen -> crossws -> uWebSockets.js

This example works fine in node / bun.

birkskyum commented 7 months ago

With the BYONM flag, SolidStart is also stuck at

birkskyum commented 7 months ago

Interesting, running the the bare example (can be selected from the cli on project creation) actually works now 🎉

The FileRoutes component (in the basic example) breaks with the following error:


(base) birkskyum@Birks-MacBook-Pro solid-project % deno task dev  
Task dev vinxi dev
vinxi v0.3.11
vinxi starting dev server

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ReferenceError: document is not defined
    at eval (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/vinxi@0.3.11/node_modules/vinxi/runtime/style.js, <anonymous>:34:19)
    at Array.forEach (<anonymous>)
    at Module.appendStyles (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/vinxi@0.3.11/node_modules/vinxi/runtime/style.js, <anonymous>:33:10)
    at Promise.Comp [as resolved] (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+start@1.0.0-rc.0_solid-js@1.8.16_vinxi@0.3.11_vite@5.2.7/node_modules/@solidjs/start/dist/router/lazyRoute.js, <anonymous>:26:33)
    at wrap (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:598:30)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at Object.outlet (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routing.js, <anonymous>:440:53)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:133:23)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:35
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:49
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at children (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:16)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:14
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at provider (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:211:12)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:130:49)
    at Show (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:417:9)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at eval (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:125:38)
    at Routes (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:122:51)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:35:95)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:70:22)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/src/app.tsx, <anonymous>:28:26)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:685:41
    at catchError (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:152:12)
    at Object.get children (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:685:18)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:35
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:49
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at children (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:16)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:14
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at provider (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:211:12)
    at createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:682:7
    at runWithOwner (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:190:12)
    at runSuspense (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:681:12)
    at Object.completed (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:662:21)
    at notifySuspense (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:632:7)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:612:11
    at async Function.allSettled (<anonymous>)
birkskyum commented 7 months ago

deno task build successfully makes some bundles, and then prints this error:


⚙  Preparing app for node-server...

 ERROR  No such file or directory (os error 2)                                                                                                     
 ERROR  No such file or directory (os error 2) 
bartlomieju commented 7 months ago

Interesting, running the the bare example (can be selected from the cli on project creation) actually works now 🎉

The FileRoutes component (in the basic example) breaks with the following error:

(base) birkskyum@Birks-MacBook-Pro solid-project % deno task dev  
Task dev vinxi dev
vinxi v0.3.11
vinxi starting dev server

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ReferenceError: document is not defined
    at eval (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/vinxi@0.3.11/node_modules/vinxi/runtime/style.js, <anonymous>:34:19)
    at Array.forEach (<anonymous>)
    at Module.appendStyles (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/vinxi@0.3.11/node_modules/vinxi/runtime/style.js, <anonymous>:33:10)
    at Promise.Comp [as resolved] (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+start@1.0.0-rc.0_solid-js@1.8.16_vinxi@0.3.11_vite@5.2.7/node_modules/@solidjs/start/dist/router/lazyRoute.js, <anonymous>:26:33)
    at wrap (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:598:30)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at Object.outlet (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routing.js, <anonymous>:440:53)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:133:23)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:35
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:49
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at children (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:16)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:14
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at provider (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:211:12)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:130:49)
    at Show (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:417:9)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at eval (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:125:38)
    at Routes (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:122:51)
    at Module.createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:35:95)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/@solidjs+router@0.13.1_solid-js@1.8.16/node_modules/@solidjs/router/dist/routers/components.jsx, <anonymous>:70:22)
    at Object.get children (/Users/birkskyum/repos/deno-kitchensink/solid-project/src/app.tsx, <anonymous>:28:26)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:685:41
    at catchError (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:152:12)
    at Object.get children (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:685:18)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:35
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:49
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at children (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:179:16)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:216:14
    at createMemo (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:95:9)
    at provider (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:211:12)
    at createComponent (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:349:15)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:682:7
    at runWithOwner (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:190:12)
    at runSuspense (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:681:12)
    at Object.completed (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:662:21)
    at notifySuspense (file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:632:7)
    at file:///Users/birkskyum/repos/deno-kitchensink/solid-project/node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/server.js:612:11
    at async Function.allSettled (<anonymous>)

I think this will work if you run with DENO_FUTURE=1 - this will remove window variable which should fix the problem - I think the package is using window check to decide if it's running in the browser.

littledivy commented 7 months ago

Yup, it works with DENO_FUTURE=1:

image

birkskyum commented 7 months ago

Interesting, I've never heard of that flag before - must have missed it when going through the release notes. If the error is that document can't be found, and this flag removed window, I don't really understand how removing something can fix the error, but it does indeed fix the FileRoutes. And that is awesome because it means it's possible to start making dev examples with Deno and SolidStart. The build error persist though.

This part of the release notes:

In following releases we will add more changes that will happen in Deno 2, including changes to handling of node_modules/ directory. Specficially enabling BYONM under DENO_FUTURE.

Can you elaborate on that last part with BYONM and DENO_FUTUTE, or is it still in design? I'm not sure how to interpret the sentence. I think the less flags needed to run the code the better.

carere commented 7 months ago

@birkskyum Do you have an example Repo ?

carere commented 7 months ago

Here is my package.json:

{
  "name": "solid-spa-deno",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview",
    "optimize": "vite optimize"
  },
  "dependencies": {
    "solid-js": "^1.8.16",
    "@solidjs/router": "^0.13.1"
  },
  "devDependencies": {
    "autoprefixer": "latest",
    "cssnano": "latest",
    "tailwindcss": "latest",
    "postcss": "latest",
    "postcss-import": "latest",
    "typescript": "latest",
    "vite": "latest",
    "vite-plugin-solid": "latest"
  }
}

And here is my deno.jsonc

{
  "unstable": ["byonm", "bare-node-builtins"],
  "imports": {
    "solid-js": "https://esm.sh/solid-js@1.8.16"
  },
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "solid-js",
    "lib": ["dom", "deno.ns"],
    "types": ["vite/client"]
  }
}

I'm trying to get the types for JSX working, but I don't know why it's not working. Do you guys have some example of configuration with the byonm unstable flag ?

birkskyum commented 7 months ago

@carere , since you're not using SolidStart this is not the right ticket. You'd probably want to replace react-jsx with preserve in the compilerOptions

carere commented 7 months ago

Ok, it's seems to be a problem with the cache of a specific file, I renamed it, and it works. But I"m only able to make it work with the canary version of Deno. When I use the stable 1.42.0, even so I add unstable flag byonm in deno.json or DENO_FUTURE=1 before my command, I still get the Deno.internal.rid error.

Do you guys also use Canary version ?

birkskyum commented 7 months ago

@carere , generally yes.

littledivy commented 6 months ago

Fixed by #23469

Tested dev, build and serve on various SolidStart projects.

demo

birkskyum commented 6 months ago

Amazing! I can test this in some real projects when it's in canary.