Open lgarron opened 3 years ago
I'm trying to tackle https://github.com/lgarron/web-worker-compat-problems/blob/main/README.md#problem-9-node-workers-differ-from-browsers so I can avoid a source of pain at https://github.com/cubing/jsss/tree/scrambles/src/scrambles/worker/getNodeAdapter :-P
I would love to see this for better compatibility with standard-module-only toolchains.
Right now, it's not possible to import something like
comlink/node-adapter
and automatically get CJS or ESM depending on the environment.node
and some bundlers support:An alternative would be to add
/node-adapter/package.json
or/dist/node-adapter/package.json
containing:Does the former seem reasonable? If not, does the latter?
One caveat is that
exports
can//should prevent importing any other files directly, so we'd need more fields if we want to export the minified versions so they can be used directly innode
or bundlers that supportexports
. (If the minified files are mainly meant for using manually, this is not needed.)