sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.41k stars 182 forks source link

Imports broken #134

Closed jonathborg closed 3 years ago

jonathborg commented 3 years ago

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/joe/Code/dompedro/automacao-efleet/node_modules/p-queue/dist/index.js require() of ES modules is not supported.

v7.0.0

sindresorhus commented 3 years ago

Please read the release notes.

jonathborg commented 3 years ago

I just used ES6 imports, still the same. I'm using ts-node and it's working with another libraries. Am I doing something wrong?

lineape commented 3 years ago

I'm having the same issues. Doesn't play well with webpack.

I'm going to have to stay on the old version for now.

devmondo commented 3 years ago

I confirm what @lineape said, I am also having issue with Wepack 5.

sindresorhus commented 3 years ago

I'm having the same issues. Doesn't play well with webpack.

It's the other way around. Webpack (or your Webpack config) doesn't play well with ESM.

sindresorhus commented 3 years ago

I have updated my ESM guide with more info: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

jpike88 commented 3 years ago

@sindresorhus you've just broken pretty much every script that uses this library with a bundler. I get that Node 10 is EOL and Node 12 supports ESM, but seems a little overkill to just dump CommonJS support because of an arbitrary cutoff. Standards take time to change, change management itself is a slow moving thing, and a bridge needs to exist in between. My bundler does not have a chance any time soon of using native ESM, even though I run all my environments in Node 14. I guess I have to pin this to the older version indefinitely.

sindresorhus commented 3 years ago

For what it's worth, bundlers had years to get ready for native ESM.

Users now expect packages to be native ESM (this package even required moving to ESM to fix some TypeScript problem). I could support a dual scheme, but I have chosen not to as it is difficult to set up correctly and requires more maintenance. I'm also hoping to push the community to move to ESM sooner than later, which will benefit everyone in the long run.

Out of curiosity, what bundler are you using? And does it have an issue open about ESM support?

jpike88 commented 3 years ago

Am using fusebox as the builder. Just currently confirming with @nchanged whether it's an issue with the bundler itself or not

npomfret commented 3 years ago

I've read the notes and I still don't understand what I need to do to get this working with ts-node. Can someone please explain?