Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit 9eb6afb

Browse files
committed
chore: overhaul build system
1 parent d6ac7c3 commit 9eb6afb

26 files changed

+509
-171
lines changed

.husky/.gitignore

-1
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</p>
1313
</div>
1414

15-
## Status: pre-alpha
15+
## Status: alpha
1616

1717
## Contribution
1818

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = {
1212
'@babel/preset-typescript',
1313
],
1414
plugins: [
15+
['const-enum', { transform: 'constObject' }],
1516
'babel-plugin-transform-typescript-metadata',
1617
['@babel/plugin-proposal-decorators', { legacy: true }],
17-
['const-enum', { transform: 'constObject' }],
1818
],
1919
};

package.json

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
{
2-
"$schema": "http://json.schemastore.org/package",
32
"name": "discord.js",
43
"description": "A powerful library for interacting with the Discord API",
5-
"contributors": [
6-
"Amish Shah <[email protected]>",
7-
"Crawl <[email protected]>",
8-
"SpaceEEC <[email protected]>",
9-
"Vlad Frangu <[email protected]>"
10-
],
11-
"license": "Apache-2.0",
124
"private": true,
135
"scripts": {
146
"pretest": "yarn build",
15-
"test": "jest --collect-coverage",
16-
"test:ci": "yarn test --verbose --noStackTrace",
7+
"test": "jest --pass-with-no-tests",
8+
"test:ci": "jest --no-stack-trace --verbose --pass-with-no-tests",
179
"prebuild": "yarn clean",
18-
"build": "tsc --build packages/core packages/rest packages/ws --force",
10+
"build": "yarn workspaces run build",
1911
"clean": "rimraf packages/**/dist packages/**/*.tsbuildinfo",
2012
"lint": "eslint packages --ext mjs,js,ts",
2113
"lint:fix": "eslint packages --ext mjs,js,ts --fix",
2214
"format": "prettier --write **/*.{ts,js,json,yml,yaml}",
2315
"update": "yarn upgrade-interactive --latest",
2416
"prepare": "husky install",
25-
"lerna": "env-cmd lerna"
17+
"lerna": "env-cmd lerna",
18+
"canary-release": "env-cmd lerna publish --conventional-prerelease --pre-dist-tag canary --preid \"canary\"",
19+
"graduate-release": "env-cmd lerna publish --conventional-graduate",
20+
"release": "env-cmd lerna publish"
2621
},
27-
"repository": {
28-
"type": "git",
29-
"url": "git+https://github.com/discordjs/discord.js-modules.git"
30-
},
31-
"bugs": {
32-
"url": "https://github.com/discordjs/discord.js-modules/issues"
33-
},
34-
"homepage": "https://github.com/discordjs/discord.js-modules",
22+
"contributors": [
23+
"Crawl <[email protected]>",
24+
"Amish Shah <[email protected]>",
25+
"SpaceEEC <[email protected]>",
26+
"Vlad Frangu <[email protected]>"
27+
],
28+
"license": "Apache-2.0",
3529
"keywords": [
3630
"discord",
3731
"api",
@@ -40,6 +34,14 @@
4034
"node",
4135
"discordapp"
4236
],
37+
"repository": {
38+
"type": "git",
39+
"url": "git+https://github.com/discordjs/discord.js-modules.git"
40+
},
41+
"bugs": {
42+
"url": "https://github.com/discordjs/discord.js-modules/issues"
43+
},
44+
"homepage": "https://github.com/discordjs/discord.js-modules",
4345
"devDependencies": {
4446
"@babel/core": "^7.15.8",
4547
"@babel/plugin-proposal-decorators": "^7.15.8",
@@ -50,7 +52,6 @@
5052
"@types/jest": "^27.0.2",
5153
"@typescript-eslint/eslint-plugin": "^4.28.0",
5254
"@typescript-eslint/parser": "^4.28.0",
53-
"babel-jest": "^27.3.0",
5455
"babel-plugin-const-enum": "^1.1.0",
5556
"babel-plugin-transform-typescript-metadata": "^0.3.2",
5657
"conventional-changelog-cli": "^2.1.1",
@@ -67,6 +68,7 @@
6768
"nock": "^13.1.3",
6869
"prettier": "^2.4.1",
6970
"rimraf": "^3.0.2",
71+
"tsup": "^5.5.0",
7072
"typescript": "^4.4.4"
7173
},
7274
"engines": {

packages/core/package.json

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
{
2-
"$schema": "http://json.schemastore.org/package",
32
"name": "@discordjs/core",
43
"version": "0.1.1-canary.0",
5-
"description": "The core for Discord.js",
4+
"description": "The core for discord.js",
5+
"private": true,
6+
"scripts": {
7+
"test": "echo \"Error: run tests from root\" && exit 1",
8+
"build": "tsup && tsc --emitDeclarationOnly"
9+
},
10+
"main": "./dist/index.js",
11+
"module": "./dist/index.mjs",
12+
"typings": "./dist/index.d.ts",
13+
"exports": {
14+
"import": "./dist/index.mjs",
15+
"require": "./dist/index.js"
16+
},
17+
"directories": {
18+
"lib": "src",
19+
"test": "__tests__"
20+
},
21+
"files": [
22+
"dist"
23+
],
624
"contributors": [
7-
"Amish Shah <[email protected]>",
825
"Crawl <[email protected]>",
26+
"Amish Shah <[email protected]>",
927
"SpaceEEC <[email protected]>",
1028
"Vlad Frangu <[email protected]>"
1129
],
1230
"license": "Apache-2.0",
13-
"scripts": {
14-
"test": "echo \"Error: run tests from root\" && exit 1",
15-
"build": "tsc --build --force"
16-
},
31+
"keywords": [
32+
"discord",
33+
"api",
34+
"core",
35+
"discordapp"
36+
],
1737
"repository": {
1838
"type": "git",
1939
"url": "git+https://github.com/discordjs/discord.js-modules.git"
@@ -22,27 +42,12 @@
2242
"url": "https://github.com/discordjs/discord.js-modules/issues"
2343
},
2444
"homepage": "https://github.com/discordjs/discord.js-modules/tree/main/packages/core",
25-
"keywords": [
26-
"discord",
27-
"api",
28-
"core",
29-
"discordapp"
30-
],
31-
"main": "dist/index.js",
32-
"directories": {
33-
"lib": "src",
34-
"test": "__tests__"
35-
},
36-
"files": [
37-
"dist"
38-
],
3945
"dependencies": {
4046
"tslib": "^2.3.1"
4147
},
4248
"engines": {
4349
"node": ">=16.0.0"
4450
},
45-
"private": true,
4651
"publishConfig": {
4752
"access": "public"
4853
}

packages/core/tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"extends": "../tsconfig.base.json",
2+
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"sourceRoot": "./",
55
"rootDir": "./src",
66
"outDir": "dist"
77
},
8-
"include": ["src"]
8+
"include": ["src/**/*.ts"]
99
}

packages/core/tsup.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../../tsup.config';

packages/rest/package.json

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
11
{
2-
"$schema": "http://json.schemastore.org/package",
32
"name": "@discordjs/rest",
43
"version": "0.1.1-canary.0",
5-
"description": "The REST API for Discord.js",
4+
"description": "The REST API for discord.js",
5+
"scripts": {
6+
"test": "echo \"Error: run tests from root\" && exit 1",
7+
"build": "tsup && tsc --emitDeclarationOnly"
8+
},
9+
"main": "./dist/index.js",
10+
"module": "./dist/index.mjs",
11+
"typings": "./dist/index.d.ts",
12+
"exports": {
13+
"import": "./dist/index.mjs",
14+
"require": "./dist/index.js"
15+
},
16+
"directories": {
17+
"lib": "src",
18+
"test": "__tests__"
19+
},
20+
"files": [
21+
"dist"
22+
],
623
"contributors": [
7-
"Amish Shah <[email protected]>",
824
"Crawl <[email protected]>",
25+
"Amish Shah <[email protected]>",
926
"SpaceEEC <[email protected]>",
1027
"Vlad Frangu <[email protected]>",
1128
"Antonio Roman <[email protected]>"
1229
],
1330
"license": "Apache-2.0",
14-
"scripts": {
15-
"test": "echo \"Error: run tests from root\" && exit 1",
16-
"build": "tsc --build --force"
17-
},
18-
"repository": {
19-
"type": "git",
20-
"url": "git+https://github.com/discordjs/discord.js-modules.git"
21-
},
22-
"bugs": {
23-
"url": "https://github.com/discordjs/discord.js-modules/issues"
24-
},
25-
"homepage": "https://github.com/discordjs/discord.js-modules/tree/main/packages/rest",
2631
"keywords": [
2732
"discord",
2833
"api",
2934
"rest",
3035
"discordapp",
3136
"discordjs"
3237
],
33-
"main": "dist/index.js",
34-
"directories": {
35-
"lib": "src",
36-
"test": "__tests__"
38+
"repository": {
39+
"type": "git",
40+
"url": "git+https://github.com/discordjs/discord.js-modules.git"
3741
},
38-
"files": [
39-
"dist"
40-
],
42+
"bugs": {
43+
"url": "https://github.com/discordjs/discord.js-modules/issues"
44+
},
45+
"homepage": "https://github.com/discordjs/discord.js-modules/tree/main/packages/rest",
4146
"dependencies": {
4247
"@discordjs/collection": "^0.2.1",
4348
"@sapphire/async-queue": "^1.1.7",

packages/rest/src/lib/CDN.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ImageURLOptions {
1515
}
1616

1717
export interface MakeURLOptions {
18-
extension?: string;
18+
extension?: string | undefined;
1919
size?: ImageSize;
2020
allowedExtensions?: readonly string[];
2121
}

packages/rest/src/lib/RequestManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface RequestData {
2626
/**
2727
* Files to be attached to this request
2828
*/
29-
attachments?: RawAttachment[];
29+
attachments?: RawAttachment[] | undefined;
3030
/**
3131
* If this request needs the `Authorization` header
3232
* @default true

packages/rest/src/lib/errors/DiscordAPIError.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class DiscordAPIError extends Error {
6161
/**
6262
* The name of the error
6363
*/
64-
public get name(): string {
64+
public override get name(): string {
6565
return `${DiscordAPIError.name}[${this.code}]`;
6666
}
6767

packages/rest/src/lib/errors/HTTPError.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class HTTPError extends Error {
1717
*/
1818
public constructor(
1919
message: string,
20-
public name: string,
20+
public override name: string,
2121
public status: number,
2222
public method: string,
2323
public url: string,

packages/rest/src/lib/handlers/SequentialHandler.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ export class SequentialHandler {
140140
let res: Response;
141141

142142
try {
143-
res = await fetch(url, { ...options, signal: controller.signal });
143+
// node-fetch typings are a bit weird, so we have to cast to any to get the correct signature
144+
// Type 'AbortSignal' is not assignable to type 'import("discord.js-modules/node_modules/@types/node-fetch/externals").AbortSignal'
145+
res = await fetch(url, { ...options, signal: controller.signal as any });
144146
} catch (error: unknown) {
145147
// Retry the specified number of times for possible timed out requests
146148
if (error instanceof Error && error.name === 'AbortError' && retries !== this.manager.options.retries) {

packages/rest/src/tsconfig.json

-11
This file was deleted.

packages/rest/tsconfig.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
2-
"extends": "../tsconfig.base.json",
2+
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"sourceRoot": "./",
55
"rootDir": "./src",
6-
"outDir": "dist",
7-
"lib": ["ESNext"]
6+
"outDir": "dist"
87
},
9-
"include": ["src"],
8+
"include": ["src/**/*.ts"],
109
"references": [{ "path": "../core" }]
1110
}

packages/rest/tsup.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../../tsup.config';

packages/tsconfig.base.json

-12
This file was deleted.

packages/tsconfig.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"composite": true
5+
}
6+
}

0 commit comments

Comments
 (0)