-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: migrate to ESM #12
base: staging
Are you sure you want to change the base?
Conversation
40abc82
to
db6d789
Compare
Not sure if we need to fork this: andywer/threads.js#470 |
Might be able to use:
To bypass it. Now I think this would require a special |
db6d789
to
303b926
Compare
Actually I think I need to do a git submodule. That would be the easiest. |
Ok so trying to use a git submodule can be complicated due to the lack of dependencies being acquired under Going back to attempting with an import path. |
Actually even subpath imports does not work because the The only solution now is to either entirely fork the project or just provide overrides on the types, meaning we type out what The problem is none of the types work anymore.
Because of errors in how threads.js exposes the types. So we have to define all these types. |
Ok after setting the overriding the types to any, we still end up with a problem. Attempting to create a worker from a file written in TS requires
Of course if I change to just using regular But then it's not possible to do
Is necessary to actually get the constructs necessary, but the workers no longer have any corresponding types. I think though one could use annotations. But generally speaking, it's just not a good idea to use typescript based workers atm since we shouldn't be tied to ts-node anyway (even if it is only during development), because after compilation it would all be JS files anyway. For some reason All in all, I don't think as of now I might have to be forced to keep |
Going to try keeping js-workers as CJS, and long term wise look into removing threadsjs and favour of something in our flavour. Can see https://github.com/piscinajs/piscina for inspiration. |
…rporated into our libraries and rewritten
I think we just remove browser support for the moment, and focus on nodejs worker threads, similar to our project in js-ws, and then slowly add back in webworker (browser support) afterwards. This can radically simplify this project and give us ESM support too. This could be assigned to @addievo. |
Going over the https://nodejs.org/api/worker_threads.html shows that the worker threads implementation will be quite complex. Here's a brief overview of things that need to be considered:
Point is, fixing up this worker ecosystem is extremely complicated. The This would be significant undertaking - estimated work would have to be 2 - 4 months to build a robust worker system that abides by the rest of PK's principles (I'm comparing it to how complicated js-quic became, but it should be simpler). Will need to schedule this for later after testnet 7. |
Description
Migrating to ESM.
The
QueuedTask
should be exported now: andywer/threads.js@7ef6eedAlso this is broken currently due to andywer/threads.js#470
Issues Fixed
Tasks
Final checklist