| 1 | import { readFileSync } from "node:fs"; |
| 2 | import { join } from "node:path"; |
| 3 | import { cwd } from "node:process"; |
| 4 | import typescript from "@rollup/plugin-typescript"; |
| 5 | import { defineConfig } from "rolldown"; |
| 6 | |
| 7 | const pkg = JSON.parse(readFileSync(join(cwd(), "package.json"), "utf8")); |
| 8 | |
| 9 | export default defineConfig({ |
| 10 | input: "guest-js/index.ts", |
| 11 | output: [ |
| 12 | { |
| 13 | file: pkg.exports.import, |
| 14 | format: "esm", |
| 15 | }, |
| 16 | { |
| 17 | file: pkg.exports.require, |
| 18 | format: "cjs", |
| 19 | }, |
| 20 | ], |
| 21 | plugins: [ |
| 22 | typescript({ |
| 23 | declaration: true, |
| 24 | declarationDir: `./${pkg.exports.import.split("/")[0]}`, |
| 25 | }), |
| 26 | ], |
| 27 | external: [ |
| 28 | /^@tauri-apps\/api/, |
| 29 | ...Object.keys(pkg.dependencies || {}), |
| 30 | ...Object.keys(pkg.peerDependencies || {}), |
| 31 | ], |
| 32 | }); |