Repository: deno
Issue: SyntaxError: Unexpected identifier 'parentPort' in worker_threads
Labels: bug,node compat

Version: Deno 2.1.2, Windows 10 x64

I wrote a program using Node.js, TypeScript and a lib called [microjob](https://github.com/wilk). the program code below:

```TS
export class EnvChecker {
  static async checkRuntimes() {

    // 首先通过进程命令行获取运行时类型（node/tsx/deno/bun...)
    const willCheck = process.env.EC_ON_LAUNCH || false
    if (willCheck) {
      try {
        // start the worker pool first
        await start({ maxWorkers: 1 })

        // this function will be executed in another thread
        const res = await job(() => {
          console.log(`run time is: ${process.argv[0]}`)
          // doing some other tasks, skip here
          return 'Env check done.'
        })
        console.log(res)
      } catch (err) {
        console.error(err)
      } finally {
        await stop() // shutdown worker pool
      }
    }
  }
}

EnvChecker.checkRuntimes()
```

When I execute it use deno, got error:

```console
PS F:\my-program> npm run dev:deno

> deno run  --watch  --inspect  --allow-all      src/main.ts

Watcher Process started.
Debugger listening on ws://127.0.0.1:9229/ws/3426a06b-7d14-4a71-bdca-e45de5e07894
Visit chrome://inspect to connect to the debugger.
Debugger listening on ws://127.0.0.1:9229/ws/0ef0d61e-7b4c-4b57-94bc-2633e8907f82
Visit chrome://inspect to connect to the debugger.
error: Uncaught (in worker "[worker eval]") SyntaxError: Unexpected identifier 'parentPort'
    at <anonymous> (data:text/javascript,const { parentPort }......error(err)    }  }}):1:49)
2024/11/30 13:16:01 Web app  > Main Process launched, name: Mot&Mot
2024/11/30 13:16:01 Web app  > Server is running on port: 55501
2024/11/30 13:16:01 Web app  > Process(Whole App/Service) instance xid(random): ct59v4cn97dj54118l2g, OS process id: 12944
Debugger listening on ws://127.0.0.1:9229/ws/955a666c-c547-46c9-a6f8-7fea6490b9d5
Visit chrome://inspect to connect to the debugger.
error: Uncaught (in worker "[worker eval]") SyntaxError: Unexpected identifier 'parentPort'
    at <anonymous> (data:text/javascript,const { parentPort }......error(err)    }  }}):1:49)
[Object: null prototype] {
  message: "Uncaught SyntaxError: Unexpected identifier 'parentPort'",
  fileName: "data:text/javascript,const { parentPort } = require('worker_threads')parentPort.on('message', async worker => {  const response = {    error: null,    data: null  }  try {    eval(worker)    // __executor__ is defined in worker    response.data = await __executor__()    parentPort.postMessage(response)  } catch (err) {    response.data = null    response.error = {      message: err.message,      stack: err.stack    }    try {      parentPort.postMessage(response)    } catch (err) {      console.error(err)    }  }})", 
  lineNumber: 1,
  columnNumber: 49
}
```

Meanwhile, this program works fine in node/tsx and bun:

```console
PS F:\my-program> npm run dev:tsx 
> npx   tsx    watch  --inspect  --env-file=.env  src/main.ts

Debugger listening on ws://127.0.0.1:9229/085d4c46-186c-43c4-9676-95fc522e81c4
For help, see: https://nodejs.org/en/docs/inspector
run time is: C:\Apps\Nvm\Node\node.exe
Env check done.
```

```console
PS F:\my-program> npm run dev:bun
> bun   run  --watch  --inspect                   src/main.ts

--------------------- Bun Inspector ---------------------
Listening:
  ws://localhost:6499/m4h84jh099g
Inspect in browser:
  https://debug.bun.sh/#localhost:6499/m4h84jh099g
--------------------- Bun Inspector ---------------------
run time is: C:\Users\jason\scoop\apps\bun\1.1.38\bun.exe
Env check done.
```