2024-03-06 21:03:12 +01:00
|
|
|
import plugins from '@lucide/rollup-plugins';
|
2025-01-10 14:35:28 +01:00
|
|
|
import preserveDirectives from 'rollup-plugin-preserve-directives';
|
2025-03-14 11:29:59 +01:00
|
|
|
import pkg from './package.json' with { type: 'json' };
|
2024-02-01 22:38:21 +09:00
|
|
|
import dts from 'rollup-plugin-dts';
|
2025-06-18 15:47:24 +02:00
|
|
|
import getAliasesEntryNames from './scripts/getAliasesEntryNames.mts';
|
2023-08-13 22:07:54 +02:00
|
|
|
|
2024-02-01 22:38:21 +09:00
|
|
|
const aliasesEntries = await getAliasesEntryNames();
|
2020-12-02 13:48:39 +01:00
|
|
|
|
2021-02-22 20:26:38 +01:00
|
|
|
const packageName = 'LucideReact';
|
|
|
|
|
const outputFileName = 'lucide-react';
|
2022-12-04 22:38:56 +01:00
|
|
|
const inputs = [`src/lucide-react.ts`];
|
2020-12-02 13:48:39 +01:00
|
|
|
const bundles = [
|
|
|
|
|
{
|
|
|
|
|
format: 'cjs',
|
|
|
|
|
inputs,
|
2025-02-19 11:33:08 +01:00
|
|
|
outputDir: 'dist/cjs',
|
2022-12-04 22:38:56 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
format: 'esm',
|
2025-02-19 11:33:08 +01:00
|
|
|
inputs: [...inputs, , 'src/dynamicIconImports.ts', 'src/DynamicIcon.ts', ...aliasesEntries],
|
|
|
|
|
outputDir: 'dist/esm',
|
2022-12-04 22:38:56 +01:00
|
|
|
preserveModules: true,
|
|
|
|
|
},
|
2023-08-06 15:47:07 +02:00
|
|
|
{
|
|
|
|
|
format: 'esm',
|
2025-02-19 11:33:08 +01:00
|
|
|
inputs: ['src/dynamic.ts'],
|
|
|
|
|
outputFile: 'dynamic.mjs',
|
2023-08-06 15:47:07 +02:00
|
|
|
external: [/src/],
|
|
|
|
|
paths: (id) => {
|
|
|
|
|
if (id.match(/src/)) {
|
2024-02-01 22:38:21 +09:00
|
|
|
const [, modulePath] = id.match(/src\/(.*)\.ts/);
|
2023-08-06 15:47:07 +02:00
|
|
|
|
2025-02-19 11:33:08 +01:00
|
|
|
return `dist/esm/${modulePath}.js`;
|
2023-08-06 15:47:07 +02:00
|
|
|
}
|
2024-02-01 22:38:21 +09:00
|
|
|
},
|
2023-08-06 15:47:07 +02:00
|
|
|
},
|
2020-12-02 13:48:39 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const configs = bundles
|
2024-02-01 22:38:21 +09:00
|
|
|
.map(
|
|
|
|
|
({
|
|
|
|
|
inputs,
|
|
|
|
|
outputDir,
|
|
|
|
|
outputFile,
|
|
|
|
|
format,
|
|
|
|
|
preserveModules,
|
|
|
|
|
entryFileNames,
|
|
|
|
|
external = [],
|
|
|
|
|
paths,
|
|
|
|
|
}) =>
|
|
|
|
|
inputs.map((input) => ({
|
|
|
|
|
input,
|
2025-01-10 14:35:28 +01:00
|
|
|
plugins: [
|
2025-08-01 12:47:22 +02:00
|
|
|
...plugins({ pkg }),
|
2025-01-10 14:35:28 +01:00
|
|
|
// Make sure we emit "use client" directive to make it compatible with Next.js
|
|
|
|
|
preserveDirectives({
|
|
|
|
|
include: 'src/DynamicIcon.ts',
|
|
|
|
|
suppressPreserveModulesWarning: true,
|
|
|
|
|
}),
|
|
|
|
|
],
|
2024-02-01 22:38:21 +09:00
|
|
|
external: ['react', 'prop-types', ...external],
|
|
|
|
|
output: {
|
|
|
|
|
name: packageName,
|
|
|
|
|
...(preserveModules
|
|
|
|
|
? {
|
2025-02-19 11:33:08 +01:00
|
|
|
dir: outputDir,
|
2024-02-01 22:38:21 +09:00
|
|
|
}
|
|
|
|
|
: {
|
2025-08-01 12:47:22 +02:00
|
|
|
file: outputFile ?? `${outputDir}/${outputFileName}.js`,
|
2024-02-01 22:38:21 +09:00
|
|
|
}),
|
|
|
|
|
paths,
|
|
|
|
|
entryFileNames,
|
|
|
|
|
format,
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
preserveModules,
|
2024-03-06 21:03:12 +01:00
|
|
|
preserveModulesRoot: 'src',
|
2024-02-01 22:38:21 +09:00
|
|
|
globals: {
|
|
|
|
|
react: 'react',
|
|
|
|
|
'prop-types': 'PropTypes',
|
|
|
|
|
},
|
2020-12-02 13:48:39 +01:00
|
|
|
},
|
2024-02-01 22:38:21 +09:00
|
|
|
})),
|
2020-12-02 13:48:39 +01:00
|
|
|
)
|
|
|
|
|
.flat();
|
|
|
|
|
|
2023-07-13 16:39:02 +02:00
|
|
|
export default [
|
2023-07-19 19:32:34 +02:00
|
|
|
{
|
|
|
|
|
input: 'src/dynamicIconImports.ts',
|
2024-02-01 22:38:21 +09:00
|
|
|
output: [
|
|
|
|
|
{
|
2025-02-19 11:33:08 +01:00
|
|
|
file: `dynamicIconImports.d.ts`,
|
2025-01-10 14:35:28 +01:00
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-02-19 11:33:08 +01:00
|
|
|
input: 'src/dynamic.ts',
|
2025-01-10 14:35:28 +01:00
|
|
|
output: [
|
|
|
|
|
{
|
2025-02-19 11:33:08 +01:00
|
|
|
file: `dynamic.d.ts`,
|
2024-02-01 22:38:21 +09:00
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-07-19 19:32:34 +02:00
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
2023-07-13 16:39:02 +02:00
|
|
|
{
|
|
|
|
|
input: inputs[0],
|
2024-02-01 22:38:21 +09:00
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/${outputFileName}.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-07-13 16:39:02 +02:00
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
2024-11-08 16:47:53 +01:00
|
|
|
{
|
|
|
|
|
input: `src/${outputFileName}.suffixed.ts`,
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/${outputFileName}.suffixed.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
input: `src/${outputFileName}.prefixed.ts`,
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/${outputFileName}.prefixed.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
2024-02-01 22:38:21 +09:00
|
|
|
...configs,
|
2023-07-13 16:39:02 +02:00
|
|
|
];
|