denoland / deno

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

Support Parcel #20613

Open birkskyum opened 10 months ago

birkskyum commented 10 months ago

Platform

Darwin 22.6.0 arm64 arm

Version

deno 1.37.0

Repro

Make an index.html

​<html>
  <head>
    <title>My First Parcel App</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>

Run it with deno

Expected

Server running at http://localhost:1234
✨ Built in 494ms

Actual

➜ deno run -A npm:parcel index.html
Error: Not implemented: v8.deserialize
    at notImplemented (ext:deno_node/_utils.ts:9:9)
    at deserialize (node:v8:62:3)
    at deserialize (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/serializer.js:204:48)
    at loadRequestGraph (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/RequestTracker.js:744:52)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Function.init (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/RequestTracker.js:718:17)
    at async Parcel._init (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Parcel.js:178:28)
    at async Parcel.watch (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Parcel.js:228:7)
    at async run (file:///Users/admin/repos/deno-parcel/node_modules/.deno/parcel@2.9.3/node_modules/parcel/lib/cli.js:286:9)
error: Uncaught (in worker "$DENO_STD_NODE_WORKER_THREAD") (in promise) Error: Only create ThreadsChild instances in a worker!
    at new ThreadsChild (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:34:13)
    at new Child (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/child.js:65:18)
    at Object.<anonymous> (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:49:27)
    at Object.<anonymous> (file:///Users/admin/repos/deno-parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:50:4)
    at Module._compile (node:module:733:34)
    at Object.Module._extensions..js (node:module:747:10)
    at Module.load (node:module:658:32)
    at Function.Module._load (node:module:539:12)
    at Module.require (node:module:677:19)
    at require (node:module:791:16)
bartlomieju commented 10 months ago

@birkskyum thanks for reporting. I can't seem to reproduce the problem you are facing, for me parcel is failing on resolution of some modules:

Error: Cannot find module '@parcel/config-default'
Require stack:
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/cli.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/bin.js
    at Function.Module._resolveFilename (node:module:624:15)
    at Function.resolve (node:module:794:19)
    at run (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/cli.js:217:28)
    at eventLoopTick (ext:core/01_core.js:197:13) {
  code: "MODULE_NOT_FOUND",
  requireStack: [
    "/Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/cli.js",
    "/Users/ib/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.9.3/lib/bin.js"
  ]
}

And if I use --node-modules-dir flag I get:

error: Uncaught (in worker "$DENO_STD_NODE_WORKER_THREAD") (in promise) Error: Only create ThreadsChild instances in a worker!
    at new ThreadsChild (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:34:13)
    at new Child (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/child.js:65:18)
    at Object.<anonymous> (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:49:27)
    at Object.<anonymous> (file:///Users/ib/dev/try_parcel/node_modules/.deno/@parcel+workers@2.9.3/node_modules/@parcel/workers/lib/threads/ThreadsChild.js:50:4)
    at Module._compile (node:module:733:34)
    at Object.Module._extensions..js (node:module:747:10)
    at Module.load (node:module:658:32)
    at Function.Module._load (node:module:539:12)
    at Module.require (node:module:677:19)
    at require (node:module:791:16)
// more errors like this

(what I mean is that I can't hit that v8.deserialize error, the error coming from workers is legit one and I know how to fix it)

birkskyum commented 10 months ago

I tried updating to deno 1.37.1, and run again, and now I see the same output as you.

bartlomieju commented 4 months ago

@birkskyum any chance you could try again with latest canary? We put a lot of effort into improving node:worker_threads module recently and I think this might now work correctly.

birkskyum commented 4 months ago

Fantastic work on pushing the compat! I get this now, so it could be it's very close for both Expo and Parcel:

➜ deno run -A npm:parcel index.html
TypeError: Cannot read properties of undefined (reading 'Symbol(Deno.internal.rid)')
    at TTY.#read (ext:deno_node/internal_binding/stream_wrap.ts:220:45)
    at TTY.readStart (ext:deno_node/internal_binding/stream_wrap.ts:90:17)
    at _tryReadStart (node:net:276:30)
    at ReadStream._read (node:net:856:7)
    at ReadStream.Readable.read (ext:deno_node/_stream.mjs:2999:16)
    at ReadStream.read (node:net:789:34)
    at resume_ (ext:deno_node/_stream.mjs:3349:16)
    at Array.processTicksAndRejections (ext:deno_node/_next_tick.ts:33:15)
    at eventLoopTick (ext:core/01_core.js:165:29)
birkskyum commented 3 months ago

Running with canary now gives this:

(base) birkskyum@Birks-MacBook-Pro deno-kitchensink % deno run -A npm:parcel index.html
Error: Cannot find module '@parcel/config-default'
Require stack:
- /Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js
- /Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/bin.js
    at Function.Module._resolveFilename (node:module:609:15)
    at Function.resolve (node:module:779:19)
    at run (file:///Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js:217:28)
    at eventLoopTick (ext:core/01_core.js:207:9) {
  code: "MODULE_NOT_FOUND",
  requireStack: [
    "/Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/cli.js",
    "/Users/birkskyum/Library/Caches/deno/npm/registry.npmjs.org/parcel/2.12.0/lib/bin.js"
  ]

I figured I'd try installing parcel with npm and try running it as a "script" in package json, with and without the byonm flag in deno.js, but then I hit this, and the terminal froze completely, to the point where I could not even abort it.

Task compress parcel index.html
zzz6519003 commented 3 months ago

deno deploy + parcel template pls