Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node 20.1.0 --loader can not longer listening process events #47914

Closed
joacub opened this issue May 8, 2023 · 2 comments
Closed

node 20.1.0 --loader can not longer listening process events #47914

joacub opened this issue May 8, 2023 · 2 comments
Labels
loaders Issues and PRs related to ES module loaders

Comments

@joacub
Copy link

joacub commented May 8, 2023

Version

20.1.0

Platform

any

Subsystem

any

What steps will reproduce the bug?

 const runProcess = spawn(
    process.execPath,
    [
      '--require',
      require.resolve('./preflight.cjs'),

      '--loader',
      pathToFileURL(require.resolve('./loader.js')).toString(),

      '--loader',
      '@wsy/hot-esm',

      ...argv,
    ],
    {
      stdio,
      env: environment,
    },);

runProcess.send({fileChanged: true, ...rest});

now loaders can not hear process events and some implementations like hot reload in dev mode can not be done (at least not with only one master watcher that propagates to child loaders in order to revalidate)

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

no response

Additional information

No response

@targos
Copy link
Member

targos commented May 8, 2023

Since Node.js 20, the loaders are not executed on the main application thread anymore, but on a separate worker thread.
You can establish a communication channel between the main thread and the loaders thread using the globalPreload hook: https://nodejs.org/dist/latest-v20.x/docs/api/esm.html#globalpreload

@targos targos added the loaders Issues and PRs related to ES module loaders label May 8, 2023
@aduh95
Copy link
Contributor

aduh95 commented May 22, 2023

Working as expected, closing. If you think the fox can be improved, please open a PR or comment on this issue.

@aduh95 aduh95 closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
loaders Issues and PRs related to ES module loaders
Projects
None yet
Development

No branches or pull requests

3 participants