Skip to content

Правка exports #3

@Despane

Description

@Despane

Добрый день.
Если проект на common js, то библиотека просто не работает в runtime.
Хотя бандл подходящий есть, но в exports это не указано.
Приходится или пачить ее через pnpm или делать подобные танцы

import type { B24Hook } from '@bitrix24/b24jssdk'
import { Injectable, OnModuleInit } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { BatchArrayResult, BatchItem, BatchRawResult, BatchResult } from './types'
import { arrayToDict, fromEntries, isBatchArray, unwrapBitrixResult } from './utils'

@Injectable()
export class BitrixAdapter implements OnModuleInit {
	private client: B24Hook
	constructor(private readonly config: ConfigService) {}
	async onModuleInit() {
		const bitrix = await eval('import("@bitrix24/b24jssdk")')
		const { B24Hook } = bitrix
		const b24Url = this.config.getOrThrow<string>('B24_URL')
		const userId = this.config.getOrThrow<number>('B24_USER_ID')
		const secret = this.config.getOrThrow<string>('B24_SECRET')
		this.client = new B24Hook({ b24Url, userId, secret })
	}

Вот экспорт в package.json у библиотеки

  "exports": {
    "./package.json": "./package.json",
    ".": {
      "types": "./dist/esm/index.d.mts",
      "import": "./dist/esm/index.mjs"
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions