feat!: switch to esm

This commit is contained in:
EvolutionX
2022-08-23 07:39:57 +05:30
parent a6e96466c4
commit b994c79fc9
18 changed files with 54 additions and 39 deletions

View File

@@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "dist/src/index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "tsup && node .",
@@ -15,7 +16,7 @@
],
"license": "MIT",
"dependencies": {
"@sern/handler": "^1.1.9-beta",
"@sern/handler": "1.0.1",
"discord.js": "^14.2.0",
"dotenv": "^16.0.1",
"jsdoc-parse-plus": "^1.3.0",

View File

@@ -1,6 +1,6 @@
import type { Message, User } from "discord.js";
import { findBestMatch } from "string-similarity";
import type { TagData } from "./types";
import type { TagData } from "./types/index.js";
export class FuzzyMatcher {
public constructor(

View File

@@ -1,10 +1,9 @@
import { commandModule, CommandType } from '@sern/handler';
import { ApplicationCommandOptionType, ButtonBuilder, ButtonStyle, Colors, ComponentType, EmbedBuilder } from 'discord.js';
import { Paginate } from '../pagination';
import { publish } from '../plugins/publish';
import DocHandler from '../trie/doc-autocmp';
import { Kind, PurpleComment, PurpleSummary, TentacledKindString } from '../../typings/docs';
import { Paginator } from '../Paginator';
import { ApplicationCommandOptionType, Colors, EmbedBuilder } from 'discord.js';
import { Kind, PurpleComment, PurpleSummary, TentacledKindString } from '../../typings/docs.js';
import { Paginator } from '../Paginator.js';
import { publish } from '../plugins/publish.js';
import DocHandler from '../trie/doc-autocmp.js';
function handleComments(sum : PurpleSummary) {
switch(sum.kind) {

View File

@@ -2,8 +2,8 @@ import { CommandType, commandModule, Context } from "@sern/handler";
import { Client, Collection, EmbedBuilder } from "discord.js";
import { inspect } from "util";
import { fetch } from "undici";
import { ownerOnly } from "../plugins/ownerOnly";
import type { Data } from "./plugin";
import { ownerOnly } from "../plugins/ownerOnly.js";
import type { Data } from "./plugin.js";
export default commandModule({
type: CommandType.Text,

View File

@@ -1,5 +1,5 @@
import { commandModule, CommandType } from "@sern/handler";
import type { TagMessage } from "../../types";
import type { TagMessage } from "../../types/index.js";
export default commandModule({
type: CommandType.Button,

View File

@@ -1,6 +1,8 @@
import { commandModule, CommandType } from "@sern/handler";
import { existsSync, writeFileSync } from "fs";
import type { TagData } from "../../types";
import type { TagData } from "../../types/index.js";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
export default commandModule({
type: CommandType.Modal,

View File

@@ -1,6 +1,8 @@
import { commandModule, CommandType } from "@sern/handler";
import { writeFileSync } from "fs";
import type { TagData } from "../../types";
import type { TagData } from "../../types/index.js";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
export default commandModule({
type: CommandType.Modal,

View File

@@ -9,9 +9,9 @@ import {
ChannelType,
EmbedBuilder,
} from "discord.js";
import { ownerOnly } from "../plugins/ownerOnly";
import { publish } from "../plugins/publish";
import { Resolver } from "../Resolver";
import { ownerOnly } from "../plugins/ownerOnly.js";
import { publish } from "../plugins/publish.js";
import { Resolver } from "../Resolver.js";
export default commandModule({
plugins: [ownerOnly(), publish()],

View File

@@ -1,5 +1,5 @@
import { commandModule, CommandType } from "@sern/handler";
import { publish } from "../plugins/publish";
import { publish } from "../plugins/publish.js";
export default commandModule({
type: CommandType.Slash,
plugins: [publish()],

View File

@@ -1,10 +1,10 @@
import { commandModule, CommandType } from "@sern/handler";
import { publish } from "../plugins/publish";
import { publish } from "../plugins/publish.js";
import { fetch } from "undici";
import { ApplicationCommandOptionType, EmbedBuilder } from "discord.js";
import { cooldown } from "../plugins/cooldown";
import { cooldown } from "../plugins/cooldown.js";
import { parse } from "jsdoc-parse-plus";
import { refreshCache } from "../plugins/refreshCache";
import { refreshCache } from "../plugins/refreshCache.js";
export default commandModule({
type: CommandType.Slash,
description: "View sern plugins",

View File

@@ -1,9 +1,12 @@
import { commandModule, CommandType } from "@sern/handler";
import { ApplicationCommandOptionType, EmbedBuilder } from "discord.js";
import { existsSync } from "fs";
import { Paginator } from "../Paginator";
import { publish } from "../plugins/publish";
import type { TagData } from "../types";
import { Paginator } from "../Paginator.js";
import { publish } from "../plugins/publish.js";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
import type { TagData } from "../types/index.js";
export default commandModule({
type: CommandType.Slash,

View File

@@ -2,18 +2,17 @@ import { commandModule, CommandType } from "@sern/handler";
import {
ActionRowBuilder,
ApplicationCommandOptionType,
ButtonBuilder,
ButtonStyle,
ComponentType,
EmbedBuilder,
ModalBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js";
import { existsSync, writeFileSync } from "fs";
import { ownerOnly } from "../plugins/ownerOnly";
import { publish } from "../plugins/publish";
import type { TagData } from "../types";
import { ownerOnly } from "../plugins/ownerOnly.js";
import { publish } from "../plugins/publish.js";
import type { TagData } from "../types/index.js";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
export default commandModule({
type: CommandType.Slash,
plugins: [publish(), ownerOnly()],

View File

@@ -6,8 +6,10 @@ import {
EmbedBuilder,
Message,
} from "discord.js";
import type { TagData, TagMessage } from "../types";
import { FuzzyMatcher } from "../FuzzyMatcher";
import type { TagData, TagMessage } from "../types/index.js";
import { FuzzyMatcher } from "../FuzzyMatcher.js";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const file: TagData[] = require(`${process.cwd()}/tags.json`);
export default eventModule({

View File

@@ -1,7 +1,7 @@
import { CommandPlugin, CommandType, PluginType } from "@sern/handler";
import type { Collection } from "discord.js";
import { cp } from "../commands/eval";
import type { Data } from "../commands/plugin";
import { cp } from "../commands/eval.js";
import type { Data } from "../commands/plugin.js";
export function refreshCache(): CommandPlugin<CommandType.Slash> {
return {
type: PluginType.Command,

View File

@@ -1,6 +1,10 @@
import { readFile } from "fs/promises";
import TrieSearch from "trie-search";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const docs = require(`${process.cwd()}/docs.json`);
import type { DocsChild } from "../../typings/docs";
import type { DocsChild } from "../../typings/docs.js";
/**
* Not bothering typing this json file
@@ -32,7 +36,9 @@ export default class DocHandler {
}
} else {
const sectionChildNodes = section.children.map((id: string) => {
const node = docs.children.find((c: { id: string }) => c.id === id)! as DocsChild;
const node = docs.children.find(
(c: { id: string }) => c.id === id
)! as DocsChild;
return {
name: section.title,
node,

View File

@@ -1 +1 @@
export * from './Tags';
export * from './Tags.js';

View File

@@ -1,8 +1,9 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"moduleResolution": "NodeNext",
"target": "ESNext",
"module": "CommonJS",
"module": "ESNext",
"outDir": "dist",
"strict": true,
"esModuleInterop": true,

View File

@@ -4,7 +4,7 @@ export default defineConfig({
clean: true,
dts: false,
entry: ["src/**/*.ts", "!src/**/*.d.ts", "typings/"],
format: ["cjs"],
format: ["esm"],
minify: false,
skipNodeModulesBundle: true,
sourcemap: false,