Skip to content

Commit dae84b2

Browse files
committed
chore: configure project for ESM support
1 parent 968cb7d commit dae84b2

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "",
66
"version": "1.0.0",
77
"private": true,
8+
"type": "module",
89
"scripts": {
910
"build": "tsc",
1011
"start": "npm run build && node dist/index.js",

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { fetchLatestQuestions } from './services/stackoverflow';
2-
import { formatBody } from './utils/htmlFormatter';
3-
import { sendQuestion } from './services/notifier';
4-
import { loadSentIds, saveSentIds } from './services/persistence';
1+
import { fetchLatestQuestions } from './services/stackoverflow.js';
2+
import { formatBody } from './utils/htmlFormatter.js';
3+
import { sendQuestion } from './services/notifier.js';
4+
import { loadSentIds, saveSentIds } from './services/persistence.js';
55

66
const sent = await loadSentIds();
77
const questions = await fetchLatestQuestions();

src/services/notifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { WebhookClient, EmbedBuilder } from "discord.js";
22

3-
import { Question } from "./stackoverflow";
4-
import { env } from "../config/env";
3+
import { Question } from "./stackoverflow.js";
4+
import { env } from "../config/env.js";
55

66
const webhook = new WebhookClient({
77
id: env.DISCORD_WEBHOOK_ID,

src/services/persistence.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import fs from 'node:fs/promises';
22
import cp from 'node:child_process';
33
import path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
48

59
const DATA_FILE = path.resolve(__dirname, '../../data/sentIds.json');
610

src/services/stackoverflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { env } from "../config/env";
1+
import { env } from "../config/env.js";
22

33
export interface Question {
44
question_id: number;

0 commit comments

Comments
 (0)