Skip to content

Commit 411ce5d

Browse files
authored
Simplify polyfill setup + prepare for temporal release (#585)
* Move temporal polyfill to be global * Remove temporal imports * Fix types of polyfill * Use tsgo language service * Add polyfills to entrypoint * Remove types that are now shipped in ts
1 parent e285c19 commit 411ce5d

30 files changed

Lines changed: 13 additions & 64 deletions

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"*.ts": "$(capture).test.ts,$(capture).d.ts"
88
},
99
"oxc.typeAware": true,
10-
"js/ts.experimental.useTsgo": false,
11-
"js/ts.tsdk.path": "node_modules/typescript/lib",
10+
"js/ts.experimental.useTsgo": true,
1211

1312
"cSpell.language": "de,en",
1413
"editor.formatOnSaveMode": "modificationsIfAvailable",

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ FROM node:alpine
4040
RUN echo "RELEASE_IDENTIFIER=${RELEASE_IDENTIFIER:-debug}" >> /app/.env && \
4141
echo "BUILD_NUMBER=${BUILD_NUMBER:-0}" >> /app/.env
4242

43-
ENTRYPOINT ["node", "--env-file", "/app/.env", "src/app.ts"]
43+
ENTRYPOINT ["node", "--env-file", "/app/.env", "--require", "./src/polyfills.ts", "src/app.ts"]

package-lock.json

Lines changed: 1 addition & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@
6161
"lefthook": "^2.1.3",
6262
"oxfmt": "^0.36.0",
6363
"oxlint": "^1.51.0",
64-
"oxlint-tsgolint": "^0.16.0",
65-
"typescript": "^6.0.1-rc"
64+
"oxlint-tsgolint": "^0.16.0"
6665
},
6766
"engines": {
6867
"node": ">=25.6.1"

src/app.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import * as sentry from "@sentry/node";
44
import { readConfig, databasePath, args } from "#/service/config.ts";
55
import log from "#log";
66

7-
import { Temporal } from "@js-temporal/polyfill";
8-
import "#/polyfills.ts";
9-
107
import * as kysely from "#/storage/db/db.ts";
118

129
import type { ReactionHandler } from "#/handler/ReactionHandler.ts";
@@ -58,16 +55,6 @@ log.info(`Bot starting up...${release ? ` (release: ${release})` : ""}`);
5855

5956
const config = await readConfig();
6057

61-
// This polyfill requires that Temporal is already available in the runtime
62-
// We cannot add it in the polyfills.ts because that file is also used as --require argument for ts-node
63-
// TODO: Remove this once temporal is available in Node.js, see: https://github.com/nodejs/node/issues/57127
64-
if (typeof Date.prototype.toTemporalInstant !== "function") {
65-
// biome-ignore lint/suspicious/noExplicitAny: hack
66-
(Date.prototype as any).toTemporalInstant = function () {
67-
return Temporal.Instant.fromEpochMilliseconds(this.getTime());
68-
};
69-
}
70-
7158
if (config.sentry?.dsn) {
7259
sentry.init({
7360
dsn: config.sentry.dsn,

src/commands/lauscher.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type { ApplicationCommand } from "#/commands/command.ts";
1616
import type { BotContext } from "#/context.ts";
1717
import assertNever from "#/utils/assertNever.ts";
1818
import { getPlaybackStats, setUserRegistration, type TrackStat } from "#/service/lauscher.ts";
19-
import { Temporal } from "@js-temporal/polyfill";
2019
import { truncateToLength } from "#/utils/stringUtils.ts";
2120
import { chunkArray } from "#/utils/arrayUtils.ts";
2221
import { Vec2 } from "#/utils/math.ts";

src/commands/vote.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { parseArgs, type ParseArgsConfig } from "node:util";
22

33
import { cleanContent } from "discord.js";
4-
import { Temporal } from "@js-temporal/polyfill";
54

65
import type { MessageCommand } from "#/commands/command.ts";
76
import type { BotContext } from "#/context.ts";

src/commands/woisvote.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Temporal } from "@js-temporal/polyfill"; // TODO: Remove once Node.js ships temporal
2-
31
import {
42
type CommandInteraction,
53
type Message,

src/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
} from "discord.js";
1616
import { ChannelType } from "discord.js";
1717
import { SpotifyApi } from "@spotify/web-api-ts-sdk";
18-
import { Temporal } from "@js-temporal/polyfill";
1918

2019
import type { UserMapEntry } from "#/commands/aoc.ts";
2120
import { readConfig } from "#/service/config.ts";

src/handler/reaction/quoteHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
type GuildTextBasedChannel,
1010
hyperlink,
1111
} from "discord.js";
12-
import { Temporal } from "@js-temporal/polyfill";
1312

1413
import type { BotContext, QuoteConfig } from "#/context.ts";
1514
import type { ReactionHandler } from "../ReactionHandler.ts";

0 commit comments

Comments
 (0)