Skip to content

Commit

Permalink
create build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci committed Jul 5, 2024
1 parent 4d02043 commit f740500
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 18 deletions.
4 changes: 1 addition & 3 deletions executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"scripts": {
"clean": "rm -rf pkg dist",
"wasm": "yarn clean && wasm-pack build --target web --out-dir pkg && scripts/pack-wasm.cjs",
"build": "yarn wasm && yarn build:cjs && yarn build:esm",
"build:cjs": "swc ./pkg -C module.type=commonjs -d dist/cjs --copy-files --strip-leading-paths && cp pkg/chopsticks_executor.d.ts dist/cjs/index.d.ts && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build:esm": "swc ./pkg -C module.type=es6 -d dist/esm --copy-files --strip-leading-paths && cp pkg/chopsticks_executor.d.ts dist/esm/index.d.ts && echo '{\"type\": \"module\"}' > dist/esm/package.json"
"build": "yarn wasm && ./package.sh"
},
"dependencies": {
"@polkadot/util": "^12.6.2",
Expand Down
17 changes: 17 additions & 0 deletions executor/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

## Build CJS
yarn swc ./pkg -C module.type=commonjs -d dist/cjs --copy-files --strip-leading-paths
## Build ESM
yarn swc ./pkg -C module.type=es6 -d dist/esm --copy-files --strip-leading-paths

## Copy types
cp pkg/chopsticks_executor.d.ts dist/cjs/index.d.ts
cp pkg/chopsticks_executor.d.ts dist/esm/index.d.ts

## Make package CJS
echo '{ "type": "commonjs" }' > dist/cjs/package.json
## Make package ESM
echo '{ "type": "module" }' > dist/esm/package.json
15 changes: 15 additions & 0 deletions package-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

## Build CJS
yarn swc ./src --config-file $(dirname "$0")/.cjsswcrc -d dist/cjs --copy-files --strip-leading-paths
## Build ESM
yarn swc ./src --config-file $(dirname "$0")/.esmswcrc -d dist/esm --copy-files --strip-leading-paths

## Build types
yarn tsc -p tsconfig.json --declarationDir dist/cjs
yarn tsc -p tsconfig.json --declarationDir dist/esm

## Make package CJS
echo '{ "type": "commonjs" }' > dist/cjs/package.json
4 changes: 1 addition & 3 deletions packages/chopsticks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"type": "module",
"scripts": {
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"build": "yarn clean && yarn build:cjs && yarn build:esm",
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --copy-files --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --copy-files --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/esm",
"build": "yarn clean && ../../package-build.sh",
"docs:prep": "typedoc",
"depcheck": "npx depcheck --ignore-patterns='*.test.ts'"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"type": "module",
"scripts": {
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"build": "yarn clean && yarn build:cjs && yarn build:esm",
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/esm",
"build": "yarn clean && ../../package-build.sh",
"docs:prep": "typedoc",
"depcheck": "npx depcheck --ignores=pino-pretty"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"type": "module",
"scripts": {
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"build": "yarn clean && yarn build:cjs && yarn build:esm",
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/esm",
"build": "yarn clean && ../../package-build.sh",
"depcheck": "npx depcheck"
},
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"type": "module",
"scripts": {
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"build": "yarn clean && yarn build:cjs && yarn build:esm",
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/esm",
"build": "yarn clean && ../../package-build.sh",
"depcheck": "npx depcheck"
},
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"type": "module",
"scripts": {
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"build": "yarn clean && yarn build:cjs && yarn build:esm",
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --strip-leading-paths && tsc -p tsconfig.json --declarationDir dist/esm",
"build": "yarn clean && ../../package-build.sh",
"depcheck": "npx depcheck"
},
"dependencies": {
Expand Down

0 comments on commit f740500

Please sign in to comment.