mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
build: tsup for better cjs / esm support
This commit is contained in:
@@ -1,92 +0,0 @@
|
|||||||
import { relative, resolve } from 'node:path';
|
|
||||||
import glob from 'fast-glob';
|
|
||||||
import isCi from 'is-ci';
|
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
|
||||||
import { defineBuildConfig, type BuildEntry } from 'unbuild';
|
|
||||||
|
|
||||||
interface ConfigOptions {
|
|
||||||
cjsBridge: boolean;
|
|
||||||
declaration: boolean;
|
|
||||||
emitCJS: boolean;
|
|
||||||
entries: (BuildEntry | string)[];
|
|
||||||
externals: string[];
|
|
||||||
minify: boolean;
|
|
||||||
preserveModules: boolean;
|
|
||||||
preserveModulesRoot: string;
|
|
||||||
sourcemap: boolean;
|
|
||||||
typeCheck: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createUnbuildConfig({
|
|
||||||
entries = [{ builder: 'rollup', input: 'src/index' }],
|
|
||||||
minify = false,
|
|
||||||
emitCJS = true,
|
|
||||||
cjsBridge = true,
|
|
||||||
externals = [],
|
|
||||||
sourcemap = true,
|
|
||||||
preserveModules = true,
|
|
||||||
preserveModulesRoot = 'src',
|
|
||||||
declaration = true,
|
|
||||||
typeCheck = isCi,
|
|
||||||
}: Partial<ConfigOptions> = {}) {
|
|
||||||
const files = glob
|
|
||||||
.sync('**', { cwd: 'src' })
|
|
||||||
.flatMap((file) => [`${file.slice(0, -2)}cjs`, `${file.slice(0, -2)}mjs`]);
|
|
||||||
|
|
||||||
return defineBuildConfig({
|
|
||||||
entries,
|
|
||||||
clean: true,
|
|
||||||
rollup: {
|
|
||||||
esbuild: {
|
|
||||||
minify,
|
|
||||||
minifyIdentifiers: false,
|
|
||||||
},
|
|
||||||
emitCJS,
|
|
||||||
cjsBridge,
|
|
||||||
json: {
|
|
||||||
namedExports: false,
|
|
||||||
preferConst: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
externals: [...files, ...externals],
|
|
||||||
|
|
||||||
hooks: {
|
|
||||||
'rollup:options': (_, options) => {
|
|
||||||
// @ts-expect-error: This will always be an array
|
|
||||||
options.output![0] = {
|
|
||||||
// @ts-expect-error: This will always be an array
|
|
||||||
...options.output![0],
|
|
||||||
sourcemap,
|
|
||||||
preserveModules,
|
|
||||||
preserveModulesRoot,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (emitCJS) {
|
|
||||||
// @ts-expect-error: This will always be an array
|
|
||||||
options.output![1] = {
|
|
||||||
// @ts-expect-error: This will always be an array
|
|
||||||
...options.output![1],
|
|
||||||
sourcemap,
|
|
||||||
preserveModules,
|
|
||||||
preserveModulesRoot,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (declaration) {
|
|
||||||
options.plugins?.unshift(
|
|
||||||
typescript({
|
|
||||||
check: typeCheck,
|
|
||||||
tsconfig: relative(__dirname, resolve(process.cwd(), 'tsconfig.json')),
|
|
||||||
tsconfigOverride: {
|
|
||||||
compilerOptions: {
|
|
||||||
emitDeclarationOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -41,13 +41,12 @@
|
|||||||
"@commitlint/config-angular": "^17.1.0",
|
"@commitlint/config-angular": "^17.1.0",
|
||||||
"@favware/cliff-jumper": "^1.8.7",
|
"@favware/cliff-jumper": "^1.8.7",
|
||||||
"@favware/npm-deprecate": "^1.0.5",
|
"@favware/npm-deprecate": "^1.0.5",
|
||||||
"@types/is-ci": "^3.0.0",
|
|
||||||
"conventional-changelog-cli": "^2.2.2",
|
"conventional-changelog-cli": "^2.2.2",
|
||||||
"fast-glob": "^3.2.11",
|
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
"is-ci": "^3.0.1",
|
"is-ci": "^3.0.1",
|
||||||
"lint-staged": "^13.0.3",
|
"lint-staged": "^13.0.3",
|
||||||
"turbo": "^1.4.3",
|
"tsup": "^6.2.3",
|
||||||
|
"turbo": "^1.4.4",
|
||||||
"typescript": "^4.8.2"
|
"typescript": "^4.8.2"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig({
|
|
||||||
entries: [
|
|
||||||
{ builder: 'rollup', input: 'src/index' },
|
|
||||||
{ builder: 'rollup', input: 'src/formatTag/index' },
|
|
||||||
],
|
|
||||||
preserveModules: false,
|
|
||||||
minify: true,
|
|
||||||
emitCJS: false,
|
|
||||||
});
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format"
|
"fmt": "yarn format"
|
||||||
@@ -48,9 +48,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
7
packages/actions/tsup.config.js
Normal file
7
packages/actions/tsup.config.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig({
|
||||||
|
entry: ['src/index.ts', 'src/formatTag/index.ts'],
|
||||||
|
format: ['esm'],
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
@@ -4,12 +4,13 @@
|
|||||||
"description": "Utilities for api-extractor",
|
"description": "Utilities for api-extractor",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format"
|
"fmt": "yarn format"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.mjs",
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
@@ -38,9 +39,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2"
|
||||||
"unbuild": "^0.8.9"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
|
|||||||
5
packages/api-extractor-utils/tsup.config.js
Normal file
5
packages/api-extractor-utils/tsup.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig({
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig();
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "A set of builders that you can use when creating your bot",
|
"description": "A set of builders that you can use when creating your bot",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format",
|
"fmt": "yarn format",
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -70,9 +70,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
3
packages/builders/tsup.config.js
Normal file
3
packages/builders/tsup.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig();
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig();
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "Utility data structure used in discord.js",
|
"description": "Utility data structure used in discord.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format",
|
"fmt": "yarn format",
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -59,9 +59,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
3
packages/collection/tsup.config.js
Normal file
3
packages/collection/tsup.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig();
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig({
|
|
||||||
entries: [
|
|
||||||
{ builder: 'rollup', input: 'src/index' },
|
|
||||||
{ builder: 'rollup', input: 'src/cli' },
|
|
||||||
],
|
|
||||||
minify: true,
|
|
||||||
});
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.12.1",
|
"version": "0.12.1",
|
||||||
"description": "The docs.json generator for discord.js and its related projects",
|
"description": "The docs.json generator for discord.js and its related projects",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format",
|
"fmt": "yarn format",
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/docgen/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/docgen/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"bin": "./dist/cli.cjs",
|
"bin": "./dist/cli.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
},
|
},
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
"commander": "^9.4.0",
|
"commander": "^9.4.0",
|
||||||
"jsdoc-to-markdown": "^7.1.1",
|
"jsdoc-to-markdown": "^7.1.1",
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"typedoc": "^0.23.11"
|
"typedoc": "^0.23.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@favware/cliff-jumper": "^1.8.7",
|
"@favware/cliff-jumper": "^1.8.7",
|
||||||
@@ -54,9 +54,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2"
|
||||||
"unbuild": "^0.8.9"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
|
|||||||
7
packages/docgen/tsup.config.js
Normal file
7
packages/docgen/tsup.config.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig({
|
||||||
|
entry: ['src/index.ts', 'src/cli.ts'],
|
||||||
|
minify: true,
|
||||||
|
dts: false,
|
||||||
|
});
|
||||||
@@ -15,4 +15,4 @@ RUN yarn workspaces focus
|
|||||||
COPY ./packages/proxy-container ./
|
COPY ./packages/proxy-container ./
|
||||||
RUN yarn build && yarn workspaces focus --production
|
RUN yarn build && yarn workspaces focus --production
|
||||||
|
|
||||||
CMD ["node", "--enable-source-maps", "./dist/index.mjs"]
|
CMD ["node", "--enable-source-maps", "./dist/index.js"]
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig({ emitCJS: false, cjsBridge: false });
|
|
||||||
@@ -3,15 +3,15 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Lightweight HTTP proxy for Discord's API, brought to you as a container 📦",
|
"description": "Lightweight HTTP proxy for Discord's API, brought to you as a container 📦",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format",
|
"fmt": "yarn format",
|
||||||
"prepack": "yarn lint && yarn test && yarn build",
|
"prepack": "yarn lint && yarn test && yarn build",
|
||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy-container/*'"
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy-container/*'"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.mjs",
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"module": "./dist/index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
},
|
},
|
||||||
@@ -53,9 +53,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2"
|
||||||
"unbuild": "^0.8.9"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
|
|||||||
6
packages/proxy-container/tsup.config.js
Normal file
6
packages/proxy-container/tsup.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig({
|
||||||
|
format: ['esm'],
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig();
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "Tools for running an HTTP proxy for Discord's API",
|
"description": "Tools for running an HTTP proxy for Discord's API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format",
|
"fmt": "yarn format",
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -69,10 +69,9 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
|
||||||
"supertest": "^6.2.4",
|
"supertest": "^6.2.4",
|
||||||
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
3
packages/proxy/tsup.config.js
Normal file
3
packages/proxy/tsup.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig();
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig();
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "The REST API for discord.js",
|
"description": "The REST API for discord.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format",
|
"fmt": "yarn format",
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -70,9 +70,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
3
packages/rest/tsup.config.js
Normal file
3
packages/rest/tsup.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig();
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig({ minify: true });
|
|
||||||
@@ -4,17 +4,17 @@
|
|||||||
"description": "A set of scripts that we use for our workflows",
|
"description": "A set of scripts that we use for our workflows",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src --ext mjs,js,ts --fix",
|
||||||
"fmt": "yarn format"
|
"fmt": "yarn format"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -55,9 +55,8 @@
|
|||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
5
packages/scripts/tsup.config.js
Normal file
5
packages/scripts/tsup.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig({
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig();
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.12.0",
|
"version": "0.12.0",
|
||||||
"description": "Implementation of the Discord Voice API for node.js",
|
"description": "Implementation of the Discord Voice API for node.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"test": "jest --coverage",
|
"test": "jest --coverage",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
"@discordjs/docgen": "workspace:^",
|
"@discordjs/docgen": "workspace:^",
|
||||||
"@favware/cliff-jumper": "^1.8.7",
|
"@favware/cliff-jumper": "^1.8.7",
|
||||||
"@microsoft/api-extractor": "^7.29.5",
|
"@microsoft/api-extractor": "^7.29.5",
|
||||||
"@types/jest": "^28.1.8",
|
"@types/jest": "^29.0.0",
|
||||||
"@types/node": "^16.11.56",
|
"@types/node": "^16.11.56",
|
||||||
"downlevel-dts": "^0.10.1",
|
"downlevel-dts": "^0.10.1",
|
||||||
"eslint": "^8.23.0",
|
"eslint": "^8.23.0",
|
||||||
@@ -74,10 +74,9 @@
|
|||||||
"jest-websocket-mock": "^2.4.0",
|
"jest-websocket-mock": "^2.4.0",
|
||||||
"mock-socket": "^9.1.5",
|
"mock-socket": "^9.1.5",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"tweetnacl": "^1.0.3",
|
"tweetnacl": "^1.0.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2"
|
||||||
"unbuild": "^0.8.9"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
|
|||||||
3
packages/voice/tsup.config.js
Normal file
3
packages/voice/tsup.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig();
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
"homepage": "https://discord.js.org",
|
"homepage": "https://discord.js.org",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/api-extractor-utils": "workspace:^",
|
"@discordjs/api-extractor-utils": "workspace:^",
|
||||||
"@emotion/react": "^11.10.0",
|
"@emotion/react": "^11.10.4",
|
||||||
"@emotion/server": "^11.10.0",
|
"@emotion/server": "^11.10.0",
|
||||||
"@mantine/core": "^5.2.4",
|
"@mantine/core": "^5.2.4",
|
||||||
"@mantine/hooks": "^5.2.4",
|
"@mantine/hooks": "^5.2.4",
|
||||||
@@ -72,9 +72,9 @@
|
|||||||
"@types/node": "^16.11.56",
|
"@types/node": "^16.11.56",
|
||||||
"@types/react-dom": "^18.0.6",
|
"@types/react-dom": "^18.0.6",
|
||||||
"@types/react-syntax-highlighter": "^15.5.5",
|
"@types/react-syntax-highlighter": "^15.5.5",
|
||||||
"@unocss/cli": "^0.45.13",
|
"@unocss/cli": "^0.45.14",
|
||||||
"@unocss/preset-web-fonts": "^0.45.13",
|
"@unocss/preset-web-fonts": "^0.45.14",
|
||||||
"@unocss/reset": "^0.45.13",
|
"@unocss/reset": "^0.45.14",
|
||||||
"@vitejs/plugin-react": "^2.0.1",
|
"@vitejs/plugin-react": "^2.0.1",
|
||||||
"@vitest/coverage-c8": "^0.22.1",
|
"@vitest/coverage-c8": "^0.22.1",
|
||||||
"concurrently": "^7.3.0",
|
"concurrently": "^7.3.0",
|
||||||
@@ -83,8 +83,8 @@
|
|||||||
"happy-dom": "^6.0.4",
|
"happy-dom": "^6.0.4",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unocss": "^0.45.13",
|
"unocss": "^0.45.14",
|
||||||
"vercel": "^28.2.0",
|
"vercel": "^28.2.2",
|
||||||
"vitest": "^0.22.1"
|
"vitest": "^0.22.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ test('spawn, connect, send a message, session info, and destroy', async () => {
|
|||||||
|
|
||||||
await manager.connect();
|
await manager.connect();
|
||||||
expect(mockConstructor).toHaveBeenCalledWith(
|
expect(mockConstructor).toHaveBeenCalledWith(
|
||||||
expect.stringContaining('worker.cjs'),
|
expect.stringContaining('worker.js'),
|
||||||
expect.objectContaining({ workerData: expect.objectContaining({ shardIds: [0, 1] }) }),
|
expect.objectContaining({ workerData: expect.objectContaining({ shardIds: [0, 1] }) }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { createUnbuildConfig } from '../../build.config';
|
|
||||||
|
|
||||||
export default createUnbuildConfig({
|
|
||||||
entries: [
|
|
||||||
{ builder: 'rollup', input: 'src/index' },
|
|
||||||
{ builder: 'rollup', input: 'src/strategies/sharding/worker' },
|
|
||||||
],
|
|
||||||
externals: ['zlib-sync'],
|
|
||||||
});
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "Wrapper around Discord's gateway",
|
"description": "Wrapper around Discord's gateway",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"build": "unbuild",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"docs": "downlevel-dts dist docs/dist --to=3.7 && docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript && api-extractor run --local",
|
"docs": "downlevel-dts dist docs/dist --to=3.7 && docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript && api-extractor run --local",
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
|
||||||
"release": "cliff-jumper"
|
"release": "cliff-jumper"
|
||||||
},
|
},
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs",
|
"require": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -72,9 +72,8 @@
|
|||||||
"eslint-config-neon": "^0.1.23",
|
"eslint-config-neon": "^0.1.23",
|
||||||
"mock-socket": "^9.1.5",
|
"mock-socket": "^9.1.5",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"rollup-plugin-typescript2": "^0.33.0",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.8.2",
|
"typescript": "^4.8.2",
|
||||||
"unbuild": "^0.8.9",
|
|
||||||
"undici": "^5.10.0",
|
"undici": "^5.10.0",
|
||||||
"vitest": "^0.22.1",
|
"vitest": "^0.22.1",
|
||||||
"zlib-sync": "^0.1.7"
|
"zlib-sync": "^0.1.7"
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export class WorkerShardingStrategy implements IShardingStrategy {
|
|||||||
shardIds: slice,
|
shardIds: slice,
|
||||||
};
|
};
|
||||||
|
|
||||||
const worker = new Worker(join(__dirname, 'worker.cjs'), { workerData });
|
const worker = new Worker(join(__dirname, 'worker.js'), { workerData });
|
||||||
await once(worker, 'online');
|
await once(worker, 'online');
|
||||||
worker
|
worker
|
||||||
.on('error', (err) => {
|
.on('error', (err) => {
|
||||||
|
|||||||
9
packages/ws/tsup.config.js
Normal file
9
packages/ws/tsup.config.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { createTsupConfig } from '../../tsup.config.js';
|
||||||
|
|
||||||
|
export default createTsupConfig({
|
||||||
|
entry: {
|
||||||
|
index: 'src/index.ts',
|
||||||
|
worker: 'src/strategies/sharding/worker.ts',
|
||||||
|
},
|
||||||
|
external: ['zlib-sync'],
|
||||||
|
});
|
||||||
35
tsup.config.js
Normal file
35
tsup.config.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { defineConfig } from 'tsup';
|
||||||
|
|
||||||
|
export function createTsupConfig({
|
||||||
|
entry = ['src/index.ts'],
|
||||||
|
external = [],
|
||||||
|
noExternal = [],
|
||||||
|
platform = 'node',
|
||||||
|
format = ['esm', 'cjs'],
|
||||||
|
target = 'es2022',
|
||||||
|
skipNodeModulesBundle = true,
|
||||||
|
clean = true,
|
||||||
|
shims = true,
|
||||||
|
minify = false,
|
||||||
|
splitting = false,
|
||||||
|
keepNames = true,
|
||||||
|
dts = true,
|
||||||
|
sourcemap = true,
|
||||||
|
} = {}) {
|
||||||
|
return defineConfig({
|
||||||
|
entry,
|
||||||
|
external,
|
||||||
|
noExternal,
|
||||||
|
platform,
|
||||||
|
format,
|
||||||
|
skipNodeModulesBundle,
|
||||||
|
target,
|
||||||
|
clean,
|
||||||
|
shims,
|
||||||
|
minify,
|
||||||
|
splitting,
|
||||||
|
keepNames,
|
||||||
|
dts,
|
||||||
|
sourcemap,
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user