const fs = require('fs')

const package = JSON.parse(fs.readFileSync('./node_modules/bignumber.js/package.json', 'utf8'))
package.exports['./bignumber'] = './bignumber.js'
fs.writeFileSync('./node_modules/bignumber.js/package.json', JSON.stringify(package, null, 2))
console.log('Fixed bignumber.js package.json')

const f1 = './node_modules/langchain/dist/document_loaders/fs/unstructured.d.ts'
const f2 = './node_modules/langchain/dist/document_loaders/fs/directory.d.ts'
fs.writeFileSync(
    f1,
    fs.readFileSync(f1, 'utf8').toString().replaceAll('/// <reference types="node" resolution-mode="require"/>', '')
)
fs.writeFileSync(
    f2,
    fs.readFileSync(f2, 'utf8').toString().replaceAll('/// <reference types="node" resolution-mode="require"/>', '')
)