diff --git a/packages/lucide-react/rollup.config.mjs b/packages/lucide-react/rollup.config.mjs index dffb93ee7..630f463d9 100644 --- a/packages/lucide-react/rollup.config.mjs +++ b/packages/lucide-react/rollup.config.mjs @@ -59,6 +59,11 @@ const bundles = [ }, ]; +// Only add the license banner to Icon.mjs in ESM builds, so it appears once in a bundle (#3744). +// Every icon imports Icon. The CJS build is one file and keeps its banner. +const licenseModuleMatcher = /[/\\]src[/\\]Icon\.ts$/; +const isNotLicenseChunk = (chunk) => !licenseModuleMatcher.test(chunk.facadeModuleId ?? ''); + const configs = bundles .map( ({ @@ -76,7 +81,11 @@ const configs = bundles inputs.map((input) => ({ input, plugins: [ - ...plugins({ pkg, minify }), + ...plugins({ + pkg, + minify, + licenseBannerExclude: format === 'esm' ? isNotLicenseChunk : undefined, + }), // Make sure we emit "use client" directive to make it compatible with Next.js preserveDirectives({ include: ['src/lucide-react.ts', 'src/DynamicIcon.ts', 'src/context.ts', 'src/Icon.ts'],