tailwindlabs / heroicons

A set of free MIT-licensed high-quality SVG icons for UI development.

Home Page:https://heroicons.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building library using Vite >=4.1.0 breaks due to heroicons/vue import

Aellynd opened this issue · comments

For my component library I have been using Vite, Vue3 and Heroicons to build and release the library as an NPM package. Recently I have been trying to upgrade Vite, but to no avail. I keep receiving the same error:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/vue.js?v=1ab4962e' does not provide an export named 'default' (at my-library.mjs:1:8)

I looked into this error further an discovered the following in my-library.mjs:

import sl from "vue";

...

, { createElementVNode: mv, openBlock: vv, createElementBlock: gv } = sl;
var yv = function(t, n) {
  return vv(), gv("svg", {
    xmlns: "http://www.w3.org/2000/svg",
    fill: "none",
    viewBox: "0 0 24 24",
    "stroke-width": "1.5",
    stroke: "currentColor",
    "aria-hidden": "true"
  }, [
    mv("path", {
      "stroke-linecap": "round",
      "stroke-linejoin": "round",
      d: "M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
    })
  ]);
}, bv = yv;

and since Vue has no default export, this appears to be causing issues. The snippet above made me realise the error was coming from svgs and my mind turned towards the heroicons/vue package. When I remove all the imports of heroicons/vue, the error disappears and the library is working as expected. Hence my issue on this board.

I have created a minimal reproduction repository at: https://github.com/Aellynd/vite-heroicons-issue

Please note the issue only started after upgrading to Vite >= 4.1.0 which has made me think it may have something to do with rollup or esbuild. Sadly I have little experience in this area, so I will happily hear your thoughts.

Thanks in advance!
-- Riki

P.S. this is my first bug report, so please let me know if you need any additional information.

Looks like this was already fixed but a release wasn't tagged. I'll get that out today. Thanks!

@Aellynd Okay I've published v2.0.18 which fixes this problem. Thanks for reporting it!

@Aellynd Okay I've published v2.0.18 which fixes this problem. Thanks for reporting it!

Thank you for the quick response, it's very much appreciated! It solves my problem 👍