lucide-icons / lucide

Beautiful & consistent icon toolkit made by the community. Open-source project and a fork of Feather Icons.
https://lucide.dev
ISC License
11.66k stars 539 forks source link

SyntaxError: Unexpected token 'export' #1828

Open d-strygwyr opened 10 months ago

d-strygwyr commented 10 months ago

Package

Version

0.314.0

Browser

Operating system

Description

i made some shared components for the internal library with turbo repo, after build and publish then we consume we got

SyntaxError: Unexpected token 'export' like this

Screenshot 2024-01-23 214300

import type { LucideProps } from "lucide-react";
import dynamicIconImports from "lucide-react/dynamicIconImports.js";
import { lazy, Suspense } from "react";

import { cn } from "../../utils";

interface IconProps extends Omit<LucideProps, "ref"> {
  name: keyof typeof dynamicIconImports;
}

export function Icon({
  className = "",
  name,
  ...props
}: IconProps): JSX.Element {
  const LucideIcon = lazy(dynamicIconImports[name]);

  return (
    <Suspense>
      <div className={cn("w-4 h-4", className)}>
        <LucideIcon className={cn("w-4 h-4", className)} {...props} />
      </div>
    </Suspense>
  );
}

Steps to reproduce

  1. create component Icon.tsx using turbo repo
import type { LucideProps } from "lucide-react";
import dynamicIconImports from "lucide-react/dynamicIconImports.js";
import { lazy, Suspense } from "react";

import { cn } from "../../utils";

interface IconProps extends Omit<LucideProps, "ref"> {
  name: keyof typeof dynamicIconImports;
}

export function Icon({
  className = "",
  name,
  ...props
}: IconProps): JSX.Element {
  const LucideIcon = lazy(dynamicIconImports[name]);

  return (
    <Suspense>
      <div className={cn("w-4 h-4", className)}>
        <LucideIcon className={cn("w-4 h-4", className)} {...props} />
      </div>
    </Suspense>
  );
}
  1. build and publish to npm
  2. consume the library
  3. then we got this Screenshot 2024-01-23 214300

Checklist

Kozioleczek commented 7 months ago

Hey @xhttp-res have you managed to resolve that issue somehow?

d-strygwyr commented 7 months ago

nope @Kozioleczek 😿