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:
parent
a5ba2cdcf1
commit
6163deecf3
2 changed files with 9 additions and 3 deletions
|
|
@ -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>;
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue