tabby/clients/tabby-agent/tsup.config.ts

84 lines
1.8 KiB
TypeScript
Raw Normal View History

import { defineConfig } from "tsup";
import { polyfillNode } from "esbuild-plugin-polyfill-node";
2023-05-29 02:09:44 +00:00
import { dependencies } from "./package.json";
const defineEnvs = (targetOptions, envs: { browser: boolean }) => {
targetOptions["define"] = {
...targetOptions["define"],
"process.env.IS_TEST": "false",
"process.env.IS_BROWSER": Boolean(envs?.browser).toString(),
};
return targetOptions;
};
2023-05-29 02:09:44 +00:00
export default async () => [
defineConfig({
2023-06-06 14:25:31 +00:00
name: "node-cjs",
entry: ["src/index.ts"],
platform: "node",
format: ["cjs"],
sourcemap: true,
esbuildOptions(options) {
defineEnvs(options, { browser: false });
},
clean: true,
}),
defineConfig({
2023-06-06 14:25:31 +00:00
name: "browser-iife",
entry: ["src/index.ts"],
platform: "browser",
format: ["iife"],
globalName: "Tabby",
treeshake: "smallest",
2023-06-06 14:25:31 +00:00
minify: true,
sourcemap: true,
2023-06-06 14:25:31 +00:00
esbuildPlugins: [
polyfillNode({
polyfills: { fs: true },
}),
],
esbuildOptions(options) {
defineEnvs(options, { browser: true });
},
clean: true,
}),
defineConfig({
2023-06-06 14:25:31 +00:00
name: "browser-esm",
entry: ["src/index.ts"],
platform: "browser",
format: ["esm"],
treeshake: true,
2023-06-06 14:25:31 +00:00
sourcemap: true,
esbuildPlugins: [
polyfillNode({
polyfills: { fs: true },
}),
],
esbuildOptions(options) {
defineEnvs(options, { browser: true });
},
2023-06-06 14:25:31 +00:00
clean: true,
}),
defineConfig({
name: "type-defs",
entry: ["src/index.ts"],
dts: {
only: true,
},
clean: true,
}),
defineConfig({
name: "cli",
entry: ["src/cli.ts"],
platform: "node",
2023-05-29 02:09:44 +00:00
noExternal: Object.keys(dependencies),
treeshake: "smallest",
minify: true,
2023-06-06 14:25:31 +00:00
sourcemap: true,
esbuildOptions(options) {
defineEnvs(options, { browser: false });
},
clean: true,
}),
];