d3 / d3

Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

Home Page:https://d3js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

package.json is not exported

janhommes opened this issue · comments

We are using a tool that determines all versions of our main dependencies (needed for module federation) and had an issue with d3. As we are using a mono-repo with yarn workspaces, we are using the node.js resolving algorithm to get the right package.json and read from there the version number:
require.resolve(d3/package.json).version

However for d3 node throws an error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /path/to/node_modules/d3/package.json

It seems like node recommends all packages to export the package.json as well for such use-cases:
nodejs/node#33460

Question is, is it intended that d3 does not export the package.json in the exports property? Can this be changed and is a PR welcome for this?

To reproduce:

npm init -f
npm i d3
touch test.js
echo "require.resolve('d3/package.json')" > test.js
node test.js

Actual:
ERR_PACKAGE_PATH_NOT_EXPORTED

Should:
Would be nice if no error is thrown 🥳

Sorry, but I’m not going to support this.

Any reason why not? I guess the change will be rather simple.