From 48cab844d4b3e71a08f4076aa5f1cbc0431ab734 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Mon, 1 May 2023 13:14:13 +0200 Subject: [PATCH] build: switch to bundler moduleResolution --- .yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch | 18 +++++ apps/guide/src/components/H1.tsx | 2 +- apps/guide/src/components/H2.tsx | 2 +- apps/guide/src/components/H3.tsx | 2 +- apps/guide/src/components/H4.tsx | 2 +- apps/guide/src/components/Mdx.tsx | 8 +-- apps/guide/tsconfig.json | 3 +- apps/website/src/app/global-error.tsx | 71 +++++++++++++++++++ apps/website/src/util/fetchMember.ts | 6 +- package.json | 4 +- .../{.prettierrc.js => .prettierrc.cjs} | 0 packages/actions/package.json | 1 + .../src/tsdoc/CommentBlock.ts | 2 +- .../src/tsdoc/CommentNodeContainer.ts | 2 +- .../src/tsdoc/RootComment.ts | 2 +- packages/brokers/package.json | 4 +- .../__tests__/components/button.test.ts | 1 + .../SlashCommands/SlashCommands.test.ts | 2 + packages/builders/package.json | 4 +- packages/collection/package.json | 4 +- packages/core/package.json | 8 +-- packages/formatters/package.json | 4 +- packages/next/package.json | 8 +-- packages/proxy-container/package.json | 2 +- .../proxy/__tests__/proxyRequests.test.ts | 2 +- packages/proxy/package.json | 4 +- packages/proxy/src/handlers/proxyRequests.ts | 2 +- packages/rest/__tests__/BurstHandler.test.ts | 2 +- packages/rest/__tests__/REST.test.ts | 2 +- .../rest/__tests__/RequestHandler.test.ts | 2 +- packages/rest/package.json | 4 +- .../rest/src/lib/errors/RateLimitError.ts | 2 +- packages/rest/src/lib/handlers/IHandler.ts | 2 +- .../src/lib/handlers/SequentialHandler.ts | 4 +- packages/scripts/package.json | 6 +- .../src/template/template.package.json | 4 +- packages/ui/package.json | 6 +- .../components/discord/MessageEmbedFields.tsx | 2 +- .../util/__tests__/types/Equatable.test-d.ts | 2 +- .../__tests__/types/JSONEncodable.test-d.ts | 2 +- packages/util/package.json | 4 +- packages/voice/package.json | 4 +- .../util/SimpleIdentifyThrottler.test.ts | 2 +- packages/ws/package.json | 4 +- .../context/IContextFetchingStrategy.ts | 2 +- .../strategies/sharding/IShardingStrategy.ts | 2 +- .../sharding/SimpleShardingStrategy.ts | 2 +- .../sharding/WorkerShardingStrategy.ts | 10 ++- .../src/throttling/SimpleIdentifyThrottler.ts | 2 +- packages/ws/src/ws/WebSocketManager.ts | 4 +- packages/ws/src/ws/WebSocketShard.ts | 2 +- tsconfig.json | 2 +- yarn.lock | 15 ++-- 53 files changed, 186 insertions(+), 79 deletions(-) create mode 100644 .yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch rename packages/actions/{.prettierrc.js => .prettierrc.cjs} (100%) diff --git a/.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch b/.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch new file mode 100644 index 000000000..514e0bee6 --- /dev/null +++ b/.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch @@ -0,0 +1,18 @@ +diff --git a/package.json b/package.json +index fc35658a40f9ba3e3513c459ba9f4f6e1b3f59f5..bc35eda66f270c95ba52e721cb6976fd61622c58 100644 +--- a/package.json ++++ b/package.json +@@ -26,11 +26,13 @@ + }, + "exports": { + ".": { ++ "types": "./dist/index.d.ts", + "node": "./dist/index.js", + "default": "./browser/index.js" + }, + "./package.json": "./package.json", + "./util": { ++ "types": "./dist/util.d.ts", + "node": "./dist/util.js", + "default": "./browser/dist/util.js" + } diff --git a/apps/guide/src/components/H1.tsx b/apps/guide/src/components/H1.tsx index 147a88456..8f9d130df 100644 --- a/apps/guide/src/components/H1.tsx +++ b/apps/guide/src/components/H1.tsx @@ -1,6 +1,6 @@ import type { HTMLAttributes, PropsWithChildren } from 'react'; -export default function H1({ children, className, ...props }: PropsWithChildren>) { +export function H1({ children, className, ...props }: PropsWithChildren>) { return (

{children} diff --git a/apps/guide/src/components/H2.tsx b/apps/guide/src/components/H2.tsx index dba78917e..b1aa1d7da 100644 --- a/apps/guide/src/components/H2.tsx +++ b/apps/guide/src/components/H2.tsx @@ -1,6 +1,6 @@ import type { HTMLAttributes, PropsWithChildren } from 'react'; -export default function H2({ children, className, ...props }: PropsWithChildren>) { +export function H2({ children, className, ...props }: PropsWithChildren>) { return (

{children} diff --git a/apps/guide/src/components/H3.tsx b/apps/guide/src/components/H3.tsx index 0b43bed7d..cf6c76116 100644 --- a/apps/guide/src/components/H3.tsx +++ b/apps/guide/src/components/H3.tsx @@ -1,6 +1,6 @@ import type { HTMLAttributes, PropsWithChildren } from 'react'; -export default function H3({ children, className, ...props }: PropsWithChildren>) { +export function H3({ children, className, ...props }: PropsWithChildren>) { return (

{children} diff --git a/apps/guide/src/components/H4.tsx b/apps/guide/src/components/H4.tsx index c915ebba4..cddf9810e 100644 --- a/apps/guide/src/components/H4.tsx +++ b/apps/guide/src/components/H4.tsx @@ -1,6 +1,6 @@ import type { HTMLAttributes, PropsWithChildren } from 'react'; -export default function H4({ children, className, ...props }: PropsWithChildren>) { +export function H4({ children, className, ...props }: PropsWithChildren>) { return (

{children} diff --git a/apps/guide/src/components/Mdx.tsx b/apps/guide/src/components/Mdx.tsx index 534e45f6e..deb23121f 100644 --- a/apps/guide/src/components/Mdx.tsx +++ b/apps/guide/src/components/Mdx.tsx @@ -2,10 +2,10 @@ import { Alert, Section, DiscordMessages, DiscordMessage, DiscordMessageEmbed } from '@discordjs/ui'; import { useMDXComponent } from 'next-contentlayer/hooks'; -import H1 from './H1'; -import H2 from './H2'; -import H3 from './H3'; -import H4 from './H4'; +import { H1 } from './H1'; +import { H2 } from './H2'; +import { H3 } from './H3'; +import { H4 } from './H4'; import { DocsLink } from '~/components/DocsLink'; import { ResultingCode } from '~/components/ResultingCode'; diff --git a/apps/guide/tsconfig.json b/apps/guide/tsconfig.json index f04d36240..c8e3df2ea 100644 --- a/apps/guide/tsconfig.json +++ b/apps/guide/tsconfig.json @@ -19,7 +19,8 @@ "~/*": ["./src/*"], "contentlayer/generated": ["./.contentlayer/generated"] }, - "strictNullChecks": true + "strictNullChecks": true, + "moduleResolution": "node" }, "include": [ "src/**/*.ts", diff --git a/apps/website/src/app/global-error.tsx b/apps/website/src/app/global-error.tsx index 6a453879d..398f8312f 100644 --- a/apps/website/src/app/global-error.tsx +++ b/apps/website/src/app/global-error.tsx @@ -1,8 +1,78 @@ 'use client'; +import { Analytics } from '@vercel/analytics/react'; +import type { Metadata } from 'next'; import { Providers } from './providers'; +import { DESCRIPTION } from '~/util/constants'; import { inter } from '~/util/fonts'; +import '@unocss/reset/tailwind-compat.css'; +import '~/styles/unocss.css'; +import '~/styles/cmdk.css'; +import '~/styles/main.css'; + +export const metadata: Metadata = { + title: 'discord.js', + description: DESCRIPTION, + viewport: { + minimumScale: 1, + initialScale: 1, + width: 'device-width', + }, + icons: { + other: [ + { + url: '/favicon-32x32.png', + sizes: '32x32', + type: 'image/png', + }, + { + url: '/favicon-16x16.png', + sizes: '16x16', + type: 'image/png', + }, + ], + apple: [ + '/apple-touch-icon.png', + { + url: '/safari-pinned-tab.svg', + rel: 'mask-icon', + }, + ], + }, + + manifest: '/site.webmanifest', + + themeColor: [ + { media: '(prefers-color-scheme: light)', color: '#f1f3f5' }, + { media: '(prefers-color-scheme: dark)', color: '#1c1c1e' }, + ], + colorScheme: 'light dark', + + appleWebApp: { + title: 'discord.js', + }, + + applicationName: 'discord.js', + + openGraph: { + siteName: 'discord.js', + type: 'website', + title: 'discord.js', + description: DESCRIPTION, + images: 'https://discordjs.dev/api/open-graph.png', + }, + + twitter: { + card: 'summary_large_image', + creator: '@iCrawlToGo', + }, + + other: { + 'msapplication-TileColor': '#1c1c1e', + }, +}; + export default function GlobalError({ error }: { error: Error }) { console.error(error); @@ -17,6 +87,7 @@ export default function GlobalError({ error }: { error: Error }) { + ); diff --git a/apps/website/src/util/fetchMember.ts b/apps/website/src/util/fetchMember.ts index 324e5b7e9..eb4a20800 100644 --- a/apps/website/src/util/fetchMember.ts +++ b/apps/website/src/util/fetchMember.ts @@ -1,9 +1,9 @@ import { addPackageToModel } from '@discordjs/scripts'; import { ApiModel, ApiFunction } from '@microsoft/api-extractor-model'; import { notFound } from 'next/navigation'; -import { OVERLOAD_SEPARATOR, PACKAGES } from './constants'; -import { findMember, findMemberByKey } from './model'; -import { fetchModelJSON } from '~/app/docAPI'; +import { OVERLOAD_SEPARATOR, PACKAGES } from './constants.js'; +import { findMember, findMemberByKey } from './model.js'; +import { fetchModelJSON } from '~/app/docAPI.js'; export interface ItemRouteParams { item: string; diff --git a/package.json b/package.json index d96a119e9..2b4d6f860 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,9 @@ }, "resolutions": { "@microsoft/tsdoc-config@~0.16.1": "patch:@microsoft/tsdoc-config@npm%3A0.16.2#./.yarn/patches/@microsoft-tsdoc-config-npm-0.16.2-30fd115d09.patch", - "@microsoft/tsdoc-config@0.16.2": "patch:@microsoft/tsdoc-config@npm%3A0.16.2#./.yarn/patches/@microsoft-tsdoc-config-npm-0.16.2-30fd115d09.patch" + "@microsoft/tsdoc-config@0.16.2": "patch:@microsoft/tsdoc-config@npm%3A0.16.2#./.yarn/patches/@microsoft-tsdoc-config-npm-0.16.2-30fd115d09.patch", + "yaml@^2.2.2": "patch:yaml@npm%3A2.2.2#./.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch", + "yaml@2.2.2": "patch:yaml@npm%3A2.2.2#./.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch" }, "engines": { "node": ">=16.9.0" diff --git a/packages/actions/.prettierrc.js b/packages/actions/.prettierrc.cjs similarity index 100% rename from packages/actions/.prettierrc.js rename to packages/actions/.prettierrc.cjs diff --git a/packages/actions/package.json b/packages/actions/package.json index 75d9b5f81..dd5135c29 100644 --- a/packages/actions/package.json +++ b/packages/actions/package.json @@ -10,6 +10,7 @@ "format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty", "fmt": "yarn format" }, + "type": "module", "main": "./dist/index.mjs", "types": "./dist/index.d.ts", "directories": { diff --git a/packages/api-extractor-utils/src/tsdoc/CommentBlock.ts b/packages/api-extractor-utils/src/tsdoc/CommentBlock.ts index 2f7a039a5..09b4de753 100644 --- a/packages/api-extractor-utils/src/tsdoc/CommentBlock.ts +++ b/packages/api-extractor-utils/src/tsdoc/CommentBlock.ts @@ -2,7 +2,7 @@ import type { ApiModel, ApiItem } from '@microsoft/api-extractor-model'; import type { DocBlock } from '@microsoft/tsdoc'; import { blockTag, type DocBlockTagJSON } from './CommentBlockTag.js'; import { type AnyDocNodeJSON, type DocNodeJSON, node } from './CommentNode.js'; -import { createCommentNode } from '.'; +import { createCommentNode } from './index.js'; export interface DocBlockJSON extends DocNodeJSON { content: AnyDocNodeJSON[]; diff --git a/packages/api-extractor-utils/src/tsdoc/CommentNodeContainer.ts b/packages/api-extractor-utils/src/tsdoc/CommentNodeContainer.ts index 294d6843e..28c43e86f 100644 --- a/packages/api-extractor-utils/src/tsdoc/CommentNodeContainer.ts +++ b/packages/api-extractor-utils/src/tsdoc/CommentNodeContainer.ts @@ -1,7 +1,7 @@ import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model'; import type { DocNodeContainer } from '@microsoft/tsdoc'; import { type AnyDocNodeJSON, type DocNodeJSON, node } from './CommentNode.js'; -import { createCommentNode } from '.'; +import { createCommentNode } from './index.js'; export interface DocNodeContainerJSON extends DocNodeJSON { nodes: AnyDocNodeJSON[]; diff --git a/packages/api-extractor-utils/src/tsdoc/RootComment.ts b/packages/api-extractor-utils/src/tsdoc/RootComment.ts index 19f10d85f..cf503d296 100644 --- a/packages/api-extractor-utils/src/tsdoc/RootComment.ts +++ b/packages/api-extractor-utils/src/tsdoc/RootComment.ts @@ -2,7 +2,7 @@ import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model'; import type { DocComment } from '@microsoft/tsdoc'; import { block, type DocBlockJSON } from './CommentBlock.js'; import { type DocNodeJSON, node } from './CommentNode.js'; -import { createCommentNode } from '.'; +import { createCommentNode } from './index.js'; export interface DocCommentJSON extends DocNodeJSON { customBlocks: DocBlockJSON[]; diff --git a/packages/brokers/package.json b/packages/brokers/package.json index 3686bb038..26816c2e9 100644 --- a/packages/brokers/package.json +++ b/packages/brokers/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "typings": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/builders/__tests__/components/button.test.ts b/packages/builders/__tests__/components/button.test.ts index eb66b2613..29da7b472 100644 --- a/packages/builders/__tests__/components/button.test.ts +++ b/packages/builders/__tests__/components/button.test.ts @@ -101,6 +101,7 @@ describe('Button Components', () => { button.toJSON(); }).toThrowError(); + // @ts-expect-error: Invalid style expect(() => buttonComponent().setStyle(24)).toThrowError(); expect(() => buttonComponent().setLabel(longStr)).toThrowError(); // @ts-expect-error: Invalid parameter for disabled diff --git a/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts b/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts index 0726d0d53..f58159632 100644 --- a/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts +++ b/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts @@ -240,8 +240,10 @@ describe('Slash Commands', () => { }); test('GIVEN a builder with valid channel options and channel_types THEN does throw an error', () => { + // @ts-expect-error: Invalid channel type expect(() => getBuilder().addChannelOption(getChannelOption().addChannelTypes(100))).toThrowError(); + // @ts-expect-error: Invalid channel types expect(() => getBuilder().addChannelOption(getChannelOption().addChannelTypes(100, 200))).toThrowError(); }); diff --git a/packages/builders/package.json b/packages/builders/package.json index ac675c332..628b1364d 100644 --- a/packages/builders/package.json +++ b/packages/builders/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/collection/package.json b/packages/collection/package.json index f576a98a9..c569d280b 100644 --- a/packages/collection/package.json +++ b/packages/collection/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/core/package.json b/packages/core/package.json index 167b9052f..297ee8a9f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -18,14 +18,14 @@ "typings": "./dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "./http-only": { + "types": "./dist/http-only.d.ts", "import": "./dist/http-only.mjs", - "require": "./dist/http-only.js", - "types": "./dist/http-only.d.ts" + "require": "./dist/http-only.js" } }, "directories": { diff --git a/packages/formatters/package.json b/packages/formatters/package.json index 041f31639..43d71a41d 100644 --- a/packages/formatters/package.json +++ b/packages/formatters/package.json @@ -17,9 +17,9 @@ "module": "./dist/index.mjs", "typings": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/next/package.json b/packages/next/package.json index 0da366cdd..44d3c833a 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -18,14 +18,14 @@ "typings": "./dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "./*": { + "types": "./dist/exports/*.d.ts", "import": "./dist/exports/*.mjs", - "require": "./dist/exports/*.js", - "types": "./dist/exports/*.d.ts" + "require": "./dist/exports/*.js" } }, "directories": { diff --git a/packages/proxy-container/package.json b/packages/proxy-container/package.json index b6c6ffc98..8ffb3fd5f 100644 --- a/packages/proxy-container/package.json +++ b/packages/proxy-container/package.json @@ -10,7 +10,7 @@ "prepack": "yarn lint && yarn build" }, "type": "module", - "module": "./dist/index.js", + "main": "./dist/index.js", "directories": { "lib": "src" }, diff --git a/packages/proxy/__tests__/proxyRequests.test.ts b/packages/proxy/__tests__/proxyRequests.test.ts index 6069fda2b..23bc8f94e 100644 --- a/packages/proxy/__tests__/proxyRequests.test.ts +++ b/packages/proxy/__tests__/proxyRequests.test.ts @@ -2,7 +2,7 @@ import { createServer } from 'node:http'; import { REST } from '@discordjs/rest'; import supertest from 'supertest'; import { MockAgent, setGlobalDispatcher, type Interceptable } from 'undici'; -import type { MockInterceptor } from 'undici/types/mock-interceptor'; +import type { MockInterceptor } from 'undici/types/mock-interceptor.js'; import { beforeEach, afterAll, afterEach, test, expect } from 'vitest'; import { proxyRequests } from '../src/index.js'; diff --git a/packages/proxy/package.json b/packages/proxy/package.json index d046752d7..5549fab44 100644 --- a/packages/proxy/package.json +++ b/packages/proxy/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "typings": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/proxy/src/handlers/proxyRequests.ts b/packages/proxy/src/handlers/proxyRequests.ts index 599413e37..c243982ad 100644 --- a/packages/proxy/src/handlers/proxyRequests.ts +++ b/packages/proxy/src/handlers/proxyRequests.ts @@ -1,7 +1,7 @@ import { URL } from 'node:url'; import type { RequestMethod, REST, RouteLike } from '@discordjs/rest'; import { populateSuccessfulResponse, populateErrorResponse } from '../util/responseHelpers.js'; -import type { RequestHandler } from '../util/util'; +import type { RequestHandler } from '../util/util.js'; /** * Creates an HTTP handler used to forward requests to Discord diff --git a/packages/rest/__tests__/BurstHandler.test.ts b/packages/rest/__tests__/BurstHandler.test.ts index a77e6a022..25831d538 100644 --- a/packages/rest/__tests__/BurstHandler.test.ts +++ b/packages/rest/__tests__/BurstHandler.test.ts @@ -4,7 +4,7 @@ import { performance } from 'node:perf_hooks'; import { MockAgent, setGlobalDispatcher } from 'undici'; import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor'; import { beforeEach, afterEach, test, expect, vitest } from 'vitest'; -import { DiscordAPIError, HTTPError, RateLimitError, REST, BurstHandlerMajorIdKey } from '../src/index.js'; +import { DiscordAPIError, REST, BurstHandlerMajorIdKey } from '../src/index.js'; import { BurstHandler } from '../src/lib/handlers/BurstHandler.js'; import { genPath } from './util.js'; diff --git a/packages/rest/__tests__/REST.test.ts b/packages/rest/__tests__/REST.test.ts index 2968016e9..dbaba1206 100644 --- a/packages/rest/__tests__/REST.test.ts +++ b/packages/rest/__tests__/REST.test.ts @@ -5,7 +5,7 @@ import type { Snowflake } from 'discord-api-types/v10'; import { Routes } from 'discord-api-types/v10'; import type { FormData } from 'undici'; import { File as UndiciFile, MockAgent, setGlobalDispatcher } from 'undici'; -import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor'; +import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor.js'; import { beforeEach, afterEach, test, expect } from 'vitest'; import { REST } from '../src/index.js'; import { genPath } from './util.js'; diff --git a/packages/rest/__tests__/RequestHandler.test.ts b/packages/rest/__tests__/RequestHandler.test.ts index 6764f1a3b..1421fd69e 100644 --- a/packages/rest/__tests__/RequestHandler.test.ts +++ b/packages/rest/__tests__/RequestHandler.test.ts @@ -3,7 +3,7 @@ import { performance } from 'node:perf_hooks'; import { setInterval, clearInterval, setTimeout } from 'node:timers'; import { MockAgent, setGlobalDispatcher } from 'undici'; -import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor'; +import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor.js'; import { beforeEach, afterEach, test, expect, vitest } from 'vitest'; import { DiscordAPIError, HTTPError, RateLimitError, REST, RESTEvents } from '../src/index.js'; import { genPath } from './util.js'; diff --git a/packages/rest/package.json b/packages/rest/package.json index 7a8af07da..ab4899e47 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "typings": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/rest/src/lib/errors/RateLimitError.ts b/packages/rest/src/lib/errors/RateLimitError.ts index 7c47fc56c..cb6b7c1df 100644 --- a/packages/rest/src/lib/errors/RateLimitError.ts +++ b/packages/rest/src/lib/errors/RateLimitError.ts @@ -1,4 +1,4 @@ -import type { RateLimitData } from '../REST'; +import type { RateLimitData } from '../REST.js'; export class RateLimitError extends Error implements RateLimitData { public timeToReset: number; diff --git a/packages/rest/src/lib/handlers/IHandler.ts b/packages/rest/src/lib/handlers/IHandler.ts index 605a3d9ff..a6837d16b 100644 --- a/packages/rest/src/lib/handlers/IHandler.ts +++ b/packages/rest/src/lib/handlers/IHandler.ts @@ -1,5 +1,5 @@ import type { Dispatcher } from 'undici'; -import type { RequestOptions } from '../REST'; +import type { RequestOptions } from '../REST.js'; import type { HandlerRequestData, RouteData } from '../RequestManager.js'; export interface IHandler { diff --git a/packages/rest/src/lib/handlers/SequentialHandler.ts b/packages/rest/src/lib/handlers/SequentialHandler.ts index 0dc20c89e..a6b461afa 100644 --- a/packages/rest/src/lib/handlers/SequentialHandler.ts +++ b/packages/rest/src/lib/handlers/SequentialHandler.ts @@ -1,8 +1,8 @@ import { setTimeout as sleep } from 'node:timers/promises'; import { AsyncQueue } from '@sapphire/async-queue'; import type { Dispatcher } from 'undici'; -import type { RateLimitData, RequestOptions } from '../REST'; -import type { HandlerRequestData, RequestManager, RouteData } from '../RequestManager'; +import type { RateLimitData, RequestOptions } from '../REST.js'; +import type { HandlerRequestData, RequestManager, RouteData } from '../RequestManager.js'; import { RESTEvents } from '../utils/constants.js'; import { hasSublimit, onRateLimit, parseHeader } from '../utils/utils.js'; import type { IHandler } from './IHandler.js'; diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 6c79e3aff..962581523 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -13,9 +13,9 @@ "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src" @@ -52,7 +52,7 @@ "fs-extra": "^11.1.1", "tslib": "^2.5.0", "undici": "^5.22.0", - "yaml": "^2.2.2" + "yaml": "2.2.2" }, "devDependencies": { "@types/fs-extra": "^11.0.1", diff --git a/packages/scripts/src/template/template.package.json b/packages/scripts/src/template/template.package.json index c39c5f441..d40b762d3 100644 --- a/packages/scripts/src/template/template.package.json +++ b/packages/scripts/src/template/template.package.json @@ -17,9 +17,9 @@ "module": "./dist/index.mjs", "typings": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/ui/package.json b/packages/ui/package.json index 2836b1f36..8aeb9669f 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -15,11 +15,11 @@ "chromatic": "chromatic" }, "type": "module", - "module": "./dist/ui.js", + "main": "./dist/ui.js", "typings": "./dist/index.d.ts", "exports": { - "import": "./dist/ui.js", - "types": "./dist/index.d.ts" + "types": "./dist/index.d.ts", + "import": "./dist/ui.js" }, "sideEffects": false, "directories": { diff --git a/packages/ui/src/lib/components/discord/MessageEmbedFields.tsx b/packages/ui/src/lib/components/discord/MessageEmbedFields.tsx index 2c99e0959..147a80b07 100644 --- a/packages/ui/src/lib/components/discord/MessageEmbedFields.tsx +++ b/packages/ui/src/lib/components/discord/MessageEmbedFields.tsx @@ -1,4 +1,4 @@ -import { DiscordMessageEmbedField, type IDiscordMessageEmbedField } from './MessageEmbedField.js'; +import { DiscordMessageEmbedField, type IDiscordMessageEmbedField } from './MessageEmbedField.jsx'; export interface IDiscordMessageEmbedFields { fields: IDiscordMessageEmbedField[]; diff --git a/packages/util/__tests__/types/Equatable.test-d.ts b/packages/util/__tests__/types/Equatable.test-d.ts index 86c579192..db918b432 100644 --- a/packages/util/__tests__/types/Equatable.test-d.ts +++ b/packages/util/__tests__/types/Equatable.test-d.ts @@ -1,5 +1,5 @@ import { expectType } from 'tsd'; -import type { Equatable } from '../../dist'; +import type { Equatable } from '../../dist/index.js'; import { isEquatable } from '../../src/index.js'; declare const unknownObj: unknown; diff --git a/packages/util/__tests__/types/JSONEncodable.test-d.ts b/packages/util/__tests__/types/JSONEncodable.test-d.ts index 7f28e6485..710cf014a 100644 --- a/packages/util/__tests__/types/JSONEncodable.test-d.ts +++ b/packages/util/__tests__/types/JSONEncodable.test-d.ts @@ -1,5 +1,5 @@ import { expectType } from 'tsd'; -import type { JSONEncodable } from '../../dist'; +import type { JSONEncodable } from '../../dist/index.js'; import { isJSONEncodable } from '../../src/index.js'; declare const unknownObj: unknown; diff --git a/packages/util/package.json b/packages/util/package.json index fd08643ea..ce3bc5b43 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src" diff --git a/packages/voice/package.json b/packages/voice/package.json index 3d4e34b90..dd77baae4 100644 --- a/packages/voice/package.json +++ b/packages/voice/package.json @@ -18,9 +18,9 @@ "module": "./dist/index.mjs", "typings": "./dist/index.d.ts", "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "directories": { "lib": "src", diff --git a/packages/ws/__tests__/util/SimpleIdentifyThrottler.test.ts b/packages/ws/__tests__/util/SimpleIdentifyThrottler.test.ts index 518b6d8f2..0d004523b 100644 --- a/packages/ws/__tests__/util/SimpleIdentifyThrottler.test.ts +++ b/packages/ws/__tests__/util/SimpleIdentifyThrottler.test.ts @@ -1,5 +1,5 @@ import { setTimeout as sleep } from 'node:timers/promises'; -import { expect, test, vi, type Mock } from 'vitest'; +import { expect, test, vi } from 'vitest'; import { SimpleIdentifyThrottler } from '../../src/index.js'; vi.mock('node:timers/promises', () => ({ diff --git a/packages/ws/package.json b/packages/ws/package.json index 00789081b..693d37299 100644 --- a/packages/ws/package.json +++ b/packages/ws/package.json @@ -18,9 +18,9 @@ "typings": "./dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.js" }, "./defaultWorker": { "import": "./dist/defaultWorker.mjs", diff --git a/packages/ws/src/strategies/context/IContextFetchingStrategy.ts b/packages/ws/src/strategies/context/IContextFetchingStrategy.ts index d2d056fba..b57f0ff82 100644 --- a/packages/ws/src/strategies/context/IContextFetchingStrategy.ts +++ b/packages/ws/src/strategies/context/IContextFetchingStrategy.ts @@ -1,6 +1,6 @@ import type { Awaitable } from '@discordjs/util'; import type { APIGatewayBotInfo } from 'discord-api-types/v10'; -import type { SessionInfo, WebSocketManager, WebSocketManagerOptions } from '../../ws/WebSocketManager'; +import type { SessionInfo, WebSocketManager, WebSocketManagerOptions } from '../../ws/WebSocketManager.js'; export interface FetchingStrategyOptions extends Omit< diff --git a/packages/ws/src/strategies/sharding/IShardingStrategy.ts b/packages/ws/src/strategies/sharding/IShardingStrategy.ts index ec7ce133e..d56330814 100644 --- a/packages/ws/src/strategies/sharding/IShardingStrategy.ts +++ b/packages/ws/src/strategies/sharding/IShardingStrategy.ts @@ -1,7 +1,7 @@ import type { Collection } from '@discordjs/collection'; import type { Awaitable } from '@discordjs/util'; import type { GatewaySendPayload } from 'discord-api-types/v10'; -import type { WebSocketShardDestroyOptions, WebSocketShardStatus } from '../../ws/WebSocketShard'; +import type { WebSocketShardDestroyOptions, WebSocketShardStatus } from '../../ws/WebSocketShard.js'; /** * Strategies responsible for spawning, initializing connections, destroying shards, and relaying events diff --git a/packages/ws/src/strategies/sharding/SimpleShardingStrategy.ts b/packages/ws/src/strategies/sharding/SimpleShardingStrategy.ts index 9e3a54a99..f1b7e8f83 100644 --- a/packages/ws/src/strategies/sharding/SimpleShardingStrategy.ts +++ b/packages/ws/src/strategies/sharding/SimpleShardingStrategy.ts @@ -1,6 +1,6 @@ import { Collection } from '@discordjs/collection'; import type { GatewaySendPayload } from 'discord-api-types/v10'; -import type { WebSocketManager } from '../../ws/WebSocketManager'; +import type { WebSocketManager } from '../../ws/WebSocketManager.js'; import { WebSocketShard, WebSocketShardEvents, type WebSocketShardDestroyOptions } from '../../ws/WebSocketShard.js'; import { managerToFetchingStrategyOptions } from '../context/IContextFetchingStrategy.js'; import { SimpleContextFetchingStrategy } from '../context/SimpleContextFetchingStrategy.js'; diff --git a/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts b/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts index ca92d6c01..fbca00c31 100644 --- a/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts +++ b/packages/ws/src/strategies/sharding/WorkerShardingStrategy.ts @@ -3,9 +3,13 @@ import { join, isAbsolute, resolve } from 'node:path'; import { Worker } from 'node:worker_threads'; import { Collection } from '@discordjs/collection'; import type { GatewaySendPayload } from 'discord-api-types/v10'; -import type { IIdentifyThrottler } from '../../throttling/IIdentifyThrottler'; -import type { SessionInfo, WebSocketManager } from '../../ws/WebSocketManager'; -import type { WebSocketShardDestroyOptions, WebSocketShardEvents, WebSocketShardStatus } from '../../ws/WebSocketShard'; +import type { IIdentifyThrottler } from '../../throttling/IIdentifyThrottler.js'; +import type { SessionInfo, WebSocketManager } from '../../ws/WebSocketManager.js'; +import type { + WebSocketShardDestroyOptions, + WebSocketShardEvents, + WebSocketShardStatus, +} from '../../ws/WebSocketShard.js'; import { managerToFetchingStrategyOptions, type FetchingStrategyOptions } from '../context/IContextFetchingStrategy.js'; import type { IShardingStrategy } from './IShardingStrategy.js'; diff --git a/packages/ws/src/throttling/SimpleIdentifyThrottler.ts b/packages/ws/src/throttling/SimpleIdentifyThrottler.ts index a612012b4..bacf3fb07 100644 --- a/packages/ws/src/throttling/SimpleIdentifyThrottler.ts +++ b/packages/ws/src/throttling/SimpleIdentifyThrottler.ts @@ -1,7 +1,7 @@ import { setTimeout as sleep } from 'node:timers/promises'; import { Collection } from '@discordjs/collection'; import { AsyncQueue } from '@sapphire/async-queue'; -import type { IIdentifyThrottler } from './IIdentifyThrottler'; +import type { IIdentifyThrottler } from './IIdentifyThrottler.js'; /** * The state of a rate limit key's identify queue. diff --git a/packages/ws/src/ws/WebSocketManager.ts b/packages/ws/src/ws/WebSocketManager.ts index 2c646c04b..7624ce2a2 100644 --- a/packages/ws/src/ws/WebSocketManager.ts +++ b/packages/ws/src/ws/WebSocketManager.ts @@ -10,8 +10,8 @@ import { type GatewayIntentBits, type GatewaySendPayload, } from 'discord-api-types/v10'; -import type { IShardingStrategy } from '../strategies/sharding/IShardingStrategy'; -import type { IIdentifyThrottler } from '../throttling/IIdentifyThrottler'; +import type { IShardingStrategy } from '../strategies/sharding/IShardingStrategy.js'; +import type { IIdentifyThrottler } from '../throttling/IIdentifyThrottler.js'; import { DefaultWebSocketManagerOptions, type CompressionMethod, type Encoding } from '../utils/constants.js'; import type { WebSocketShardDestroyOptions, WebSocketShardEventsMap } from './WebSocketShard.js'; diff --git a/packages/ws/src/ws/WebSocketShard.ts b/packages/ws/src/ws/WebSocketShard.ts index 85b3f3c22..435c9a97c 100644 --- a/packages/ws/src/ws/WebSocketShard.ts +++ b/packages/ws/src/ws/WebSocketShard.ts @@ -22,7 +22,7 @@ import { } from 'discord-api-types/v10'; import { WebSocket, type RawData } from 'ws'; import type { Inflate } from 'zlib-sync'; -import type { IContextFetchingStrategy } from '../strategies/context/IContextFetchingStrategy'; +import type { IContextFetchingStrategy } from '../strategies/context/IContextFetchingStrategy.js'; import { ImportantGatewayOpcodes, getInitialSendRateLimitState } from '../utils/constants.js'; import type { SessionInfo } from './WebSocketManager.js'; diff --git a/tsconfig.json b/tsconfig.json index 80f404863..2eef22df7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ // Modules "module": "ESNext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, // Emit diff --git a/yarn.lock b/yarn.lock index b997a54de..254ae4424 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2356,7 +2356,7 @@ __metadata: typescript: ^5.0.4 undici: ^5.22.0 vitest: ^0.29.8 - yaml: ^2.2.2 + yaml: 2.2.2 languageName: unknown linkType: soft @@ -26052,6 +26052,13 @@ __metadata: languageName: node linkType: hard +"yaml@npm:2.2.2, yaml@npm:^2.1.1": + version: 2.2.2 + resolution: "yaml@npm:2.2.2" + checksum: d90c235e099e30094dcff61ba3350437aef53325db4a6bcd04ca96e1bfe7e348b191f6a7a52b5211e2dbc4eeedb22a00b291527da030de7c189728ef3f2b4eb3 + languageName: node + linkType: hard + "yaml@npm:^1.10.2": version: 1.10.2 resolution: "yaml@npm:1.10.2" @@ -26059,10 +26066,10 @@ __metadata: languageName: node linkType: hard -"yaml@npm:^2.1.1, yaml@npm:^2.2.2": +"yaml@patch:yaml@npm%3A2.2.2#./.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch::locator=%40discordjs%2Fdiscord.js%40workspace%3A.": version: 2.2.2 - resolution: "yaml@npm:2.2.2" - checksum: d90c235e099e30094dcff61ba3350437aef53325db4a6bcd04ca96e1bfe7e348b191f6a7a52b5211e2dbc4eeedb22a00b291527da030de7c189728ef3f2b4eb3 + resolution: "yaml@patch:yaml@npm%3A2.2.2#./.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch::version=2.2.2&hash=2af928&locator=%40discordjs%2Fdiscord.js%40workspace%3A." + checksum: 3ef8fd54fae7a810ea323a9d183b37698aaf7c0ab03334a4740a919489361ef7014c8ffefe561f21086cd697ec7c3643cb0551c9f729f24ce9d1c2904a213727 languageName: node linkType: hard