const { resolve } = require("path"); const { readdirSync } = require("fs"); const typescript = require("@rollup/plugin-typescript"); /** * @type {import('rollup').RollupOptions} */ const config = { external: ["jl-graphic"], input: getEntryPoints(), output: { dir: "components", format: "esm", preserveModules: true, }, plugins: [ typescript({ tsconfig: "./tsconfig.json", compilerOptions: { declaration: true, declarationDir: "components", }, }), ], }; module.exports = config; function getEntryPoints() { const packageDir = resolve(__dirname, "src/packages"); const entryPoints = readdirSync(packageDir, { withFileTypes: true }) .filter((dirent) => dirent.isDirectory()) .map((dirent) => resolve(packageDir, dirent.name, `${dirent.name}.ts`)); console.log(entryPoints); return entryPoints; }