fix(build-icons): support Windows paths in dynamic imports for template and metadata (#5058)

Co-authored-by: grzdev <grzdev@users.noreply.github.com>
This commit is contained in:
Dami Oyeniyi
2026-10-23 16:45:06 +02:00
committed by GitHub
co-authored by grzdev
parent 9158d44cde
commit 9ad51a07f4
2 changed files with 9 additions and 2 deletions
+5 -1
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { pathToFileURL } from 'url';
import getArgumentOptions from 'minimist';
import { readSvgDirectory } from '@lucide/helpers';
@@ -76,7 +77,9 @@ async function buildIcons() {
const icons = await renderIconsObject(svgFiles, ICONS_DIR, renderUniqueKey);
const { default: iconFileTemplate } = await import(path.resolve(process.cwd(), templateSrc));
const { default: iconFileTemplate } = await import(
pathToFileURL(path.resolve(process.cwd(), templateSrc)).href
);
const iconMetaData = await getIconMetaData(ICONS_DIR);
@@ -135,4 +138,5 @@ try {
await buildIcons();
} catch (error) {
console.error(error);
process.exitCode = 1;
}
+4 -1
View File
@@ -1,4 +1,5 @@
import path from 'path';
import { pathToFileURL } from 'url';
import { readSvgDirectory } from '@lucide/helpers';
import { type IconMetadata } from '../types.ts';
@@ -7,7 +8,9 @@ async function getIconMetaData(iconDirectory: string): Promise<Record<string, Ic
const aliasesEntries = await Promise.all(
iconJsons.map(async (jsonFile: string) => {
/** eslint-disable */
const file = await import(path.join(iconDirectory, jsonFile), { with: { type: 'json' } });
const file = await import(pathToFileURL(path.join(iconDirectory, jsonFile)).href, {
with: { type: 'json' },
});
return [path.basename(jsonFile, '.json'), file.default];
}),
);