-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
d255c6a
commit ad1accb
Showing
33 changed files
with
11,265 additions
and
3,151 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,127 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import withSolid from 'rollup-preset-solid'; | ||
import bundleSize from '@atomico/rollup-plugin-sizes'; | ||
import license from 'rollup-plugin-license'; | ||
import path from 'path'; | ||
import { babel } from '@rollup/plugin-babel'; | ||
import esbuild from 'esbuild'; | ||
import plugins from '@lucide/rollup-plugins'; | ||
import ts from 'typescript'; | ||
|
||
import pkg from './package.json' assert { type: 'json' }; | ||
|
||
const config = withSolid({ | ||
targets: ['esm', 'cjs'], | ||
}); | ||
const packageName = 'LucideSolid'; | ||
const outputFileName = 'lucide-solid'; | ||
const outputDir = 'dist'; | ||
const inputs = ['src/lucide-solid.ts']; | ||
|
||
config.plugins = [ | ||
...config.plugins, | ||
license({ | ||
banner: `${pkg.name} v${pkg.version} - ${pkg.license}`, | ||
}), | ||
bundleSize(), | ||
const bundles = [ | ||
{ | ||
format: 'cjs', | ||
inputs, | ||
outputDir, | ||
}, | ||
{ | ||
format: 'esm', | ||
inputs, | ||
outputDir, | ||
}, | ||
]; | ||
|
||
export default config; | ||
const configs = bundles | ||
.map(({ inputs, outputDir, format, preserveModules }) => | ||
inputs.map((input) => ({ | ||
input, | ||
plugins: [ | ||
babel({ | ||
extensions: ['.ts', '.tsx', '.js'], | ||
babelHelpers: 'bundled', | ||
presets: [ | ||
'babel-preset-solid', | ||
'@babel/preset-typescript', | ||
['@babel/preset-env', { bugfixes: true, targets: 'last 2 years' }], | ||
], | ||
}), | ||
...plugins({ | ||
pkg, | ||
withEsbuild: false, | ||
}), | ||
format === 'esm' | ||
? { | ||
name: 'ts', | ||
buildEnd() { | ||
// Transpile typescript to './dist/source' | ||
esbuild.build({ | ||
entryPoints: ['./src/**/*.tsx', './src/**/*.ts'], | ||
outdir: './dist/source', | ||
loader: { | ||
'.js': 'jsx', | ||
}, | ||
jsx: 'preserve', | ||
bundle: true, | ||
format: 'esm', | ||
sourcemap: true, | ||
target: ['esnext'], | ||
banner: { | ||
js: `/** | ||
* @license ${pkg.name} v${pkg.version} - ${pkg.license} | ||
* | ||
* This source code is licensed under the ${pkg.license} license. | ||
* See the LICENSE file in the root directory of this source tree. | ||
*/`, | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'externalize-everything-except-own-dependencies', | ||
setup(build) { | ||
build.onResolve({ filter: /(.*)/ }, (args) => { | ||
const modulePath = path.join(args.resolveDir, args.path); | ||
if ( | ||
args.kind === 'import-statement' && | ||
args.path !== '@lucide/shared' && | ||
!modulePath.includes('packages/shared') | ||
) { | ||
return { path: args.path, external: true }; | ||
} | ||
}); | ||
}, | ||
}, | ||
], | ||
external: ['solid-js'], | ||
}); | ||
|
||
// Generate types | ||
const program = ts.createProgram([pkg.source], { | ||
target: ts.ScriptTarget.ESNext, | ||
module: ts.ModuleKind.ESNext, | ||
moduleResolution: ts.ModuleResolutionKind.NodeJs, | ||
jsx: ts.JsxEmit.Preserve, | ||
jsxImportSource: 'solid-js', | ||
allowSyntheticDefaultImports: true, | ||
esModuleInterop: true, | ||
declarationDir: `dist/types`, | ||
declaration: true, | ||
emitDeclarationOnly: true, | ||
}); | ||
program.emit(); | ||
}, | ||
} | ||
: null, | ||
], | ||
external: ['solid-js', 'solid-js/web', 'solid-js/store'], | ||
output: { | ||
name: packageName, | ||
...(preserveModules | ||
? { | ||
dir: `${outputDir}/${format}`, | ||
exports: 'auto', | ||
} | ||
: { | ||
file: `${outputDir}/${format}/${outputFileName}.js`, | ||
}), | ||
format: format === 'source' ? 'esm' : format, | ||
preserveModules, | ||
preserveModulesRoot: 'src', | ||
sourcemap: true, | ||
}, | ||
})), | ||
) | ||
.flat(); | ||
|
||
export default configs; |
Oops, something went wrong.