(build): Switch to esbuild & transpile to commonjs.

This commit is contained in:
2026-06-13 00:58:17 +00:00
parent 38ddcde06c
commit 6f10dedc12
7 changed files with 404 additions and 280 deletions
+1 -4
View File
@@ -1,7 +1,6 @@
import path, { dirname } from 'path';
import path from 'path';
import { open, Database as SqliteDatabase } from 'sqlite';
import sqlite3 from 'sqlite3';
import { fileURLToPath } from 'url';
import { Message } from '../events';
import { AppealMessage, Ban, GithubUserMapping, GuildArraySetting, GuildSetting, GuildSettings, KnowledgebaseItem, LoggedMessage, Note, PrivateHelpTicket, RoleButton, TicketMessage, TicketPhrase } from '../types';
import { serializeMessage, wait } from '../utils';
@@ -33,7 +32,6 @@ export class Database {
}
private static async ensure() {
const __dirname = dirname(fileURLToPath(import.meta.url));
const schema = readFileSync(path.join(__dirname, '..', '..', 'sql', 'structure.sql'), { encoding: 'utf-8' });
await Database.db.exec(schema);
console.log('SQLite database ensured');
@@ -42,7 +40,6 @@ export class Database {
private static async migrate() {
console.log('Starting database migrations');
const __dirname = dirname(fileURLToPath(import.meta.url));
await Database.db.migrate({
migrationsPath: path.join(__dirname, '..', '..', 'sql', 'migrations')
});
+2 -3
View File
@@ -1,10 +1,9 @@
import { Client } from 'discord.js';
import fs from 'fs';
import path, { dirname } from 'path';
import { fileURLToPath, pathToFileURL } from 'url';
import path from 'path';
import { pathToFileURL } from 'url';
import { Handler } from '../types';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = path.resolve(__dirname, '..');
export async function loadHandlersFrom(dir: string, handlerArray: Handler[]): Promise<void> {
+2 -3
View File
@@ -1,11 +1,10 @@
import { Client, REST, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js';
import fs from 'fs';
import path, { dirname } from 'path';
import { fileURLToPath, pathToFileURL } from 'url';
import path from 'path';
import { pathToFileURL } from 'url';
import { config } from '../config';
import { Command } from '../types';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = path.resolve(__dirname, '..');
const rest = new REST({ version: '10' }).setToken(config.DISCORD_TOKEN!);
+1 -4
View File
@@ -5,8 +5,7 @@ import express, { Request, Response } from 'express';
import session from 'express-session';
import fs from 'fs';
import MemoryStore from 'memorystore';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import path from 'path';
import { config } from '../config';
import { Database } from '../shared/Database';
import { AltData, comprehensiveAltLookupFromE621, DiscordOAuth2 } from '../utils';
@@ -26,8 +25,6 @@ const DEV_BASE_URL = `http://localhost:${config.PORT}`;
const PROD_BASE_URL = 'https://discord.e621.net';
const OAUTH_SCOPES = ['identify', 'guilds.join'];
const __dirname = dirname(fileURLToPath(import.meta.url));
const PAGE_TEMPLATE = fs.readFileSync(path.join(__dirname, 'templates', 'page.html'), { encoding: 'utf-8' });
const oauth = new DiscordOAuth2({