Skip to content

Commit

Permalink
feat: add in build for both cjs/esm
Browse files Browse the repository at this point in the history
  • Loading branch information
willfarrell committed Mar 19, 2022
1 parent c2bb404 commit f2e4df7
Show file tree
Hide file tree
Showing 37 changed files with 286 additions and 48 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [ 14.x]
node-version: [14.x]

steps:
- name: Checkout repository
Expand All @@ -33,11 +33,10 @@ jobs:
run: |
npm install
- name: Transpile to CommonJS for Node.js ${{ matrix.node-version }}
- name: Transpile for Node.js ${{ matrix.node-version }}
run: |
./node_modules/.bin/lerna exec --bail --concurrency 2 -- rm index.cjs
./node_modules/.bin/lerna exec --bail --concurrency 2 -- rm index.cjs.map
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.config.json --source-maps false index.js --out-file index.js
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.cjs.config.json --source-maps false index.js --out-file index.cjs
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.esm.config.json --source-maps false index.js --out-file index.js
- name: Pre-Release
if: contains(${{GITHUB_REF}}, 'alpha') || contains(${{GITHUB_REF}}, 'beta') || contains(${{GITHUB_REF}}, 'rc')
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Unit Tests
on:
push:
branches:
- "main"
- 'main'
tags-ignore:
- "*.*.*"
- '*.*.*'
pull_request:

jobs:
Expand All @@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
node-version: [14.x, 16.x]
type: [cjs, esm]

steps:
- name: Checkout repository
Expand All @@ -33,11 +34,13 @@ jobs:
env:
CI: true

- name: Transpile for Node.js ${{ matrix.node-version }}
- name: Transpile for Node.js ${{ matrix.node-version }} (${{ metrix.type}})
run: |
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.config.json index.js --out-file index.js
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.${{ metrix.type}}.config.json index.js --out-file index.js
- name: Unit tests
run: npm run test:packages:unit
run: |
cat packages/core/index.js
npm run test:packages:unit
env:
CI: true
1 change: 1 addition & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
'**/*.{json,yml}': ['prettier --write'],
'**/*.js': ['prettier --write', 'ts-standard --fix']
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"pre-commit": "npm run test:lint",
"install": "lerna bootstrap",
"test": "npm run test:lint && npm run test:packages",
"test:lint": "ts-standard --fix",
"test:lint": "lint-staged",
"test:lint:ci": "ts-standard",
"test:unit": "cd packages/$PACKAGE && c8 npm run test:unit",
"test:benchmark": "cd packages/$PACKAGE && npm run test:benchmark",
Expand Down
9 changes: 8 additions & 1 deletion packages/cloudwatch-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/do-not-wait-for-empty-event-loop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/error-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/event-normalizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-content-encoding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-content-negotiation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-cors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-error-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-event-normalizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-header-normalizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-json-body-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-multipart-body-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-partial-response/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-response-serializer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion packages/http-security-headers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
"publishConfig": {
"access": "public"
},
"exports": "./index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
}
},
"types": "index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
Expand Down
Loading

0 comments on commit f2e4df7

Please sign in to comment.