diff --git a/dist/components/button/index.js b/dist/components/button/index.js
index cca0df0..2b39865 100644
--- a/dist/components/button/index.js
+++ b/dist/components/button/index.js
@@ -1,2 +1,2 @@
-import t from"react";var e=function(){return t.createElement("div",null,"Button")};export{e as default};
+import{cn as t}from"../../lib/utils.js";import e from"react";var r=function(){return e.createElement("div",{className:t("bg-blue-500","text-white")},"Button")};export{r as default};
//# sourceMappingURL=index.js.map
diff --git a/dist/components/button/index.js.map b/dist/components/button/index.js.map
index a9701bd..a43696f 100644
--- a/dist/components/button/index.js.map
+++ b/dist/components/button/index.js.map
@@ -1 +1 @@
-{"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import React from 'react'\r\n\r\nconst Button = () => {\r\n return (\r\n
Button
\r\n )\r\n}\r\n\r\nexport default Button"],"names":["Button","React","createElement"],"mappings":"qBAEA,IAAMA,EAAS,WACb,OACEC,EAAiBC,cAAA,MAAA,KAAA,SAErB"}
\ No newline at end of file
+{"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import { cn } from '@/lib/utils'\r\nimport React from 'react'\r\n\r\n\r\nconst Button = () => {\r\n return (\r\n \r\n Button\r\n
\r\n )\r\n}\r\n\r\nexport default Button"],"names":["Button","React","createElement","className","cn"],"mappings":"6DAIA,IAAMA,EAAS,WACb,OACEC,EAAAC,cAAA,MAAA,CAAKC,UAAWC,EACd,cACA,eAGI,SAEV"}
\ No newline at end of file
diff --git a/dist/index.d.ts b/dist/index.d.ts
index 8d942ea..cc0fe51 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -1,3 +1,3 @@
-export * from './components/button';
-export * from './components/input';
+export { default as Button } from './components/button';
+export { default as Input } from './components/input';
export * from './lib/utils';
diff --git a/dist/index.js b/dist/index.js
new file mode 100644
index 0000000..8010c1f
--- /dev/null
+++ b/dist/index.js
@@ -0,0 +1,2 @@
+export{default as Button}from"./components/button/index.js";export{default as Input}from"./components/input/index.js";export{cn}from"./lib/utils.js";
+//# sourceMappingURL=index.js.map
diff --git a/dist/index.js.map b/dist/index.js.map
new file mode 100644
index 0000000..c8e9b4f
--- /dev/null
+++ b/dist/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/utils.js b/dist/lib/utils.js
new file mode 100644
index 0000000..dc828c0
--- /dev/null
+++ b/dist/lib/utils.js
@@ -0,0 +1,2 @@
+import r from"@babel/runtime/helpers/toConsumableArray";import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/typeof";import{twMerge as n}from"tailwind-merge";function o(){for(var o=arguments.length,i=new Array(o),l=0;l input)\r\n .flatMap((input) =>\r\n typeof input === 'object'\r\n ? Object.entries(input).filter(([, value]) => value).map(([key]) => key)\r\n : input.split(' ')\r\n )\r\n\r\n return twMerge(...classes)\r\n}\r\n"],"names":["cn","_len","arguments","length","inputs","Array","_key","classes","filter","input","flatMap","_typeof","Object","entries","_ref","_slicedToArray","map","_ref3","split","twMerge","apply","_toConsumableArray"],"mappings":"kMAEgB,SAAAA,IAAa,IAAA,IAAAC,EAAAC,UAAAC,OAANC,EAAMC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAANF,EAAME,GAAAJ,UAAAI,GAC3B,IAAMC,EAAUH,EACbI,QAAO,SAACC,GAAK,OAAKA,CAAK,IACvBC,SAAQ,SAACD,GAAK,MACI,WAAjBE,EAAOF,GACHG,OAAOC,QAAQJ,GAAOD,QAAO,SAAAM,GAAS,OAATC,EAAAD,EAAA,GAAS,EAAW,IAAEE,KAAI,SAAAC,GAAK,OAALF,EAAAE,EAAA,GAAK,EAAS,IACrER,EAAMS,MAAM,QAGpB,OAAOC,EAAOC,aAAAC,EAAId,GACpB"}
\ No newline at end of file
diff --git a/generateRollupConfig.cjs b/generateRollupConfig.cjs
deleted file mode 100644
index a2c221a..0000000
--- a/generateRollupConfig.cjs
+++ /dev/null
@@ -1,64 +0,0 @@
-const requireContext = require('require-context')
-const fs = require('fs')
-// const path = require('path')
-
-const requireComponent = requireContext(
- './../../src', true, /\.(js|ts)x?$/, 'lazy'
-)
-
-const dependencias = {
- Example: '',
- VCalendar: "'react-big-calendar', 'moment'"
-}
-
-const makeConfig = () => {
- let config = ''
- requireComponent.keys().forEach(fileName => {
- // Ajusta la ruta para que coincida con tus rutas y extensiones de archivo
- const folderName = fileName.replace(/components[\\/]/, '').replace(/index\.(jsx|tsx)$/, '')
- if (folderName != null && folderName && !folderName.includes('index.')) {
- const defaultItem = `
- {
- input: 'src/components/${folderName}/index.${fileName.endsWith('.tsx') ? 'tsx' : 'jsx'}',
- output: {
- dir: 'dist/${folderName}',
- format: 'es'
- },
- external: [/@babel\\/runtime/, 'react', 'prop-types'${dependencias[folderName] != null ? (', ' + dependencias[folderName]) : ''}],
- plugins: [
- typescript(),
- babel({
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
- babelHelpers: 'runtime',
- plugins: ['@babel/plugin-transform-runtime']
- }),
- postcss({ plugins: [autoprefixer()], sourceMap: true, extract: true, minimize: true }),
- tailwind({ input: './styles/globals.css', purge: false })
- ]
- },`
- config = `${config} ${defaultItem}`
- }
- })
- return config
-}
-
-const content = `// File generated by npm run generateRollupFile
-import typescript from '@rollup/plugin-typescript';
-import babel from '@rollup/plugin-babel';
-import postcss from 'rollup-plugin-postcss';
-import tailwind from 'rollup-plugin-tailwindcss';
-import autoprefixer from 'autoprefixer';
-
-const config = [${makeConfig()}
-];
-
-export default config;
-`
-
-fs.writeFile('rollup.config.js', content, err => {
- if (err) {
- console.error(err)
- return
- }
- console.log('file written successfully')
-})
diff --git a/package.json b/package.json
index c305ebe..7dab5d0 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,11 @@
{
"name": "library-template",
- "version": "1.0.1",
+ "version": "1.0.2",
"type": "module",
"exports": {
- "./*": "./dist/components/*/index.js"
+ ".": "./dist/index.js",
+ "./button": "./dist/components/button/index.js",
+ "./input": "./dist/components/input/index.js"
},
"types": "dist/index.d.ts",
"files": [
diff --git a/rollup.config.js b/rollup.config.js
index 9ce242a..9fa32c4 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -9,44 +9,36 @@ import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
-// Recursively get .tsx files from a directory
-const getComponents = (dir) =>
- fs.readdirSync(dir).reduce((files, file) => {
- const name = path.join(dir, file)
- const isDirectory = fs.statSync(name).isDirectory()
- const isIndexFile = path.basename(name).includes('index')
- if (isDirectory) {
- return files.concat(getComponents(name))
- } else if (isIndexFile && name.endsWith('.tsx')) {
- return files.concat(name)
- } else {
- return files
- }
- }, [])
+const pkgPath = path.resolve('package.json')
+const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
-// Generate Rollup configuration for each component
-const componentsDir = 'src/components'
-const componentFiles = getComponents(componentsDir)
+const external = [
+ ...Object.keys(pkg.dependencies || {}),
+ ...Object.keys(pkg.peerDependencies || {}),
+ /@babel\/runtime/
+]
-const rollupConfig = componentFiles.map((inputFile) => ({
- input: inputFile,
- output: [
- {
- dir: 'dist',
- format: 'es',
- sourcemap: true,
- preserveModules: true,
- preserveModulesRoot: 'src'
- }
- ],
- external: [/@babel\/runtime/, 'react', 'prop-types'],
+export default {
+ input: 'src/index.ts',
+ output: {
+ dir: 'dist',
+ format: 'esm',
+ sourcemap: true,
+ preserveModules: true,
+ preserveModulesRoot: 'src'
+ },
+ external,
plugins: [
resolve(),
commonjs(),
- typescript(),
+ typescript({
+ declaration: true,
+ noEmitOnError: true
+ }),
babel({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
babelHelpers: 'runtime',
+ include: ['src/**/*'],
plugins: ['@babel/plugin-transform-runtime']
}),
postcss({
@@ -56,11 +48,8 @@ const rollupConfig = componentFiles.map((inputFile) => ({
minimize: true
}),
tailwind({
- input: './styles/globals.css',
- purge: false
+ input: './styles/globals.css'
}),
terser()
]
-}))
-
-export default rollupConfig
+}
diff --git a/src/components/button/index.tsx b/src/components/button/index.tsx
index bb79ee4..276697e 100644
--- a/src/components/button/index.tsx
+++ b/src/components/button/index.tsx
@@ -1,8 +1,15 @@
+import { cn } from '@/lib/utils'
import React from 'react'
+
const Button = () => {
return (
- Button
+
+ Button
+
)
}
diff --git a/src/index.ts b/src/index.ts
index 8d942ea..cc0fe51 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,3 +1,3 @@
-export * from './components/button';
-export * from './components/input';
+export { default as Button } from './components/button';
+export { default as Input } from './components/input';
export * from './lib/utils';
diff --git a/tsconfig.json b/tsconfig.json
index 9829e3b..76f29b7 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -7,8 +7,8 @@
"moduleResolution": "node",
"esModuleInterop": true,
"noUnusedLocals": true,
- "outDir": "./dist",
"declaration": true,
+ "declarationDir": "./dist",
"target": "esnext",
"module": "esnext",
"jsx": "react",