piscinajs / piscina

A fast, efficient Node.js Worker Thread Pool implementation
https://piscinajs.github.io/piscina/
Other
4.4k stars 107 forks source link

Support for loading ES Module in require() is an experimental feature #697

Open bennypowers opened 2 weeks ago

bennypowers commented 2 weeks ago

Thank you for publishing this helpful package.

This issue is similar to #85

When loading ESM workers, the following error is logged by node v23.2.0:

(node:404242) ExperimentalWarning: CommonJS module /path/to/node_modules/piscina/dist/worker.js is loading ES Module /path/to/worker.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

This could perhaps be avoided with export conditions in the piscina package:

  "type": "module",
  "exports": {
    "types": "./dist/index.d.ts",
    "import": "./dist/main.js",
    "require": "./dist/cjs/main.cjs"
  },
metcoder95 commented 2 weeks ago

👋 Thanks for the heads up!

This is something we will be exploring once the require(ESM) goes out of experimental, and most likely until v24 comes out. In the meanwhile this is expected behavior, a documentation support will be highly appreciated