diff --git a/packages/governance-sdk/bin/after-build.sh b/packages/governance-sdk/bin/after-build.sh new file mode 100755 index 00000000..91fa6cc4 --- /dev/null +++ b/packages/governance-sdk/bin/after-build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cat >lib/cjs/package.json <lib/mjs/package.json <", "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" }, @@ -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" @@ -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" } } -} \ No newline at end of file +} diff --git a/packages/governance-sdk/tsconfig-base.json b/packages/governance-sdk/tsconfig-base.json new file mode 100644 index 00000000..af9078b7 --- /dev/null +++ b/packages/governance-sdk/tsconfig-base.json @@ -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"] +} diff --git a/packages/governance-sdk/tsconfig.cjs.json b/packages/governance-sdk/tsconfig.cjs.json new file mode 100644 index 00000000..9ad1b33e --- /dev/null +++ b/packages/governance-sdk/tsconfig.cjs.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig-base.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "lib/cjs", + "target": "es2015" + } +} diff --git a/packages/governance-sdk/tsconfig.json b/packages/governance-sdk/tsconfig.json index 60e1a5d4..b02d817a 100644 --- a/packages/governance-sdk/tsconfig.json +++ b/packages/governance-sdk/tsconfig.json @@ -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", - ] -} \ No newline at end of file + "module": "esnext", + "outDir": "lib/mjs", + "target": "esnext" + } +} diff --git a/yarn.lock b/yarn.lock index 7aba1605..007a1305 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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== @@ -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" @@ -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"