sindresorhus / p-queue

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

Fixed `package.json` not exported error and warnings when using this library #138

Closed mationai closed 3 years ago

mationai commented 3 years ago

Package.json should export itself has well as the js file. Without it, bundlers such as rollup will complain about it, see eg. below. This PR fixes it by exporting both.

Eg.: [rollup-plugin-svelte] The following packages did not export their package.json file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.

sindresorhus commented 3 years ago

Sorry, I'm not interested in changing my package to please bundlers. This should be properly fixed in Rollup instead.

mationai commented 3 years ago

It's not just Rollup, others will complain about it too since it's not properly configured, please see https://nodejs.org/api/packages.html#packages_package_entry_points

sindresorhus commented 3 years ago

I disagree with your assessment that it's not properly configured. Previously, package consumers could import any subpath from a package, making it possible for consumers to import internal modules, etc. Now, we explicitly export what's public. I don't think every package should have to export their package.json. That's just a losing battle for bundlers. They should instead directly read the package.json file using the fs methods. That way it will work for any package. Please do open an issue on your bundler about this.

mationai commented 3 years ago

Appreciate your reasoning for the close.