Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

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 21, 2022
1 parent c5f7cd1 commit b5e2198
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 33 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
19 changes: 13 additions & 6 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 @@ -36,15 +42,16 @@
"superstruct": "^0.15.2"
},
"devDependencies": {
"@solana/spl-token": "0.1.3",
"esbuild": "^0.14.11",
"esbuild-jest": "^0.5.0",
"jest": "^27.4.7",
"typescript": "^4.5.4",
"@solana/spl-token": "0.1.3"
"rimraf": "^3.0.2",
"typescript": "^4.5.4"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "esbuild-jest"
}
}
}
}
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"
}
}
44 changes: 43 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,28 @@
semver "^6.3.0"
source-map "^0.5.0"

"@babel/core@^7.12.17", "@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0":
"@babel/core@^7.12.17":
version "7.16.10"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.16.10.tgz#ebd034f8e7ac2b6bfcdaa83a161141a646f74b50"
integrity sha512-pbiIdZbCiMx/MM6toR+OfXarYix3uz0oVsnNtfdAGTcCTu3w/JGF8JhirevXLBJUu0WguSZI12qpKnx7EeMyLA==
dependencies:
"@babel/code-frame" "^7.16.7"
"@babel/generator" "^7.16.8"
"@babel/helper-compilation-targets" "^7.16.7"
"@babel/helper-module-transforms" "^7.16.7"
"@babel/helpers" "^7.16.7"
"@babel/parser" "^7.16.10"
"@babel/template" "^7.16.7"
"@babel/traverse" "^7.16.10"
"@babel/types" "^7.16.8"
convert-source-map "^1.7.0"
debug "^4.1.0"
gensync "^1.0.0-beta.2"
json5 "^2.1.2"
semver "^6.3.0"
source-map "^0.5.0"

"@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.16.7.tgz#db990f931f6d40cb9b87a0dc7d2adc749f1dcbcf"
integrity sha512-aeLaqcqThRNZYmbMqtulsetOQZ/5gbR/dWruUCJcpas4Qoyy+QeagfDsPdMrqwsPRDNxJvBlRiZxxX7THO7qtA==
Expand Down Expand Up @@ -537,6 +558,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.8.tgz#61c243a3875f7d0b0962b0543a33ece6ff2f1f17"
integrity sha512-i7jDUfrVBWc+7OKcBzEe5n7fbv3i2fWtxKzzCvOjnzSxMfWMigAhtfJ7qzZNGFNMsCCd67+uz553dYKWXPvCKw==

"@babel/parser@^7.16.10":
version "7.16.10"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.10.tgz#aba1b1cb9696a24a19f59c41af9cf17d1c716a88"
integrity sha512-Sm/S9Or6nN8uiFsQU1yodyDW3MWXQhFeqzMPM+t8MJjM+pLsnFVxFZzkpXKvUXh+Gz9cbMoYYs484+Jw/NTEFQ==

"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.13.12":
version "7.13.12"
resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.13.12.tgz#a3484d84d0b549f3fc916b99ee4783f26fabad2a"
Expand Down Expand Up @@ -1441,6 +1467,22 @@
debug "^4.1.0"
globals "^11.1.0"

"@babel/traverse@^7.16.10":
version "7.16.10"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.16.10.tgz#448f940defbe95b5a8029975b051f75993e8239f"
integrity sha512-yzuaYXoRJBGMlBhsMJoUW7G1UmSb/eXr/JHYM/MsOJgavJibLwASijW7oXBdw3NQ6T0bW7Ty5P/VarOs9cHmqw==
dependencies:
"@babel/code-frame" "^7.16.7"
"@babel/generator" "^7.16.8"
"@babel/helper-environment-visitor" "^7.16.7"
"@babel/helper-function-name" "^7.16.7"
"@babel/helper-hoist-variables" "^7.16.7"
"@babel/helper-split-export-declaration" "^7.16.7"
"@babel/parser" "^7.16.10"
"@babel/types" "^7.16.8"
debug "^4.1.0"
globals "^11.1.0"

"@babel/traverse@^7.16.7", "@babel/traverse@^7.7.2":
version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.16.8.tgz#bab2f2b09a5fe8a8d9cad22cbfe3ba1d126fef9c"
Expand Down

0 comments on commit b5e2198

Please sign in to comment.