From 2fcc6b65e0d90f0bf1b96cbe4dd0813ffb2a5ad3 Mon Sep 17 00:00:00 2001 From: Ayush Date: Thu, 29 Aug 2024 02:27:47 +0530 Subject: [PATCH] added cjs distribution command and tsconfig --- package-lock.json | 4 ++-- package.json | 28 ++++++++++++++++++++++++---- tsconfig.cjs.json | 7 +++++++ tsconfig.json | 21 +++++++++++++-------- 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 tsconfig.cjs.json diff --git a/package-lock.json b/package-lock.json index 81245c7..741a155 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solana-developers/helpers", - "version": "2.5.0", + "version": "2.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@solana-developers/helpers", - "version": "2.5.0", + "version": "2.5.2", "license": "MIT", "dependencies": { "@solana/spl-token": "^0.4.8", diff --git a/package.json b/package.json index e0802fb..8f09d6a 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,32 @@ "name": "@solana-developers/helpers", "version": "2.5.2", "description": "Solana helper functions", - "main": "dist/index.js", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/esm/index.d.ts", "type": "module", "private": false, + "exports": { + ".": { + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + }, + "./node": { + "import": "./dist/esm/node.js", + "require": "./dist/cjs/node.js" + } + }, + "files": [ + "dist" + ], + "sideEffects": false, "scripts": { - "build": "tsc", + "build": "npm run build:esm && npm run build:cjs", + "build:esm": "tsc", + "build:cjs": "tsc -p tsconfig.cjs.json", "clean": "rm -rf dist", - "test": "esrun src/index.test.ts" + "test": "esrun src/index.test.ts", + "typecheck": "tsc --noEmit" }, "keywords": [ "solana", @@ -24,7 +43,8 @@ "Nick Frostbutter", "John Liu", "Steven Luscher", - "Christian Krueger" + "Christian Krueger", + "Ayush Chauhan" ], "license": "MIT", "dependencies": { diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..181de34 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "./dist/cjs" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index a948bb7..7935e9b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,20 @@ -// See https://aka.ms/tsconfig { "compilerOptions": { - "outDir": "dist", - "target": "es2022", - "moduleResolution": "Bundler", - "module": "ES2022", + "target": "ES2018", + "lib": ["ES2018", "DOM"], + "moduleResolution": "node", + "outDir": "./dist/esm", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, + "sourceMap": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "module": "ESNext", + "isolatedModules": true }, - "include": ["src"], + "include": ["src/**/*"], "exclude": ["node_modules", "dist"] -} +} \ No newline at end of file