From f30c9273468b16b132cca0ccd57759e847ab8051 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 16 Jan 2026 11:56:09 +0100 Subject: [PATCH 1/3] feat(utxo-ord): add ESM support Configure ESM build alongside existing CommonJS build, updating package.json exports field to support both module systems. The package can now be used with both `import` and `require` statements. Issue: BTC-2936 Co-authored-by: llm-git --- modules/utxo-ord/package.json | 25 +++++++++++++++++++++---- modules/utxo-ord/tsconfig.esm.json | 17 +++++++++++++++++ modules/utxo-ord/tsconfig.json | 2 +- 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 modules/utxo-ord/tsconfig.esm.json diff --git a/modules/utxo-ord/package.json b/modules/utxo-ord/package.json index 1651359816..10eae025bc 100644 --- a/modules/utxo-ord/package.json +++ b/modules/utxo-ord/package.json @@ -1,11 +1,26 @@ { "name": "@bitgo/utxo-ord", "description": "Utilities for building ordinals with BitGo utxo-lib", - "main": "./dist/src/index.js", - "types": "./dist/src/index.d.ts", + "main": "./dist/cjs/src/index.js", + "module": "./dist/esm/index.js", + "browser": "./dist/esm/index.js", + "types": "./dist/cjs/src/index.d.ts", "version": "1.22.22", + "exports": { + ".": { + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/cjs/src/index.d.ts", + "default": "./dist/cjs/src/index.js" + } + } + }, "files": [ - "dist/**/*" + "dist/cjs", + "dist/esm" ], "keywords": [ "bitgo", @@ -16,7 +31,9 @@ ], "scripts": { "prepare": "npm run build", - "build": "yarn tsc --build --incremental --verbose .", + "build": "npm run build:cjs && npm run build:esm", + "build:cjs": "yarn tsc --build --incremental --verbose .", + "build:esm": "yarn tsc --project tsconfig.esm.json", "lint": "eslint --quiet .", "unit-test": "mocha --recursive test", "fmt": "prettier --write '{src,test}/**/*.{ts,js}'", diff --git a/modules/utxo-ord/tsconfig.esm.json b/modules/utxo-ord/tsconfig.esm.json new file mode 100644 index 0000000000..17f39ab0f3 --- /dev/null +++ b/modules/utxo-ord/tsconfig.esm.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/esm", + "rootDir": "./src", + "module": "ES2020", + "target": "ES2020", + "moduleResolution": "bundler", + "lib": ["ES2020", "DOM"], + "declaration": true, + "declarationMap": true, + "skipLibCheck": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "test", "dist"], + "references": [] +} diff --git a/modules/utxo-ord/tsconfig.json b/modules/utxo-ord/tsconfig.json index d589c2e2a3..877b19b0ca 100644 --- a/modules/utxo-ord/tsconfig.json +++ b/modules/utxo-ord/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "./dist", + "outDir": "./dist/cjs", "rootDir": ".", "typeRoots": ["./node_modules/@types", "../../node_modules/@types"], "allowJs": false, From dea95c3d009fc6bf9bc9452361040e135d0cc3e5 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 16 Jan 2026 12:19:05 +0100 Subject: [PATCH 2/3] feat(webpack): add webpack scope to commitlint Add webpack to the list of valid scopes in commitlint configuration. Issue: BTC-2936 Co-authored-by: llm-git --- commitlint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitlint.config.js b/commitlint.config.js index 9e3ff39289..32f2d0816b 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -12,7 +12,7 @@ module.exports = { 'scope-enum': async () => [ 2, 'always', - (await readdir('modules')).concat('root', 'deps', 'scripts', 'examples'), + (await readdir('modules')).concat('root', 'deps', 'scripts', 'examples', 'webpack'), ], 'footer-max-line-length': [0, 'always', Infinity], 'references-empty': [2, 'never'], From 8daafab2fd4a0484b7016251e283fe9ba7ffa451 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 16 Jan 2026 12:00:46 +0100 Subject: [PATCH 3/3] feat(webpack): force ESM version of utxo-ord for browser bundles Ensures proper import of wasm-utxo in browser environments by using the ESM version of utxo-ord. Issue: BTC-2936 Co-authored-by: llm-git --- webpack/bitgojs.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webpack/bitgojs.config.js b/webpack/bitgojs.config.js index 0c226c2bb3..cafdef7b5b 100644 --- a/webpack/bitgojs.config.js +++ b/webpack/bitgojs.config.js @@ -15,8 +15,11 @@ module.exports = { // use the default version here since we're webpacking ourselves '@bitgo/sdk-api': path.resolve('../sdk-api/dist/src/index.js'), async: path.resolve('../../node_modules/async/index.js'), - // Force ESM version of wasm-utxo for browser bundles (has proper wasm import) + // Force ESM versions for browser bundles - required for proper WASM initialization. + // Note: We can't use global `conditionNames: ['browser', 'import', ...]` because + // third-party packages like @solana/spl-token and @bufbuild/protobuf have broken ESM builds. '@bitgo/wasm-utxo': path.resolve('../../node_modules/@bitgo/wasm-utxo/dist/esm/js/index.js'), + '@bitgo/utxo-ord': path.resolve('../utxo-ord/dist/esm/index.js'), }, fallback: { constants: false,