v1.0.2
This commit is contained in:
parent
2a26a5c9b7
commit
d2b169c6f8
2
dist/components/button/index.js
vendored
2
dist/components/button/index.js
vendored
@ -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
|
//# sourceMappingURL=index.js.map
|
||||||
|
2
dist/components/button/index.js.map
vendored
2
dist/components/button/index.js.map
vendored
@ -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 <div>Button</div>\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"}
|
{"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 <div className={cn(\r\n 'bg-blue-500',\r\n 'text-white'\r\n )}>\r\n Button\r\n </div>\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"}
|
4
dist/index.d.ts
vendored
4
dist/index.d.ts
vendored
@ -1,3 +1,3 @@
|
|||||||
export * from './components/button';
|
export { default as Button } from './components/button';
|
||||||
export * from './components/input';
|
export { default as Input } from './components/input';
|
||||||
export * from './lib/utils';
|
export * from './lib/utils';
|
||||||
|
2
dist/index.js
vendored
Normal file
2
dist/index.js
vendored
Normal file
@ -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
|
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
2
dist/lib/utils.js
vendored
Normal file
2
dist/lib/utils.js
vendored
Normal file
@ -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<o;l++)i[l]=arguments[l];var a=i.filter((function(r){return r})).flatMap((function(r){return"object"===t(r)?Object.entries(r).filter((function(r){return e(r,2)[1]})).map((function(r){return e(r,1)[0]})):r.split(" ")}));return n.apply(void 0,r(a))}export{o as cn};
|
||||||
|
//# sourceMappingURL=utils.js.map
|
1
dist/lib/utils.js.map
vendored
Normal file
1
dist/lib/utils.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"utils.js","sources":["../../src/lib/utils.ts"],"sourcesContent":["import { twMerge } from 'tailwind-merge'\r\n\r\nexport function cn (...inputs) {\r\n const classes = inputs\r\n .filter((input) => 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"}
|
@ -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')
|
|
||||||
})
|
|
@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "library-template",
|
"name": "library-template",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"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",
|
"types": "dist/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -9,44 +9,36 @@ import resolve from '@rollup/plugin-node-resolve'
|
|||||||
import commonjs from '@rollup/plugin-commonjs'
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
import { terser } from 'rollup-plugin-terser'
|
import { terser } from 'rollup-plugin-terser'
|
||||||
|
|
||||||
// Recursively get .tsx files from a directory
|
const pkgPath = path.resolve('package.json')
|
||||||
const getComponents = (dir) =>
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
||||||
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
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
// Generate Rollup configuration for each component
|
const external = [
|
||||||
const componentsDir = 'src/components'
|
...Object.keys(pkg.dependencies || {}),
|
||||||
const componentFiles = getComponents(componentsDir)
|
...Object.keys(pkg.peerDependencies || {}),
|
||||||
|
/@babel\/runtime/
|
||||||
|
]
|
||||||
|
|
||||||
const rollupConfig = componentFiles.map((inputFile) => ({
|
export default {
|
||||||
input: inputFile,
|
input: 'src/index.ts',
|
||||||
output: [
|
output: {
|
||||||
{
|
dir: 'dist',
|
||||||
dir: 'dist',
|
format: 'esm',
|
||||||
format: 'es',
|
sourcemap: true,
|
||||||
sourcemap: true,
|
preserveModules: true,
|
||||||
preserveModules: true,
|
preserveModulesRoot: 'src'
|
||||||
preserveModulesRoot: 'src'
|
},
|
||||||
}
|
external,
|
||||||
],
|
|
||||||
external: [/@babel\/runtime/, 'react', 'prop-types'],
|
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve(),
|
resolve(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
typescript(),
|
typescript({
|
||||||
|
declaration: true,
|
||||||
|
noEmitOnError: true
|
||||||
|
}),
|
||||||
babel({
|
babel({
|
||||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
babelHelpers: 'runtime',
|
babelHelpers: 'runtime',
|
||||||
|
include: ['src/**/*'],
|
||||||
plugins: ['@babel/plugin-transform-runtime']
|
plugins: ['@babel/plugin-transform-runtime']
|
||||||
}),
|
}),
|
||||||
postcss({
|
postcss({
|
||||||
@ -56,11 +48,8 @@ const rollupConfig = componentFiles.map((inputFile) => ({
|
|||||||
minimize: true
|
minimize: true
|
||||||
}),
|
}),
|
||||||
tailwind({
|
tailwind({
|
||||||
input: './styles/globals.css',
|
input: './styles/globals.css'
|
||||||
purge: false
|
|
||||||
}),
|
}),
|
||||||
terser()
|
terser()
|
||||||
]
|
]
|
||||||
}))
|
}
|
||||||
|
|
||||||
export default rollupConfig
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
|
import { cn } from '@/lib/utils'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
|
|
||||||
const Button = () => {
|
const Button = () => {
|
||||||
return (
|
return (
|
||||||
<div>Button</div>
|
<div className={cn(
|
||||||
|
'bg-blue-500',
|
||||||
|
'text-white'
|
||||||
|
)}>
|
||||||
|
Button
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export * from './components/button';
|
export { default as Button } from './components/button';
|
||||||
export * from './components/input';
|
export { default as Input } from './components/input';
|
||||||
export * from './lib/utils';
|
export * from './lib/utils';
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"outDir": "./dist",
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
"declarationDir": "./dist",
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
|
Loading…
Reference in New Issue
Block a user