Skip to content

Commit 12685c4

Browse files
committed
feat(sdk-coin-sol): add dual ESM/CJS build for browser WASM support
Add dual ESM/CJS build support to sdk-coin-sol to enable browser compatibility with @bitgo/wasm-solana. Changes: - Update package.json with module, browser, exports fields - Update tsconfig.json to output CJS to dist/cjs - Add tsconfig.esm.json for ESM build - Add webpack alias for @bitgo/sdk-coin-sol This is required for browser bundles (bitgo-ui, bitgo-retail) to properly handle async WASM initialization. Ticket: BTC-3007
1 parent 147f7c6 commit 12685c4

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

modules/sdk-coin-sol/package.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
"name": "@bitgo/sdk-coin-sol",
33
"version": "7.12.0",
44
"description": "BitGo SDK coin library for Sol",
5-
"main": "./dist/src/index.js",
6-
"types": "./dist/src/index.d.ts",
5+
"main": "./dist/cjs/src/index.js",
6+
"module": "./dist/esm/index.js",
7+
"browser": "./dist/esm/index.js",
8+
"types": "./dist/cjs/src/index.d.ts",
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
"scripts": {
8-
"build": "yarn tsc --build --incremental --verbose .",
22+
"build": "npm run build:cjs && npm run build:esm",
23+
"build:cjs": "yarn tsc --build --incremental --verbose .",
24+
"build:esm": "yarn tsc --project tsconfig.esm.json",
925
"fmt": "prettier --write .",
1026
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
11-
"clean": "rm -r ./dist",
27+
"clean": "rm -rf ./dist",
1228
"lint": "eslint --quiet .",
1329
"prepare": "npm run build",
1430
"test": "npm run coverage",
@@ -60,6 +76,7 @@
6076
},
6177
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c",
6278
"files": [
63-
"dist"
79+
"dist/cjs",
80+
"dist/esm"
6481
]
6582
}
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/sdk-coin-sol/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
"strictPropertyInitialization": false,
77
"esModuleInterop": true,

0 commit comments

Comments
 (0)