sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.45k stars 185 forks source link

native esm is experimental and doesn't yet work with test or monitoring code that must manipulate the code #147

Closed tcollinsworth closed 2 years ago

tcollinsworth commented 3 years ago

For example sinon mocking and newrelic agents have no workaround. Please consider keeping it esm but not native esm. Just drop the package.json type: module and don't use .mjs extensions. Then developers can still use the library as an esm module with all the goodness but without the code being locked from manipulation by mocks and instrumenting monitoring agents. And it doesn't force them to update their projects to native modules. And if someone knows different, please enlighten me.

After lots of pain updating my own libraries, I backed them all out of native esm for these very same reasons.

BryanHunt commented 3 years ago

I just spent the whole morning debugging TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/bhunt/.../test/basics.spec.ts and the root cause was using p-queue v7.x in the code I was trying to test. The code compiled just fine, but failed with the above error when running mocha with ts-node.

JordanShurmer commented 3 years ago

Just noting: I've encountered the exact same thing @BryanHunt describes above.

Is there any solution available to us? I've been digging into esm / ts-node stuff and haven't found anything useful yet.

JordanShurmer commented 3 years ago

For now I'm downgrading to ^6.0.0

mattgodbolt commented 3 years ago

I just hit a similar issue, when upgrading from 6.6.2 to 7.x my -r esm-based project gets MODULE_NOT_FOUND. strace-ing and node isn't looking for dist/index.js but only index.js (and a ton of other files).

spb-web commented 3 years ago

+

Richienb commented 2 years ago

ESM support is up to tooling to cover. See https://github.com/sindresorhus/p-queue/issues/144