Open mbostock opened 3 years ago
Those are all great suggestions, thank you. We agree that while the current code snippets work for most packages, they definitely break for some, and it’s not ideal. Especially for things like d3-format
.
We had actually discussed #3—letting package authors control the import—but like you pointed out that won’t automatically provide good defaults for everyone.
In preparation for this we have started collecting more package info behind-the-scenes for the possibility of a better import. Let me see what we can do about a better snippet, at least an improvement from what’s there now.
Some packages (e.g., d3-format) do not provide a default export; instead they provide named exports. These named imports can be imported individually or as a namespace with
*
. Yet Skypack doesn’t seem to detect whether a package has a default export and always recommends importing the default export even if none exists:This results in broken code since
d3Format
will be undefined. What we need instead is:Or perhaps better:
This problem extends to the “Open in CodePen” button, which directs users to CodePen with some broken default code.
Some possible options:
*
instead.