diff --git a/__tests__/greip.test.ts b/__tests__/greip.test.ts index d1a3f56..4c97906 100644 --- a/__tests__/greip.test.ts +++ b/__tests__/greip.test.ts @@ -1,5 +1,5 @@ import * as dotenv from "dotenv"; -import Greip from "../src/index"; +import Greip from "../src/index.mjs"; let greip: Greip; @@ -32,7 +32,7 @@ describe("Greip", () => { test("EmailValidation", async () => { const data: any = await greip.EmailValidation({ - email: "name[at]domain.com" + email: "name[ar]domain.com" }); expect(data.isValid).toBeFalsy(); }); diff --git a/package-lock.json b/package-lock.json index dfa4294..14ddd27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "greip-node", - "version": "1.1.1", + "version": "1.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "greip-node", - "version": "1.1.1", + "version": "1.2.2", "license": "Apache-2.0", "dependencies": { "axios": "^1.7.4" diff --git a/package.json b/package.json index 6099ca9..65d6c2c 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,20 @@ { "name": "greip-node", - "version": "1.2.1", + "version": "1.2.8", "description": "Official Node.js library for Greip API", "author": { "name": "Greip", "email": "info@greip.io", "url": "https://greip.io" }, - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", - "type": "module", + "main": "dist/cjs/index.cjs.js", + "types": "dist/cjs/index.d.ts", "exports": { - "import": "./dist/src/index.js", - "require": "./dist/src/index.js" - }, + ".": { + "import": "./dist/esm/index.mjs.js", + "require": "./dist/cjs/index.cjs.js" + } + }, "scripts": { "build:cjs": "tsc --project tsconfig.cjs.json", "build:esm": "tsc --project tsconfig.esm.json", @@ -22,7 +23,7 @@ "test": "jest", "test --watch": "jest --watchAll", "format": "prettier --write \"src/**/*.ts\"", - "lint": "tslint -p tsconfig.json", + "lint": "tslint -p tsconfig.cjs.json", "prepare": "npm run build", "prepublishOnly": "npm test && npm run lint", "preversion": "npm run lint", diff --git a/src/index.cjs.ts b/src/index.cjs.ts new file mode 100644 index 0000000..0a371d4 --- /dev/null +++ b/src/index.cjs.ts @@ -0,0 +1,2 @@ +import Greip from './index.mjs'; +module.exports = Greip; \ No newline at end of file diff --git a/src/index.ts b/src/index.mjs.ts similarity index 99% rename from src/index.ts rename to src/index.mjs.ts index 0bd3434..40dad1c 100644 --- a/src/index.ts +++ b/src/index.mjs.ts @@ -36,7 +36,7 @@ class Greip { lang1 = lang1.toUpperCase(); // Validate the ip variable - if (ip1.length < 7) { + if (ip1.length < 3) { reject(new Error("You should pass the `ip` parameter.")); } @@ -114,7 +114,7 @@ class Greip { const mode1 = options.mode || "live"; // Validate the ip variable - if (ip1.length < 7) { + if (ip1.length < 3) { reject(new Error("You should pass the `ip` parameter.")); } @@ -593,7 +593,6 @@ class Greip { }; } -export { Greip }; +// export { Greip }; export default Greip; -module.exports = Greip; diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 9abf960..9217289 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,9 +1,15 @@ { "compilerOptions": { - "outDir": "./dist", "module": "commonjs", - "target": "es5", - "moduleResolution": "node" + "target": "es2020", + "outDir": "./dist/cjs", + "rootDir": "./src", + "declaration": true, + "esModuleInterop": true, + "sourceMap": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "strict": true, }, "include": ["src/**/*"], "exclude": ["node_modules", "**/__tests__/*"] diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 4677e0e..8f6a88e 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,9 +1,15 @@ -{ + { "compilerOptions": { - "outDir": "./dist", "module": "esnext", - "target": "es6", - "moduleResolution": "node" + "target": "es2020", + "outDir": "./dist/esm", + "rootDir": "./src", + "declaration": true, + "esModuleInterop": true, + "sourceMap": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "strict": true }, "include": ["src/**/*"], "exclude": ["node_modules", "**/__tests__/*"]