diff --git a/packages/lucide-svelte/package.json b/packages/lucide-svelte/package.json index 6b4b4bcd4cb..ee45d8d6693 100644 --- a/packages/lucide-svelte/package.json +++ b/packages/lucide-svelte/package.json @@ -36,7 +36,8 @@ }, "./icons/*": { "types": "./dist/icons/*.svelte.d.ts", - "svelte": "./dist/icons/*.svelte" + "svelte": "./dist/icons/*.js", + "default": "./dist/icons/*.js" } }, "typings": "dist/lucide-svelte.d.ts", @@ -48,7 +49,7 @@ "build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:package && pnpm build:license", "copy:license": "cp ../../LICENSE ./LICENSE", "clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.svelte && rm -f index.js", - "build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --exportFileName=index.ts --iconFileExtension=.svelte --importImportFileExtension=.svelte --withAliases --aliasesFileExtension=.ts --aliasImportFileExtension=.svelte --pretty=false", + "build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --exportFileName=index.ts --iconFileExtension=.svelte --importImportFileExtension=.svelte --separateIconFileExport --separateIconFileExportExtension=.ts --withAliases --aliasesFileExtension=.ts --separateAliasesFile --separateAliasesFileExtension=.ts --aliasImportFileExtension=.ts --pretty=false", "build:package": "svelte-package --input ./src", "build:license": "node ./scripts/appendBlockComments.mjs", "test": "pnpm build:icons && vitest run", diff --git a/packages/lucide-svelte/scripts/license.mjs b/packages/lucide-svelte/scripts/license.mjs index 3c39a02b6f2..3ef4f0306c8 100644 --- a/packages/lucide-svelte/scripts/license.mjs +++ b/packages/lucide-svelte/scripts/license.mjs @@ -1,4 +1,4 @@ -import pkg from '../package.json' assert { type: 'json' }; +import pkg from '../package.json' with { type: 'json' }; export function getJSBanner() { return `/** diff --git a/packages/lucide/rollup.config.mjs b/packages/lucide/rollup.config.mjs index 3d64d9d0e59..a4840c024b5 100644 --- a/packages/lucide/rollup.config.mjs +++ b/packages/lucide/rollup.config.mjs @@ -1,7 +1,7 @@ import plugins from '@lucide/rollup-plugins'; import replace from '@rollup/plugin-replace'; import dts from 'rollup-plugin-dts'; -import pkg from './package.json' assert { type: 'json' }; +import pkg from './package.json' with { type: 'json' }; const outputFileName = pkg.name; const outputDir = 'dist'; diff --git a/tools/build-icons/building/aliases/generateAliasesFiles.mjs b/tools/build-icons/building/aliases/generateAliasesFiles.mjs index 52927e7a089..043613475a6 100644 --- a/tools/build-icons/building/aliases/generateAliasesFiles.mjs +++ b/tools/build-icons/building/aliases/generateAliasesFiles.mjs @@ -14,6 +14,7 @@ export default async function generateAliasesFiles({ aliasImportFileExtension, aliasNamesOnly = false, separateAliasesFile = false, + separateAliasesFileExtension, showLog = true, }) { const iconsDistDirectory = path.join(outputDirectory, `icons`); @@ -96,8 +97,13 @@ export default async function generateAliasesFiles({ : ''; if (separateAliasesFile) { - const output = `export { default } from "./${iconName}"`; - const location = path.join(iconsDistDirectory, `${alias.name}${iconFileExtension}`); + const output = `export { default } from "./${iconName}${ + separateAliasesFileExtension ? iconFileExtension : '' + }";\n`; + const location = path.join( + iconsDistDirectory, + `${alias.name}${separateAliasesFileExtension ?? iconFileExtension}`, + ); await fs.promises.writeFile(location, output, 'utf-8'); } diff --git a/tools/build-icons/building/generateIconFiles.mjs b/tools/build-icons/building/generateIconFiles.mjs index 0a8aadd4dff..691729e5913 100644 --- a/tools/build-icons/building/generateIconFiles.mjs +++ b/tools/build-icons/building/generateIconFiles.mjs @@ -10,6 +10,8 @@ export default ({ template, showLog = true, iconFileExtension = '.js', + separateIconFileExport = false, + separateIconFileExportExtension, pretty = true, iconsDir, iconMetaData, @@ -46,6 +48,7 @@ export default ({ deprecated, deprecationReason, }); + const output = pretty ? prettier.format(elementTemplate, { singleQuote: true, @@ -56,6 +59,16 @@ export default ({ : elementTemplate; await fs.promises.writeFile(location, output, 'utf-8'); + + if (separateIconFileExport) { + const output = `export { default } from "./${iconName}${iconFileExtension}";\n`; + const location = path.join( + iconsDistDirectory, + `${iconName}${separateIconFileExportExtension ?? iconFileExtension}`, + ); + + await fs.promises.writeFile(location, output, 'utf-8'); + } }); Promise.all(writeIconFiles) diff --git a/tools/build-icons/cli.mjs b/tools/build-icons/cli.mjs index 31e4830155f..c710cf70765 100755 --- a/tools/build-icons/cli.mjs +++ b/tools/build-icons/cli.mjs @@ -34,6 +34,9 @@ const { aliasNamesOnly = false, withDynamicImports = false, separateAliasesFile = false, + separateAliasesFileExtension = undefined, + separateIconFileExport = false, + separateIconFileExportExtension = undefined, aliasesFileExtension = '.js', aliasImportFileExtension = '', pretty = true, @@ -59,6 +62,8 @@ async function buildIcons() { template: iconFileTemplate, showLog: !silent, iconFileExtension, + separateIconFileExport, + separateIconFileExportExtension, pretty: JSON.parse(pretty), iconsDir: ICONS_DIR, iconMetaData, @@ -75,6 +80,7 @@ async function buildIcons() { exportModuleNameCasing, aliasImportFileExtension, separateAliasesFile, + separateAliasesFileExtension, showLog: !silent, }); } diff --git a/tools/build-icons/utils/getAliases.mjs b/tools/build-icons/utils/getAliases.mjs index 342741acdd6..1d469fc06b5 100644 --- a/tools/build-icons/utils/getAliases.mjs +++ b/tools/build-icons/utils/getAliases.mjs @@ -5,7 +5,7 @@ async function getAliases(iconDirectory) { const iconJsons = readSvgDirectory(iconDirectory, '.json'); const aliasesEntries = await Promise.all( iconJsons.map(async (jsonFile) => { - const file = await import(path.join(iconDirectory, jsonFile), { assert: { type: 'json' } }); + const file = await import(path.join(iconDirectory, jsonFile), { with: { type: 'json' } }); return [path.basename(jsonFile, '.json'), file.default]; }), ); diff --git a/tools/build-icons/utils/getIconMetaData.mjs b/tools/build-icons/utils/getIconMetaData.mjs index 7c8c149caee..e03bdaa0278 100644 --- a/tools/build-icons/utils/getIconMetaData.mjs +++ b/tools/build-icons/utils/getIconMetaData.mjs @@ -6,7 +6,7 @@ async function getIconMetaData(iconDirectory) { const aliasesEntries = await Promise.all( iconJsons.map(async (jsonFile) => { /** eslint-disable */ - const file = await import(path.join(iconDirectory, jsonFile), { assert: { type: 'json' } }); + const file = await import(path.join(iconDirectory, jsonFile), { with: { type: 'json' } }); return [path.basename(jsonFile, '.json'), file.default]; }), );