mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
fix(lucide-react-native): emit runtime files for alias icon subpaths (#5055)
closes #5043 Agent: claude Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
This commit is contained in:
@@ -55,11 +55,12 @@
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:bundles",
|
||||
"build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:bundles && pnpm check:icon-subpaths",
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE",
|
||||
"clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.ts",
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mts --renderUniqueKey --iconFileExtension=.ts --exportFileName=index.ts --withAliases --separateAliasesFile --separateAliasesFileIgnore=fingerprint --aliasesFileExtension=.ts",
|
||||
"build:bundles": "rollup -c ./rollup.config.mjs",
|
||||
"check:icon-subpaths": "node ./scripts/checkIconSubpaths.mts",
|
||||
"test": "pnpm build:icons && vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"typecheck": "pnpm build:icons && tsc"
|
||||
|
||||
@@ -11,7 +11,14 @@ const dtsOptions = {
|
||||
const packageName = 'LucideReact';
|
||||
const outputFileName = 'lucide-react-native';
|
||||
const outputDir = 'dist';
|
||||
const inputs = ['src/lucide-react-native.ts', 'src/icons/index.ts'];
|
||||
const iconAndAliasEntries = await getIconEntryNamesAndAliases();
|
||||
// Alias modules (e.g. `icons/trash-2`) aren't imported by the index, so list them as entries
|
||||
// to emit the runtime files the `./icons/*` export map points at.
|
||||
const inputs = [
|
||||
'src/lucide-react-native.ts',
|
||||
'src/icons/index.ts',
|
||||
...Object.values(iconAndAliasEntries),
|
||||
];
|
||||
const bundles = [
|
||||
{
|
||||
format: 'cjs',
|
||||
@@ -28,7 +35,6 @@ const bundles = [
|
||||
},
|
||||
];
|
||||
|
||||
const iconAndAliasEntries = await getIconEntryNamesAndAliases();
|
||||
const typesModuleMatcher = /[/\\]src[/\\]types\.(d\.)?ts$/;
|
||||
|
||||
const configs = bundles.map(({ inputs, outputDir, format, preserveModules, extension = 'js' }) => ({
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Fails the build when an `icons/*` subpath has type declarations but no runtime file.
|
||||
import { existsSync, readdirSync } from 'node:fs';
|
||||
|
||||
const declarations = readdirSync('dist/types/icons').filter((file) => file.endsWith('.d.ts'));
|
||||
|
||||
const missing = declarations.flatMap((file) => {
|
||||
const name = file.replace(/\.d\.ts$/, '');
|
||||
return [`dist/esm/icons/${name}.mjs`, `dist/cjs/icons/${name}.js`].filter(
|
||||
(runtimeFile) => !existsSync(runtimeFile),
|
||||
);
|
||||
});
|
||||
|
||||
if (missing.length > 0) {
|
||||
console.error(`Missing runtime files for icon subpaths:\n${missing.join('\n')}`);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user