Skip to content

Commit

Permalink
fix: import compatibility with ts-node/esm
Browse files Browse the repository at this point in the history
  • Loading branch information
teidesu committed Dec 2, 2023
1 parent 392ff5a commit 0b2ae3a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
2 changes: 2 additions & 0 deletions e2e/cjs/utils.js
@@ -1,4 +1,5 @@
const { MemoryStorage } = require('@mtcute/core/storage/memory.js')
const { LogManager } = require('@mtcute/core/utils.js')

exports.getApiParams = () => {
if (!process.env.API_ID || !process.env.API_HASH) {
Expand All @@ -10,5 +11,6 @@ exports.getApiParams = () => {
apiHash: process.env.API_HASH,
testMode: true,
storage: new MemoryStorage(),
logLevel: LogManager.DEBUG,
}
}
2 changes: 2 additions & 0 deletions e2e/esm/utils.js
@@ -1,4 +1,5 @@
import { MemoryStorage } from '@mtcute/core/storage/memory.js'
import { LogManager } from '@mtcute/core/utils.js'

export const getApiParams = () => {
if (!process.env.API_ID || !process.env.API_HASH) {
Expand All @@ -10,5 +11,6 @@ export const getApiParams = () => {
apiHash: process.env.API_HASH,
testMode: true,
storage: new MemoryStorage(),
logLevel: LogManager.DEBUG,
}
}
1 change: 0 additions & 1 deletion e2e/ts/run-esm.cjs
@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-globals */
const cp = require('child_process')

const { fixForEsm } = require('./build-esm.cjs')
Expand Down
2 changes: 2 additions & 0 deletions e2e/ts/utils.ts
@@ -1,5 +1,6 @@
import { BaseTelegramClientOptions } from '@mtcute/core'
import { MemoryStorage } from '@mtcute/core/storage/memory.js'
import { LogManager } from '@mtcute/core/utils.js'

export const getApiParams = (): BaseTelegramClientOptions => {
if (!process.env.API_ID || !process.env.API_HASH) {
Expand All @@ -11,5 +12,6 @@ export const getApiParams = (): BaseTelegramClientOptions => {
apiHash: process.env.API_HASH,
testMode: true,
storage: new MemoryStorage(),
logLevel: LogManager.DEBUG,
}
}
6 changes: 3 additions & 3 deletions packages/client/package.json
Expand Up @@ -18,9 +18,9 @@
"import": "./esm/index.js",
"require": "./cjs/index.js"
},
"./methods/*.js": {
"import": "./esm/methods/*.js",
"require": "./cjs/methods/*.js"
"./methods/*": {
"import": "./esm/methods/*",
"require": "./cjs/methods/*"
},
"./utils.js": {
"import": "./esm/utils/index.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/core/package.json
Expand Up @@ -27,17 +27,17 @@
"import": "./esm/utils/index.js",
"require": "./cjs/utils/index.js"
},
"./utils/crypto/*.js": {
"import": "./esm/utils/crypto/*.js",
"require": "./cjs/utils/crypto/*.js"
"./utils/crypto/*": {
"import": "./esm/utils/crypto/*",
"require": "./cjs/utils/crypto/*"
},
"./network/transports/*.js": {
"import": "./esm/network/transports/*.js",
"require": "./cjs/network/transports/*.js"
"./network/transports/*": {
"import": "./esm/network/transports/*",
"require": "./cjs/network/transports/*"
},
"./storage/*.js": {
"import": "./esm/storage/*.js",
"require": "./cjs/storage/*.js"
"./storage/*": {
"import": "./esm/storage/*",
"require": "./cjs/storage/*"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions packages/i18n/package.json
Expand Up @@ -16,9 +16,9 @@
"import": "./esm/index.js",
"require": "./cjs/index.js"
},
"./plurals/*.js": {
"import": "./esm/plurals/*.js",
"require": "./cjs/plurals/*.js"
"./plurals/*": {
"import": "./esm/plurals/*",
"require": "./cjs/plurals/*"
}
}
},
Expand Down

0 comments on commit 0b2ae3a

Please sign in to comment.