Skip to content

Commit

Permalink
Esm Build (#64)
Browse files Browse the repository at this point in the history
* build esm and cjs

* use github tag on publish
  • Loading branch information
bh2smith authored Sep 19, 2024
1 parent ab2f785 commit f284747
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package
name: NPM Publish

on:
release:
Expand All @@ -16,8 +13,13 @@ jobs:
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: yarn --frozen-lockfile
- run: yarn build
- run: npm publish --access public
- name: Build & Set Package Version to Tag
run: |
yarn --frozen-lockfile
yarn build
VERSION=${GITHUB_REF#refs/tags/}
npm version $VERSION --no-git-tag-version
- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.DUNE_NPM_TOKEN}}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"dist/**/*"
],
"scripts": {
"build": "tsc",
"build": "rm -rf dist/* && yarn build:esm && yarn build:cjs",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"test": "jest",
"fmt": "prettier --write \"./**/*.ts\"",
"lint": "eslint ./src"
Expand Down
7 changes: 7 additions & 0 deletions 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",
}
}
8 changes: 8 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"outDir": "dist/esm",
}
}
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"declaration": true,
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"],
Expand Down

0 comments on commit f284747

Please sign in to comment.