From 752213bb3821c0e706025e96c0d7a80cea24bea3 Mon Sep 17 00:00:00 2001 From: Dami Oyeniyi Date: Tue, 24 Nov 2026 17:02:24 +0100 Subject: [PATCH] fix(lucide-react): include license banner once instead of in every module (#5209) * fix(lucide-react): include license banner once instead of in every module * Adjust config --------- Co-authored-by: grzdev Co-authored-by: Eric --- packages/lucide-react/rollup.config.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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'],