build(node): migrate from CommonJS to ESM modules

This commit is contained in:
link2xt
2023-11-10 01:41:07 +00:00
parent 94dc65c1a2
commit b607f12b0e
20 changed files with 89 additions and 75 deletions

View File

@@ -1,6 +1,7 @@
const {execSync} = require('child_process')
const {existsSync} = require('fs')
const {join} = require('path')
import {execSync} from 'child_process'
import {existsSync} from 'fs'
import {join} from 'path'
import * as url from 'url'
const run = (cmd) => {
console.log('[i] running `' + cmd + '`')
@@ -16,7 +17,7 @@ if (process.env.USE_SYSTEM_LIBDELTACHAT === 'true') {
run('npm run install:prebuilds')
}
if (!existsSync(join(__dirname, '..', 'dist'))) {
if (!existsSync(join(url.fileURLToPath(new URL('.', import.meta.url)), '..', 'dist'))) {
console.log('[i] Didn\'t find already built typescript bindings. Trying to transpile them. If this fail, make sure typescript is installed ;)')
run('npm run build:bindings:ts')
}