Skip to content

Commit

Permalink
build: switch to bundler moduleResolution
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed May 1, 2023
1 parent 8b71f44 commit 48cab84
Show file tree
Hide file tree
Showing 53 changed files with 186 additions and 79 deletions.
18 changes: 18 additions & 0 deletions .yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion apps/guide/src/components/H1.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { HTMLAttributes, PropsWithChildren } from 'react';

export default function H1({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
export function H1({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
return (
<h1 className={`group ${className}`} {...props}>
{children}
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/components/H2.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { HTMLAttributes, PropsWithChildren } from 'react';

export default function H2({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
export function H2({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
return (
<h2 className={`group ${className}`} {...props}>
{children}
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/components/H3.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { HTMLAttributes, PropsWithChildren } from 'react';

export default function H3({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
export function H3({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
return (
<h3 className={`group ${className}`} {...props}>
{children}
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/components/H4.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { HTMLAttributes, PropsWithChildren } from 'react';

export default function H4({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
export function H4({ children, className, ...props }: PropsWithChildren<HTMLAttributes<HTMLHeadingElement>>) {
return (
<h4 className={`group ${className}`} {...props}>
{children}
Expand Down
8 changes: 4 additions & 4 deletions apps/guide/src/components/Mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 2 additions & 1 deletion apps/guide/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"~/*": ["./src/*"],
"contentlayer/generated": ["./.contentlayer/generated"]
},
"strictNullChecks": true
"strictNullChecks": true,
"moduleResolution": "node"
},
"include": [
"src/**/*.ts",
Expand Down
71 changes: 71 additions & 0 deletions apps/website/src/app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -17,6 +87,7 @@ export default function GlobalError({ error }: { error: Error }) {
</div>
</main>
</Providers>
<Analytics />
</body>
</html>
);
Expand Down
6 changes: 3 additions & 3 deletions apps/website/src/util/fetchMember.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]": "patch:@microsoft/tsdoc-config@npm%3A0.16.2#./.yarn/patches/@microsoft-tsdoc-config-npm-0.16.2-30fd115d09.patch"
"@microsoft/[email protected]": "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",
"[email protected]": "patch:yaml@npm%3A2.2.2#./.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch"
},
"engines": {
"node": ">=16.9.0"
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-extractor-utils/src/tsdoc/CommentBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion packages/api-extractor-utils/src/tsdoc/RootComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
4 changes: 2 additions & 2 deletions packages/brokers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/builders/__tests__/components/button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/formatters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/proxy-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"prepack": "yarn lint && yarn build"
},
"type": "module",
"module": "./dist/index.js",
"main": "./dist/index.js",
"directories": {
"lib": "src"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/proxy/__tests__/proxyRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions packages/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/proxy/src/handlers/proxyRequests.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/__tests__/BurstHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/rest/__tests__/REST.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/__tests__/RequestHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading

1 comment on commit 48cab84

@vercel
Copy link

@vercel vercel bot commented on 48cab84 May 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.