2023-07-30 10:37:25 -04:00
|
|
|
import typescript from 'rollup-plugin-typescript2';
|
|
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
|
|
|
|
import pkg from './package.json';
|
2023-12-11 14:48:40 -05:00
|
|
|
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
|
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
|
|
|
import replace from '@rollup/plugin-replace';
|
|
|
|
|
import terser from '@rollup/plugin-terser';
|
|
|
|
|
import generatePackageJson from 'rollup-plugin-generate-package-json';
|
|
|
|
|
|
|
|
|
|
const plugins = [
|
|
|
|
|
peerDepsExternal(),
|
|
|
|
|
resolve(),
|
|
|
|
|
replace({
|
|
|
|
|
__IS_DEV__: process.env.NODE_ENV === 'development',
|
|
|
|
|
}),
|
|
|
|
|
commonjs(),
|
|
|
|
|
typescript({
|
|
|
|
|
tsconfig: './tsconfig.json',
|
|
|
|
|
useTsconfigDeclarationDir: true,
|
|
|
|
|
}),
|
|
|
|
|
terser(),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const subfolderPlugins = (folderName) => [
|
|
|
|
|
...plugins,
|
|
|
|
|
generatePackageJson({
|
|
|
|
|
baseContents: {
|
|
|
|
|
name: `${pkg.name}/${folderName}`,
|
|
|
|
|
private: true,
|
|
|
|
|
main: '../index.js',
|
|
|
|
|
module: './index.es.js', // Adjust to match the output file
|
|
|
|
|
types: `../types/${folderName}/index.d.ts`, // Point to correct types file
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
];
|
2023-07-30 10:37:25 -04:00
|
|
|
|
|
|
|
|
export default [
|
|
|
|
|
{
|
|
|
|
|
input: 'src/index.ts',
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: pkg.main,
|
|
|
|
|
format: 'cjs',
|
2023-12-11 14:48:40 -05:00
|
|
|
sourcemap: true,
|
|
|
|
|
exports: 'named',
|
2023-07-30 10:37:25 -04:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
file: pkg.module,
|
|
|
|
|
format: 'esm',
|
2023-12-11 14:48:40 -05:00
|
|
|
sourcemap: true,
|
|
|
|
|
exports: 'named',
|
2023-07-30 10:37:25 -04:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
...{
|
|
|
|
|
external: [
|
|
|
|
|
...Object.keys(pkg.dependencies || {}),
|
|
|
|
|
...Object.keys(pkg.devDependencies || {}),
|
|
|
|
|
...Object.keys(pkg.peerDependencies || {}),
|
2023-12-11 14:48:40 -05:00
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
2023-07-30 10:37:25 -04:00
|
|
|
],
|
|
|
|
|
preserveSymlinks: true,
|
2023-12-11 14:48:40 -05:00
|
|
|
plugins,
|
2023-07-30 10:37:25 -04:00
|
|
|
},
|
|
|
|
|
},
|
2023-12-11 14:48:40 -05:00
|
|
|
// Separate bundle for react-query related part
|
|
|
|
|
{
|
|
|
|
|
input: 'src/react-query/index.ts',
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: 'dist/react-query/index.es.js',
|
|
|
|
|
format: 'esm',
|
|
|
|
|
exports: 'named',
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
external: [
|
|
|
|
|
...Object.keys(pkg.dependencies || {}),
|
|
|
|
|
...Object.keys(pkg.devDependencies || {}),
|
|
|
|
|
...Object.keys(pkg.peerDependencies || {}),
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
// 'librechat-data-provider', // Marking main part as external
|
|
|
|
|
],
|
|
|
|
|
preserveSymlinks: true,
|
|
|
|
|
plugins: subfolderPlugins('react-query'),
|
|
|
|
|
},
|
2023-07-30 10:37:25 -04:00
|
|
|
];
|