jsDelivr captures the version of a dependency when a module is bundled. This means that you can end up with multiple versions of a dependency. When this happens, the module might not behave correctly (for example if it uses instanceof).
Here d3-interpolate 3.0.1 is loading d3-color 3.0.1, but d3 7.9.0 is loading the more recent d3-color 3.1.0. And hence the d3.hcl instance you pass into d3.interpolateHcl is not detected correctly, and hence is converted to sRGB, such that the chroma (c) channel becomes NaN instead of 0.
You can fix this by loading D3 from esm.sh instead of jsDelivr:
import * as d3 from "https://esm.sh/d3";
This problem is not unique to D3; it affects many libraries, including React. I didn’t realize until now that this was already affecting D3, so thank you for the report. I’ve done more analysis in this notebook:
Wow. Thank you for looking at this, taking the time to explain what is going on, and sharing the code that you used! I vaguely knew that I could end up with conflicting versions of a package via external dependencies (i.e. a imports d3@7.9.0 while b imports d3@7.8.0), but it had not occurred to me that this might occur via a package’s own internal imports. That’s a subtle and nasty bug (in jsDelivr!).