d3 / d3-shape

Graphical primitives for visualization, such as lines and areas.
https://d3js.org/d3-shape
ISC License
2.48k stars 310 forks source link

Error importing via unpkg #132

Closed adorsk closed 5 years ago

adorsk commented 6 years ago

When trying to import d3 from unpkg I get a 404 that appears to come from d3-shape.

For example, try pasting this into an index.html file and opening it with a browser:

<html>
<body>
    <script type="module">
        import d3 from 'https://unpkg.com/d3@5.7.0?module'
        console.log("Hello d3!", d3)
    </script>
</body>
</html>

When I open the above file in a browser I see this console message:

unpkg.com/d3-shape@1.2.2/src/symbol?module Failed to load resource: the server responded with a status of 404 ()

The offending import seems to be: https://unpkg.com/d3-shape@1.2.2/src/symbol?module. If you go to that URL this message appears:

Cannot find an index in "/src/symbol" in d3-shape@1.2.2`

The issue appears to be that unpkg attempts to resolve an import for ./symbol?module from a non-existent /src/symbol/index.js file, rather than the existing /src/symbol.js file.

One solution to this is to simple rename the file /src/symbol.js to /src/symbols.js, and update /src/index.js appropriately.

I will make a PR for this solution shortly, and will reference this issue in that PR.

mbostock commented 5 years ago

Fixed in 68720c7415c7340081605a81dd01791c1759c2d0.