Skip to content

Commit 7a31daa

Browse files
committed
fix: support esm and cjs
1 parent 4dea066 commit 7a31daa

File tree

6 files changed

+70
-6
lines changed

6 files changed

+70
-6
lines changed

.github/workflows/npm-publish.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: "22.4.1"
20+
registry-url: "https://registry.npmjs.org/"
21+
22+
# - name: Install dependencies
23+
# run: npm install
24+
# working-directory: ./packages/youbet-sdk
25+
26+
- name: Build project
27+
run: npm run build
28+
working-directory: ./packages/youbet-sdk
29+
30+
- name: Publish package
31+
run: npm publish
32+
working-directory: ./packages/youbet-sdk
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"devDependencies": {
1212
"inquirer": "^9.3.1",
1313
"npm-run-all": "^4.1.5"
14+
},
15+
"dependencies": {
16+
"youbet-sdk": "^0.0.8"
1417
}
1518
}

packages/youbet-sdk/package.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
{
22
"name": "youbet-sdk",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "Awesome SDK it is.",
5-
"main": "./dist/main.js",
6-
"types": "./dist/main.d.ts",
5+
"main": "./dist/cjs/main.js",
6+
"module": "./dist/esm/index.js",
7+
"exports": {
8+
"import": "./dist/esm/main.js",
9+
"require": "./dist/cjs/main.js"
10+
},
11+
"types": "./dist/esm/main.d.ts",
712
"scripts": {
813
"clean": "rm -rf dist build package",
9-
"build": "tsc -p tsconfig.json",
10-
"build-watch": "tsc -p tsconfig.json --watch",
14+
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
15+
"build-watch": "tsc -p tsconfig.esm.json --watch",
1116
"build-all": "pnpm clean && pnpm build"
1217
},
1318
"repository": {
@@ -17,7 +22,8 @@
1722
"author": "[email protected]",
1823
"license": "ISC",
1924
"dependencies": {
20-
"ethers": "^6.13.1"
25+
"ethers": "^6.13.1",
26+
"youbet-sdk": "^0.0.8"
2127
},
2228
"devDependencies": {
2329
"@types/node": "^20.14.8",

packages/youbet-sdk/tsconfig.cjs.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./dist/cjs"
6+
}
7+
}

packages/youbet-sdk/tsconfig.esm.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"outDir": "./dist/esm"
6+
}
7+
}

pnpm-lock.yaml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)