d3 / d3-color

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.
https://d3js.org/d3-color
ISC License
398 stars 91 forks source link

Does the Common JS version of the module work? #95

Closed watson closed 2 years ago

watson commented 2 years ago

This modules ships with a Common JS version under a dist directory:

image

However, the exports field in package.json, is defined as such:

https://github.com/d3/d3-color/blob/7d61bbe6e426a7f3d3f4520a8b31cfc92dc69ee7/package.json#L35-L38

As far as I can see, these two entries doesn't really make any sense. E.g. there's no way that I know of to require the umd version of this package. Either the exports keys should all be prefixed with ./ which would require users to to update their require and import statements accordingly, or the two keys should be require and import instead of umd and default. In both cases the ./dist/d3-color.min.js key should be ./dist/d3-color.min.cjs (notice the cjs ending) since this is a package of "type": "module".

mbostock commented 2 years ago

CommonJS is no longer supported as of d3-color 3.0. In Node (or other environments that use package.json), you must use the ES module import. The UMD is intended for browsers, typically as either a vanilla script or AMD.