Fase 1a: fix interop CJS/ESM del driver mongodb v3

mongodb v3.x es CommonJS; el import nombrado ESM (import { MongoClient }) no lo
resuelve el cjs-lexer de Node en runtime (SyntaxError al arrancar dist). Tomo los
valores del default export (mongodb.MongoClient / mongodb.ObjectId). Verificado
importando dist/*.js con node (no solo compilando).
This commit is contained in:
vjrj 2026-07-13 01:02:15 +02:00
parent a5ba2cdcf1
commit 6163deecf3
2 changed files with 9 additions and 3 deletions

View file

@ -1,9 +1,13 @@
import { MongoClient, type Collection, type Db } from 'mongodb';
import mongodb, { type Collection, type Db } from 'mongodb';
import type { Config } from './config.js';
// mongodb v3.x is CommonJS; named ESM imports of its values aren't resolvable by
// Node's cjs-lexer, so pull runtime values off the default (module.exports).
const { MongoClient } = mongodb;
import type { NotificationDoc, SendRecord, UserDoc } from './types.js';
export interface Repos {
client: MongoClient;
client: mongodb.MongoClient;
db: Db;
notifications: Collection<NotificationDoc>;
users: Collection<UserDoc>;

View file

@ -1,5 +1,7 @@
import { ObjectId } from 'mongodb';
import mongodb from 'mongodb';
import type { Config } from './config.js';
// mongodb v3.x is CommonJS — take ObjectId off the default export (see db.ts).
const { ObjectId } = mongodb;
import type { Repos } from './db.js';
import type { FcmClient } from './fcm.js';
import type { Mailer } from './mailer.js';