build: switch to bundler moduleResolution

This commit is contained in:
iCrawl
2023-05-01 13:14:13 +02:00
parent 8b71f44b1f
commit 48cab844d4
53 changed files with 186 additions and 79 deletions

View File

@@ -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": {

View File

@@ -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[];

View File

@@ -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[];

View File

@@ -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[];

View File

@@ -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",

View File

@@ -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

View File

@@ -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();
});

View File

@@ -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",

View File

@@ -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",

View File

@@ -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": {

View File

@@ -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",

View File

@@ -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": {

View File

@@ -10,7 +10,7 @@
"prepack": "yarn lint && yarn build"
},
"type": "module",
"module": "./dist/index.js",
"main": "./dist/index.js",
"directories": {
"lib": "src"
},

View File

@@ -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';

View File

@@ -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",

View File

@@ -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

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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",

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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';

View File

@@ -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",

View File

@@ -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",

View File

@@ -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": {

View File

@@ -1,4 +1,4 @@
import { DiscordMessageEmbedField, type IDiscordMessageEmbedField } from './MessageEmbedField.js';
import { DiscordMessageEmbedField, type IDiscordMessageEmbedField } from './MessageEmbedField.jsx';
export interface IDiscordMessageEmbedFields {
fields: IDiscordMessageEmbedField[];

View File

@@ -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;

View File

@@ -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;

View File

@@ -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"

View File

@@ -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",

View File

@@ -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', () => ({

View File

@@ -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",

View File

@@ -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<

View File

@@ -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

View File

@@ -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';

View File

@@ -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';

View File

@@ -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.

View File

@@ -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';

View File

@@ -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';