@mtcute/core/client.js isn't resolved under module: esnext #28

Closed
opened 2024-04-06 18:20:44 +03:00 by teidesu · 0 comments
teidesu commented 2024-04-06 18:20:44 +03:00 (Migrated from github.com)

/subj. was reported in tg chat

To Reproduce

create a node.js project, put "module": "esnext" in tsconfig.json, try compiling this code:

import { TelegramClient } from '@mtcute/node'

const tg = new TelegramClient({})
tg.exportSession() // <- error, `exportSession` not found

Expected behavior

works fine

Logs

n/a

Environment

  • OS: n/a
  • Runtime: node any, ts
  • mtcute version: 0.10.0

Additional context
this happens because ts can't resolve @mtcute/core/client.js under esnext, because it ignores exports field in package.json:

image

we should probably also generate the client.js/utils.js/etc. files at root dir based on our package.json exports in build script, but this is blocked by #27

<!-- describe the bug --> /subj. was reported in tg chat ## To Reproduce create a node.js project, put `"module": "esnext"` in tsconfig.json, try compiling this code: ```ts import { TelegramClient } from '@mtcute/node' const tg = new TelegramClient({}) tg.exportSession() // <- error, `exportSession` not found ``` ## Expected behavior works fine ## Logs n/a ## Environment - OS: n/a - Runtime: node any, ts - mtcute version: 0.10.0 **Additional context** this happens because ts can't resolve `@mtcute/core/client.js` under esnext, because it ignores `exports` field in package.json: <img width="743" alt="image" src="https://github.com/mtcute/mtcute/assets/86301490/edb0bf8e-9070-413f-8e7f-87d43dbeb9ca"> we should probably also generate the client.js/utils.js/etc. files at root dir based on our package.json exports in build script, but this is blocked by #27
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: teidesu/mtcute#28
No description provided.