mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 14:24:42 +12:00
50 lines
926 B
TypeScript
50 lines
926 B
TypeScript
import { relative, resolve } from 'node:path';
|
|
import { defineConfig, type Options } from 'tsup';
|
|
|
|
type ConfigOptions = Pick<
|
|
Options,
|
|
| 'globalName'
|
|
| 'minify'
|
|
| 'entry'
|
|
| 'format'
|
|
| 'target'
|
|
| 'sourcemap'
|
|
| 'skipNodeModulesBundle'
|
|
| 'noExternal'
|
|
| 'esbuildOptions'
|
|
| 'dts'
|
|
>;
|
|
|
|
export const createTsupConfig = ({
|
|
globalName,
|
|
format = ['esm', 'cjs'],
|
|
dts = true,
|
|
target = 'es2021',
|
|
sourcemap = true,
|
|
minify = false,
|
|
entry = ['src/index.ts'],
|
|
skipNodeModulesBundle = true,
|
|
noExternal,
|
|
esbuildOptions = (options, context) => {
|
|
if (context.format === 'cjs') {
|
|
options.banner = {
|
|
js: '"use strict";',
|
|
};
|
|
}
|
|
},
|
|
}: ConfigOptions = {}) =>
|
|
defineConfig({
|
|
clean: true,
|
|
dts,
|
|
entry,
|
|
format,
|
|
minify,
|
|
skipNodeModulesBundle,
|
|
sourcemap,
|
|
target,
|
|
tsconfig: relative(__dirname, resolve(process.cwd(), 'tsconfig.json')),
|
|
keepNames: true,
|
|
globalName,
|
|
noExternal,
|
|
esbuildOptions,
|
|
});
|