Skip to content

Commit c6d544b

Browse files
authored
Merge pull request #7919 from BitGo/BTC-2936.utxo-ord-esm
feat(utxo-ord): add ESM support and update webpack configuration
2 parents 87bc628 + 8daafab commit c6d544b

5 files changed

Lines changed: 44 additions & 7 deletions

File tree

commitlint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
'scope-enum': async () => [
1313
2,
1414
'always',
15-
(await readdir('modules')).concat('root', 'deps', 'scripts', 'examples'),
15+
(await readdir('modules')).concat('root', 'deps', 'scripts', 'examples', 'webpack'),
1616
],
1717
'footer-max-line-length': [0, 'always', Infinity],
1818
'references-empty': [2, 'never'],

modules/utxo-ord/package.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
{
22
"name": "@bitgo/utxo-ord",
33
"description": "Utilities for building ordinals with BitGo utxo-lib",
4-
"main": "./dist/src/index.js",
5-
"types": "./dist/src/index.d.ts",
4+
"main": "./dist/cjs/src/index.js",
5+
"module": "./dist/esm/index.js",
6+
"browser": "./dist/esm/index.js",
7+
"types": "./dist/cjs/src/index.d.ts",
68
"version": "1.22.22",
9+
"exports": {
10+
".": {
11+
"import": {
12+
"types": "./dist/esm/index.d.ts",
13+
"default": "./dist/esm/index.js"
14+
},
15+
"require": {
16+
"types": "./dist/cjs/src/index.d.ts",
17+
"default": "./dist/cjs/src/index.js"
18+
}
19+
}
20+
},
721
"files": [
8-
"dist/**/*"
22+
"dist/cjs",
23+
"dist/esm"
924
],
1025
"keywords": [
1126
"bitgo",
@@ -16,7 +31,9 @@
1631
],
1732
"scripts": {
1833
"prepare": "npm run build",
19-
"build": "yarn tsc --build --incremental --verbose .",
34+
"build": "npm run build:cjs && npm run build:esm",
35+
"build:cjs": "yarn tsc --build --incremental --verbose .",
36+
"build:esm": "yarn tsc --project tsconfig.esm.json",
2037
"lint": "eslint --quiet .",
2138
"unit-test": "mocha --recursive test",
2239
"fmt": "prettier --write '{src,test}/**/*.{ts,js}'",

modules/utxo-ord/tsconfig.esm.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist/esm",
5+
"rootDir": "./src",
6+
"module": "ES2020",
7+
"target": "ES2020",
8+
"moduleResolution": "bundler",
9+
"lib": ["ES2020", "DOM"],
10+
"declaration": true,
11+
"declarationMap": true,
12+
"skipLibCheck": true
13+
},
14+
"include": ["src/**/*"],
15+
"exclude": ["node_modules", "test", "dist"],
16+
"references": []
17+
}

modules/utxo-ord/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "./dist",
4+
"outDir": "./dist/cjs",
55
"rootDir": ".",
66
"typeRoots": ["./node_modules/@types", "../../node_modules/@types"],
77
"allowJs": false,

webpack/bitgojs.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ module.exports = {
1515
// use the default version here since we're webpacking ourselves
1616
'@bitgo/sdk-api': path.resolve('../sdk-api/dist/src/index.js'),
1717
async: path.resolve('../../node_modules/async/index.js'),
18-
// Force ESM version of wasm-utxo for browser bundles (has proper wasm import)
18+
// Force ESM versions for browser bundles - required for proper WASM initialization.
19+
// Note: We can't use global `conditionNames: ['browser', 'import', ...]` because
20+
// third-party packages like @solana/spl-token and @bufbuild/protobuf have broken ESM builds.
1921
'@bitgo/wasm-utxo': path.resolve('../../node_modules/@bitgo/wasm-utxo/dist/esm/js/index.js'),
22+
'@bitgo/utxo-ord': path.resolve('../utxo-ord/dist/esm/index.js'),
2023
},
2124
fallback: {
2225
constants: false,

0 commit comments

Comments
 (0)