refactor: Adds repo shared package @lucide/shared (#1904)

* Fixed import of toKebabCase helper function

* Added utils package

* utils

* Make utils package work in build

* Add lucide-shared

* Transpile solid with esbuild

* Fix resolve modules

* Cleanup

* Format files

* Fix properties plugins function

* Fix properties plugins in lucide package

* Revert remove resolve plugin and cleanup

* Update snapshots

* Revert icon changes

---------

Co-authored-by: Rohan <rohancrrm@gmail.com>
This commit is contained in:
Eric Fennis
2024-03-06 21:03:12 +01:00
committed by GitHub
parent d255c6ac4e
commit ad1accb2e3
33 changed files with 11267 additions and 3153 deletions

View File

@@ -46,6 +46,7 @@
"devDependencies": {
"@lucide/build-icons": "workspace:*",
"@lucide/rollup-plugins": "workspace:*",
"@lucide/shared": "workspace:*",
"@testing-library/jest-dom": "^6.1.6",
"@testing-library/vue": "^8.0.1",
"@vitejs/plugin-vue": "^4.6.2",

View File

@@ -35,7 +35,7 @@ const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map((input) => ({
input,
plugins: plugins(pkg, minify),
plugins: plugins({ pkg, minify }),
external: ['vue'],
output: {
name: packageName,
@@ -48,6 +48,7 @@ const configs = bundles
}),
format,
preserveModules,
preserveModulesRoot: 'src',
sourcemap: true,
globals: {
vue: 'vue',

View File

@@ -1,6 +1,7 @@
import { h } from 'vue';
import type { SVGAttributes, FunctionalComponent, DefineComponent } from 'vue';
import type { SVGAttributes, FunctionalComponent } from 'vue';
import defaultAttributes from './defaultAttributes';
import { toKebabCase } from '@lucide/shared';
// Create interface extending SVGAttributes
export interface SVGProps extends Partial<SVGAttributes> {
@@ -11,17 +12,13 @@ export interface SVGProps extends Partial<SVGAttributes> {
export type IconNode = [elementName: string, attrs: Record<string, string>][];
export type Icon = FunctionalComponent<SVGProps>;
/**
* Converts string to KebabCase
* Copied from scripts/helper. If anyone knows how to properly import it here
* then please fix it.
*
* @param {string} string
* @returns {string} A kebabized string
*/
export const toKebabCase = (string: string) =>
string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
/**
* Create a Lucide icon component
* @param {string} iconName
* @param {array} iconNode
* @returns {FunctionalComponent} LucideIcon
*/
const createLucideIcon =
(iconName: string, iconNode: IconNode): Icon =>
(