andywer / andywer/threads.js

Avoid use of `eval` in worker_threads.ts?

未關閉
#382 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
3.5k
分支
173
PR 合併指標
30 天內沒有已合併 PR

描述

https://github.com/andywer/threads.js/blob/42b1042f9a0057fd25c94807ba4ac988e6475916/src/worker_threads.ts#L20

Thanks for all your work on `threads.js`! I am working with `rollup` and running into an issue due to the use of `eval("require")("worker_threads")` when creating an ESM output. Rollup cannot convert the `eval("require")` to a top-level import statement `import require$$0 from 'worker_threads'` since it doesn't not recognize it statically as a commonjs `require("worker_threads")`.

This means that in the final ESM bundle ends up with a `eval("require")` which throws at runtime since require is not allowed when using ESM in node. I see the comment "Webpack hack" and am curious if the use of eval is a part of that hack? Or would there be an option to avoid the use of `eval` and change this to `require("worker_threads")`? Cheers!

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。