Skip to content

Commit

Permalink
fix: support esm and cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
wfnuser committed Jul 27, 2024
1 parent 4dea066 commit 7a31daa
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to npm

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "22.4.1"
registry-url: "https://registry.npmjs.org/"

# - name: Install dependencies
# run: npm install
# working-directory: ./packages/youbet-sdk

- name: Build project
run: npm run build
working-directory: ./packages/youbet-sdk

- name: Publish package
run: npm publish
working-directory: ./packages/youbet-sdk
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"devDependencies": {
"inquirer": "^9.3.1",
"npm-run-all": "^4.1.5"
},
"dependencies": {
"youbet-sdk": "^0.0.8"
}
}
18 changes: 12 additions & 6 deletions packages/youbet-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"name": "youbet-sdk",
"version": "0.0.7",
"version": "0.0.8",
"description": "Awesome SDK it is.",
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"main": "./dist/cjs/main.js",
"module": "./dist/esm/index.js",
"exports": {
"import": "./dist/esm/main.js",
"require": "./dist/cjs/main.js"
},
"types": "./dist/esm/main.d.ts",
"scripts": {
"clean": "rm -rf dist build package",
"build": "tsc -p tsconfig.json",
"build-watch": "tsc -p tsconfig.json --watch",
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
"build-watch": "tsc -p tsconfig.esm.json --watch",
"build-all": "pnpm clean && pnpm build"
},
"repository": {
Expand All @@ -17,7 +22,8 @@
"author": "[email protected]",
"license": "ISC",
"dependencies": {
"ethers": "^6.13.1"
"ethers": "^6.13.1",
"youbet-sdk": "^0.0.8"
},
"devDependencies": {
"@types/node": "^20.14.8",
Expand Down
7 changes: 7 additions & 0 deletions packages/youbet-sdk/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "./dist/cjs"
}
}
7 changes: 7 additions & 0 deletions packages/youbet-sdk/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"outDir": "./dist/esm"
}
}
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a31daa

Please sign in to comment.