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

Add self as preload script, to load in worker_threads and child processes. #1177

Open
cspotcode opened this issue Dec 16, 2020 · 3 comments
Open
Labels
enhancement research Needs design work, investigation, or prototyping. Implementation uncertain.

Comments

@cspotcode
Copy link
Collaborator

When user runs ts-node ./index.ts and the code spawns worker_threads and/or child_processes, these should also be able to require() .ts files.

This already happens with node --require ts-node/register, since that's inherited by child processes and worker threads.

Should we make our ts-node bin entrypoint behave the same way?


yarn uses NODE_OPTIONS='--require .pnp.js' to hook their PnP API into the runtime.
nyc uses some sort of child_process.spawn monkey-patching, but they also don't support worker_threads. Why don't they use NODE_OPTIONS?

nodejs/node#36531
nodejs/node#29117

Are there performance concerns? Can we avoid child processes/threads re-resolving tsconfig when the parent has already done so? By passing the necessary config via an env var, or maybe prepending a --require /tmp/ts-node-config-497f86.cjs?

@cspotcode cspotcode added enhancement research Needs design work, investigation, or prototyping. Implementation uncertain. labels Dec 16, 2020
@ChristianTucker
Copy link

Curious if there's any updates regarding this issue almost a year later, we've used ts-node exclusively in production for awhile, but we're having to move away from it as the worker_threads implementation can't find a .js file that doesn't exist, requiring us to build and run from node directly.

@cspotcode
Copy link
Collaborator Author

Is there a pull request for this? Are you able to send one to be reviewed? Have you tried the recommended approaches above?
Those approaches already work with ts-node in worker threads today. If you've tried them, did they work, or were there blockers?

Answers to these questions will help to triage this issue.

@cspotcode
Copy link
Collaborator Author

@ChristianTucker any update? Would appreciate your assistance to properly prioritize this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement research Needs design work, investigation, or prototyping. Implementation uncertain.
Projects
None yet
Development

No branches or pull requests

2 participants