From f4e4de129853283738830ca540c0f61c541de6ba Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 24 Aug 2023 21:49:46 +0200 Subject: [PATCH 1/8] fix: splitting compile into separate esm and cjs dists --- package.json | 18 ++++++++++++++---- tsconfig.build.json | 4 ---- tsconfig.cjs.json | 9 +++++++++ tsconfig.esm.json | 9 +++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) delete mode 100644 tsconfig.build.json create mode 100644 tsconfig.cjs.json create mode 100644 tsconfig.esm.json diff --git a/package.json b/package.json index cbc1e707..ab1a5011 100644 --- a/package.json +++ b/package.json @@ -8,16 +8,26 @@ "engines": { "node": ">=16.0" }, - "main": "./index.js", + "type": "module", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", "files": [ "**/*" ], + "exports": { + ".": { + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + }, + "./package.json": "./package.json" + }, "scripts": { "build": "run-s build:*", "build:0-clean": "rimraf dist coverage", - "build:1-compile": "tsc -p tsconfig.build.json", - "build:2-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json", - "build:3-copy-readme": "copyfiles README.md dist", + "build:1-compile-cjs": "tsc -p tsconfig.cjs.json", + "build:2-compile-esm": "tsc -p tsconfig.esm.json", + "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json", + "build:4-copy-readme": "copyfiles README.md dist", "test": "dotenv -e .env -- jest --coverage --passWithNoTests", "lint": "eslint ./src/ --ext .ts", "lint:fix": "eslint ./src/ --ext .ts --fix", diff --git a/tsconfig.build.json b/tsconfig.build.json deleted file mode 100644 index 096977c3..00000000 --- a/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["src/**/*.spec.ts", "tests/**/*.*"] -} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 00000000..72ae58ad --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "moduleResolution": "node" + }, + "exclude": ["src/**/*.spec.ts", "tests/**/*.*"] +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 00000000..4aba3b08 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node" + }, + "exclude": ["src/**/*.spec.ts", "tests/**/*.*"] +} From edda24cfed9d4ac9857cccf66874df173952b445 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 24 Aug 2023 21:52:22 +0200 Subject: [PATCH 2/8] chore: testing ci --- commitlint.config.js => commitlint.config.cjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename commitlint.config.js => commitlint.config.cjs (100%) diff --git a/commitlint.config.js b/commitlint.config.cjs similarity index 100% rename from commitlint.config.js rename to commitlint.config.cjs From 65e064e8debd7368abecf646eed463def1dd0efc Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 24 Aug 2023 21:54:20 +0200 Subject: [PATCH 3/8] chore: testing ci --- .prettierrc.js => .prettierrc.cjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .prettierrc.js => .prettierrc.cjs (100%) diff --git a/.prettierrc.js b/.prettierrc.cjs similarity index 100% rename from .prettierrc.js rename to .prettierrc.cjs From 6cb358381ab7583d1fc0b68edb05101c00740fd7 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 25 Aug 2023 10:56:50 +0200 Subject: [PATCH 4/8] refactor: addressing pr comments --- package-lock.json | 10 ---------- package.json | 20 ++++++++++++++++++++ src/types/app-client.spec.ts | 2 +- tsconfig.cjs.json | 1 + tsconfig.esm.json | 4 +++- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 78903108..aab5826f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11451,16 +11451,6 @@ ], "peer": true }, - "node_modules/q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", - "dev": true, - "engines": { - "node": ">=0.6.0", - "teleport": ">=0.2.0" - } - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", diff --git a/package.json b/package.json index ab1a5011..85fc5b2e 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,26 @@ }, "./package.json": "./package.json" }, + "types": "./dist/types/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "dist/types/index.d.ts" + ], + "types/app": [ + "dist/types/types/app.d.ts" + ], + "types/app-client": [ + "dist/types/types/app-client.d.ts" + ], + "types/app-spec": [ + "dist/types/types/app-spec.d.ts" + ], + "types/transaction": [ + "dist/types/types/transaction.d.ts" + ] + } + }, "scripts": { "build": "run-s build:*", "build:0-clean": "rimraf dist coverage", diff --git a/src/types/app-client.spec.ts b/src/types/app-client.spec.ts index 66d6c106..9ac413d1 100644 --- a/src/types/app-client.spec.ts +++ b/src/types/app-client.spec.ts @@ -534,8 +534,8 @@ describe('application-client', () => { invariant(result.confirmations) invariant(result.confirmations[0]) expect(result.transactions.length).toBe(1) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const returnValue = algokit.getABIReturn( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion { method: client.getABIMethod('call_abi_foreign_refs')!, methodArgs: [] }, result.confirmations[0], ) diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 72ae58ad..24172b56 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "outDir": "./dist/cjs", "target": "esnext", "module": "commonjs", "moduleResolution": "node" diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 4aba3b08..d5b44e39 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,9 +1,11 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "outDir": "./dist/esm", "target": "esnext", "module": "esnext", - "moduleResolution": "node" + "moduleResolution": "node", + "declarationDir": "./dist/types" }, "exclude": ["src/**/*.spec.ts", "tests/**/*.*"] } From 1217f555b406e1f026ba36536ce4ca71445e0194 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 25 Aug 2023 14:11:04 +0200 Subject: [PATCH 5/8] chore: addressing pr comments --- package.json | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 85fc5b2e..a43f9acf 100644 --- a/package.json +++ b/package.json @@ -11,42 +11,38 @@ "type": "module", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js", - "files": [ - "**/*" - ], - "exports": { - ".": { - "import": "./dist/esm/index.js", - "require": "./dist/cjs/index.js" - }, - "./package.json": "./package.json" - }, "types": "./dist/types/index.d.ts", "typesVersions": { "*": { "*": [ - "dist/types/index.d.ts" - ], - "types/app": [ - "dist/types/types/app.d.ts" - ], - "types/app-client": [ - "dist/types/types/app-client.d.ts" + "dist/types/*.d.ts" ], - "types/app-spec": [ - "dist/types/types/app-spec.d.ts" - ], - "types/transaction": [ - "dist/types/types/transaction.d.ts" + "types/*": [ + "dist/types/types/*.d.ts" ] } }, + "files": [ + "**/*" + ], + "exports": { + ".": { + "import": "./esm/index.js", + "require": "./cjs/index.js" + }, + "./testing": { + "import": "./esm/testing/index.js", + "require": "./cjs/testing/index.js" + }, + "./index.d.ts": "./types/index.d.ts", + "./package.json": "./package.json" + }, "scripts": { "build": "run-s build:*", "build:0-clean": "rimraf dist coverage", "build:1-compile-cjs": "tsc -p tsconfig.cjs.json", "build:2-compile-esm": "tsc -p tsconfig.esm.json", - "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json", + "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --main ./dist/cjs/index.js --types ./dist/types/index.d.ts --custom-sections exports", "build:4-copy-readme": "copyfiles README.md dist", "test": "dotenv -e .env -- jest --coverage --passWithNoTests", "lint": "eslint ./src/ --ext .ts", From b7c2419e83bfbb98545b65343e361fb0d99e7887 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 25 Aug 2023 14:13:19 +0200 Subject: [PATCH 6/8] chore: minor tweaks --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index a43f9acf..fe5a7eb2 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,6 @@ "*": { "*": [ "dist/types/*.d.ts" - ], - "types/*": [ - "dist/types/types/*.d.ts" ] } }, From b06b41da4f06724b9b876faff5426a3c7729675d Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 25 Aug 2023 17:31:54 +0200 Subject: [PATCH 7/8] refactor: addressing pr comments --- package.json | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index fe5a7eb2..e48ad17a 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,25 @@ "node": ">=16.0" }, "type": "module", - "main": "./dist/cjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/types/index.d.ts", + "main": "./cjs/index.js", + "module": "./esm/index.js", + "types": "./types/index.d.ts", "typesVersions": { "*": { - "*": [ - "dist/types/*.d.ts" + ".": [ + "types/index.d.ts" + ], + "types/app": [ + "types/types/app.d.ts" + ], + "types/app-client": [ + "types/types/app-client.d.ts" + ], + "types/app-spec": [ + "types/types/app-spec.d.ts" + ], + "types/transaction": [ + "types/types/transaction.d.ts" ] } }, @@ -39,7 +51,7 @@ "build:0-clean": "rimraf dist coverage", "build:1-compile-cjs": "tsc -p tsconfig.cjs.json", "build:2-compile-esm": "tsc -p tsconfig.esm.json", - "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --main ./dist/cjs/index.js --types ./dist/types/index.d.ts --custom-sections exports", + "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --main ./dist/cjs/index.js --types ./dist/types/index.d.ts --custom-sections exports typesVersions", "build:4-copy-readme": "copyfiles README.md dist", "test": "dotenv -e .env -- jest --coverage --passWithNoTests", "lint": "eslint ./src/ --ext .ts", From 129cb4c91c3c3966176bccd46d37d48976bc1cf9 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Fri, 25 Aug 2023 17:37:12 +0200 Subject: [PATCH 8/8] chore: minor tweaks --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e48ad17a..98690ab6 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "build:0-clean": "rimraf dist coverage", "build:1-compile-cjs": "tsc -p tsconfig.cjs.json", "build:2-compile-esm": "tsc -p tsconfig.esm.json", - "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --main ./dist/cjs/index.js --types ./dist/types/index.d.ts --custom-sections exports typesVersions", + "build:3-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --main ./cjs/index.js --types ./types/index.d.ts --custom-sections exports typesVersions module", "build:4-copy-readme": "copyfiles README.md dist", "test": "dotenv -e .env -- jest --coverage --passWithNoTests", "lint": "eslint ./src/ --ext .ts",