x64Bits / solid-icons

The simplest way to use icons in SolidJS
https://solid-icons.vercel.app
MIT License
284 stars 18 forks source link

Unable to export packages that use solid-icons using rollup #50

Closed linkthai closed 8 months ago

linkthai commented 10 months ago

I'm trying to build a core library, which will get imported and used by multiple projects. I has an icon modules where it imports certain icons from solid-icons. The problem happens when I use rollup to bundle the library, all icons from solid-icons cause this error.

[!] RollupError: "RiDesignEdit2Line" is not exported by "node_modules/.pnpm/solid-icons@1.0.9_solid-js@1.7.6/node_modules/solid-icons/ri/index.cjs", imported by "src/components/base/icons/icons-remix.tsx".
https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module

Here are the rollup.config.ts

import ignoreImport from "rollup-plugin-ignore-import";
import withSolid from "rollup-preset-solid";

const plugins = [
  ignoreImport({
    // Ignore all .scss and .css file imports while building the bundle
    extensions: [".scss", ".css"],
    // Optional: replace body for ignored files. Default value is "export default undefined;"
    body: "export default undefined;",
  }),
];

export default withSolid([
  {
    input: "src/index.ts",
    targets: ["esm"],
    mappingName: "index",
    output: {
      file: "./dist/lib/index.js",
      format: "module",
      inlineDynamicImports: true,
    },
    plugins,
  },
  {
    input: "src/index.ts",
    mappingName: "index",
    solidOptions: {
      generate: "ssr",
      hydratable: false,
    },
    targets: ["cjs"],
    output: {
      file: "./dist/lib/index.cjs",
      format: "cjs",
    },
    plugins,
  },
]);
x64Bits commented 9 months ago

Hi @linkthai, thanks for reporting this, I'm almost sure this is due to the exports key in package.json, I've compared it with the export of the solid-js modules and it seems to have adopted the modern way depending on the runtime, this package (solid-icons) should also migrate that way.

This change would be included in 1.1.0 which is still in progress I hope it helps with this problem.

x64Bits commented 8 months ago

Hi @linkthai, version 1.1.0 has been released, could you check if this version corrects your problem? I was able to check and now it works to build in astro, greetings and thank you very much!

linkthai commented 7 months ago

Hello @x64Bits, I missed your question last time sorry for the late answer. I tried exporting with rollup and it worked absolutely fine now, thank you for the help.