UNPKG

sandai-react

Version:

React components and utilities for the Sandai 3D AI Characters.

82 lines (78 loc) 2.56 kB
import babel from "@rollup/plugin-babel"; import resolve from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import terser from "@rollup/plugin-terser"; import typescript from "rollup-plugin-typescript2"; import dts from "rollup-plugin-dts"; import pkg from "./package.json" with { type: "json" }; // Peer deps (react, react-dom, typescript) are external for the JS bundle. const jsExternal = [...Object.keys(pkg.peerDependencies)]; // For the .d.ts bundle we additionally keep sibling monorepo packages external // so the declaration graph never climbs up into `packages/` (which produced the // old divergent dist/sandai-react, dist/sandai-core, dist/r3f-vrm, ... layout). // These are NOT added to the JS externals — sandai-core is a value dependency // and must stay bundled exactly as before. const dtsExternal = [ ...jsExternal, /^sandai-core(\/|$)/, /^ai-vrm-chat(\/|$)/, /^r3f-vrm(\/|$)/, /^pose-3d-bone-mapper(\/|$)/, /^ai-character(\/|$)/, /^piper-wasm(\/|$)/, ]; export default [ // 1. JS bundles. `dist` is wiped by the `rollup` npm script (rm -rf) before // this runs, so old nested declaration layouts can't accumulate. { input: "index.ts", output: [ { file: "dist/index.cjs.js", format: "cjs", sourcemap: true, }, { file: "dist/index.esm.js", format: "esm", sourcemap: true, }, ], plugins: [ resolve({ extensions: [".js", ".jsx", ".ts", ".tsx"], // Handle .tsx files }), commonjs(), typescript({ tsconfig: "./tsconfig.build.json", exclude: ["**/__tests__/**"], check: false, extensions: [".js", ".jsx", ".ts", ".tsx"], }), babel({ babelHelpers: "bundled", exclude: "", extensions: [".js", ".jsx", ".ts", ".tsx"], // Babel should handle these too presets: [ "@babel/preset-env", ["@babel/preset-react", { runtime: "automatic" }], "@babel/preset-typescript", // Add this preset ], }), terser(), ], external: jsExternal, }, // 2. Types. Bundles every declaration reachable from the real entry (index.ts) // into a single dist/index.d.ts — matching `"types"` in package.json, with // no rootDir-dependent folder nesting. { input: "index.ts", output: { file: "dist/index.d.ts", format: "es", }, plugins: [dts({ tsconfig: "./tsconfig.build.json" })], external: dtsExternal, }, ];