Skip to content

Commit

Permalink
build: generate commonjs and esmodules builds
Browse files Browse the repository at this point in the history
  • Loading branch information
johnrees committed Jan 15, 2022
1 parent 44dfff5 commit d78abee
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 29 deletions.
13 changes: 13 additions & 0 deletions packages/governance-sdk/bin/after-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

cat >lib/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >lib/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
13 changes: 10 additions & 3 deletions packages/governance-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"author": "Solana Maintainers <[email protected]>",
"homepage": "https://github.com/solana-labs/oyster/blob/main/packages/governance-sdk/README.md",
"license": "MIT",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "lib/cjs/index.js",
"module": "lib/mjs/index.js",
"types": "lib/mjs/index.d.ts",
"source": "src/index.ts",
"exports": {
"import": "./lib/mjs/index.js",
"require": "./lib/cjs/index.js"
},
"directories": {
"lib": "lib"
},
Expand All @@ -19,7 +25,7 @@
},
"sideEffects": false,
"scripts": {
"build": "tsc",
"build": "rimraf lib && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && ./bin/after-build.sh",
"test": "jest",
"start": "npm-run-all --parallel watch",
"watch": "tsc --watch"
Expand All @@ -40,6 +46,7 @@
"esbuild": "^0.14.11",
"esbuild-jest": "^0.5.0",
"jest": "^27.4.7",
"rimraf": "^3.0.2",
"typescript": "^4.5.4"
},
"jest": {
Expand Down
20 changes: 20 additions & 0 deletions packages/governance-sdk/tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["esnext"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"pretty": true,
"resolveJsonModule": true,
"rootDir": "./src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true
},
"include": ["src"]
}
8 changes: 8 additions & 0 deletions packages/governance-sdk/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "lib/cjs",
"target": "es2015"
}
}
32 changes: 6 additions & 26 deletions packages/governance-sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"target": "es6",
"lib": [
"es2019"
],
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"outDir": "./lib",
"pretty": true,
"resolveJsonModule": true,
"rootDir": "./src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
},
"include": [
"src"
],
"exclude": [
"node_modules",
]
}
"module": "esnext",
"outDir": "lib/mjs",
"target": "esnext"
}
}

0 comments on commit d78abee

Please sign in to comment.