Skip to content

A masive bunch of chunks before #1448

@0w4n

Description

@0w4n

Description

My tech stack that I currently use is:

Vite: 6.4.1,
Tabler/icons-react: 3.36.0

And the same issue it ocurred again.

For put some points at the road, I use firebase database services to get the icon's name. Cause that, I created a file to dynamically import only the icon that I'm going to use not all the bunch.

But honestly these doesn't occured...

Package

  • @tabler/icons
  • @tabler/icons-eps
  • @tabler/icons-pdf
  • @tabler/icons-png
  • @tabler/icons-webfont
  • @tabler/icons-sprite
  • @tabler/icons-preact
  • @tabler/icons-react
  • @tabler/icons-react-native
  • @tabler/icons-solid
  • @tabler/icons-svelte
  • @tabler/icons-svelte-runes
  • @tabler/icons-vue
  • Figma plugin
  • source/main
  • other/not relevant

Version

3.36.0

Browser

  • Chrome/Chromium
  • Firefox
  • Safari
  • Edge
  • iOS Safari
  • Opera
  • Other/not relevant

Operating system

  • Windows
  • Linux
  • macOS
  • ChromeOS
  • iOS
  • Android
  • Other/not relevant

Steps to reproduce

  1. Use the code below:
import {
  forwardRef,
  createElement,
  lazy,
  Suspense,
  type ComponentType,
} from "react";

type TablerIconComponent = ComponentType<any>;

const iconCache: Record<string, TablerIconComponent> = {};

function loadIcon(name: string) {
  if (!iconCache[name]) {
    iconCache[name] = lazy(async () => {
      const mod = await import("@tabler/icons-react");

      const Icon = (mod as unknown as Record<string, TablerIconComponent>)[name];

      if (!Icon) {
        throw new Error(`Tabler icon "${name}" does not exist`);
      }

      return { default: Icon };
    });
  }

  return iconCache[name];
}

const Icon = forwardRef(
  (
    {
      name,
      size = 24,
      color = "currentColor",
      strokeWidth = 2,
      className = "",
      ...rest
    }: any,
    ref
  ) => {
    if (!name) return null;

    const Icon = loadIcon(name);

    return (
      <Suspense fallback={null}>
        {createElement(Icon, {
          ref,
          size,
          color,
          strokeWidth,
          className,
          ...rest,
        })}
      </Suspense>
    );
  }
);

Icon.displayName = "Icon";

export default Icon;

  1. Run the app
  2. Notice that network seccion all the chuncks

Checklist

  • I have searched if someone has submitted a similar issue before and there weren't any. (Please make sure to also search closed issues, as this issue might already have been resolved.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions