nodejs / nodejs/node

`--conditions xxx` cannot pass into `worker_thread`

Open
#50,885 21 comments 1 reaction 1 assignee View on GitHub

@juanarbol is already working on this.

Since Nov 23, 2023.

confirmed-bug esm loaders module worker
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v20.10.0

Platform

Darwin Alexs-MacBook-Pro.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020 arm64

Subsystem

module

What steps will reproduce the bug?
// main.js
import { Worker } from 'node:worker_threads'

new Worker(new URL('worker.js', import.meta.url), {
  execArgv: ['--conditions', 'react-server']
})
// worker.js
import { register } from 'node:module'

register('./register.js', import.meta.url)

console.log('1')

import('./test.js')
// register.js
export async function resolve (specifier, context, nextResolve) {
  // Take an `import` or `require` specifier and resolve it to a URL.
  console.log('context', context.conditions)
  return nextResolve(specifier, context, nextResolve)
}

export async function load (url, context, nextLoad) {
  return nextLoad(url, context, nextLoad)
}
// test.js
console.log('3')
How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?
1
context [ 'node', 'import', 'node-addons', 'react-server' ]
3
What do you see instead?
1
context [ 'node', 'import', 'node-addons' ]
3
Additional information

Might cause RSC bundle issue https://github.com/dai-shi/waku/pull/178

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.