From ce80ac6cf50f09a5ef862b06f6b2ab5e29b5e942 Mon Sep 17 00:00:00 2001 From: laxmanpokhrel Date: Mon, 26 Feb 2024 23:45:47 +0545 Subject: [PATCH] feat: subpath import implemented --- .release/config.json | 2 +- .release/release-notes.txt | 6 +- package.json | 124 ++++++++++++++++++------------------- readme.md | 23 +++++++ tsconfig.json | 5 +- 5 files changed, 90 insertions(+), 70 deletions(-) diff --git a/.release/config.json b/.release/config.json index b1d4ecb..5c0dc42 100644 --- a/.release/config.json +++ b/.release/config.json @@ -1,4 +1,4 @@ { "versionUpgradeType": "patch", - "releaseType": "--prerelease" + "releaseType": "--latest" } \ No newline at end of file diff --git a/.release/release-notes.txt b/.release/release-notes.txt index 54b8046..1b2d0ce 100644 --- a/.release/release-notes.txt +++ b/.release/release-notes.txt @@ -1,5 +1,5 @@ -## This release for testing subpath modules and their declerations +## Changes - Folder structure changed and types removed from package.json - changed export pattern -- individual package.json -- @types for decleration file \ No newline at end of file +- @types dir for decleration file +- documented the types guidence \ No newline at end of file diff --git a/package.json b/package.json index c5de564..7a5fc32 100644 --- a/package.json +++ b/package.json @@ -10,248 +10,248 @@ "exports": { "./abbreviateCurrencyValue": { "types": { - "require": "./lib/cjs/abbreviateCurrencyValue/index.d.ts", - "default": "./lib/esm/abbreviateCurrencyValue/index.d.ts" + "require": "./@types/abbreviateCurrencyValue/index.d.ts", + "default": "./@types/abbreviateCurrencyValue/index.d.ts" }, "import": "./lib/esm/abbreviateCurrencyValue/index.js", "require": "./lib/cjs/abbreviateCurrencyValue/index.js" }, "./areObjectsEqual": { "types": { - "require": "./lib/cjs/areObjectsEqual/index.d.ts", - "default": "./lib/esm/areObjectsEqual/index.d.ts" + "require": "./@types/areObjectsEqual/index.d.ts", + "default": "./@types/areObjectsEqual/index.d.ts" }, "import": "./lib/esm/areObjectsEqual/index.js", "require": "./lib/cjs/areObjectsEqual/index.js" }, "./calculateAndInjectPercentageByMaxValue": { "types": { - "require": "./lib/cjs/calculateAndInjectPercentageByMaxValue/index.d.ts", - "default": "./lib/esm/calculateAndInjectPercentageByMaxValue/index.d.ts" + "require": "./@types/calculateAndInjectPercentageByMaxValue/index.d.ts", + "default": "./@types/calculateAndInjectPercentageByMaxValue/index.d.ts" }, "import": "./lib/esm/calculateAndInjectPercentageByMaxValue/index.js", "require": "./lib/cjs/calculateAndInjectPercentageByMaxValue/index.js" }, "./calculateAndInjectPercentageBySum": { "types": { - "require": "./lib/cjs/calculateAndInjectPercentageBySum/index.d.ts", - "default": "./lib/esm/calculateAndInjectPercentageBySum/index.d.ts" + "require": "./@types/calculateAndInjectPercentageBySum/index.d.ts", + "default": "./@types/calculateAndInjectPercentageBySum/index.d.ts" }, "import": "./lib/esm/calculateAndInjectPercentageBySum/index.js", "require": "./lib/cjs/calculateAndInjectPercentageBySum/index.js" }, "./calculateSumOfKey": { "types": { - "require": "./lib/cjs/calculateSumOfKey/index.d.ts", - "default": "./lib/esm/calculateSumOfKey/index.d.ts" + "require": "./@types/calculateSumOfKey/index.d.ts", + "default": "./@types/calculateSumOfKey/index.d.ts" }, "import": "./lib/esm/calculateSumOfKey/index.js", "require": "./lib/cjs/calculateSumOfKey/index.js" }, "./containsBinaryData": { "types": { - "require": "./lib/cjs/containsBinaryData/index.d.ts", - "default": "./lib/esm/containsBinaryData/index.d.ts" + "require": "./@types/containsBinaryData/index.d.ts", + "default": "./@types/containsBinaryData/index.d.ts" }, "import": "./lib/esm/containsBinaryData/index.js", "require": "./lib/cjs/containsBinaryData/index.js" }, "./convertNestedKeysToObject": { "types": { - "require": "./lib/cjs/convertNestedKeysToObject/index.d.ts", - "default": "./lib/esm/convertNestedKeysToObject/index.d.ts" + "require": "./@types/convertNestedKeysToObject/index.d.ts", + "default": "./@types/convertNestedKeysToObject/index.d.ts" }, "import": "./lib/esm/convertNestedKeysToObject/index.js", "require": "./lib/cjs/convertNestedKeysToObject/index.js" }, "./countKeyOccurrences": { "types": { - "require": "./lib/cjs/countKeyOccurrences/index.d.ts", - "default": "./lib/esm/countKeyOccurrences/index.d.ts" + "require": "./@types/countKeyOccurrences/index.d.ts", + "default": "./@types/countKeyOccurrences/index.d.ts" }, "import": "./lib/esm/countKeyOccurrences/index.js", "require": "./lib/cjs/countKeyOccurrences/index.js" }, "./distributePercentageEqually": { "types": { - "require": "./lib/cjs/distributePercentageEqually/index.d.ts", - "default": "./lib/esm/distributePercentageEqually/index.d.ts" + "require": "./@types/distributePercentageEqually/index.d.ts", + "default": "./@types/distributePercentageEqually/index.d.ts" }, "import": "./lib/esm/distributePercentageEqually/index.js", "require": "./lib/cjs/distributePercentageEqually/index.js" }, "./distributePercentageEquallyWithRemainder": { "types": { - "require": "./lib/cjs/distributePercentageEquallyWithRemainder/index.d.ts", - "default": "./lib/esm/distributePercentageEquallyWithRemainder/index.d.ts" + "require": "./@types/distributePercentageEquallyWithRemainder/index.d.ts", + "default": "./@types/distributePercentageEquallyWithRemainder/index.d.ts" }, "import": "./lib/esm/distributePercentageEquallyWithRemainder/index.js", "require": "./lib/cjs/distributePercentageEquallyWithRemainder/index.js" }, "./formatNumberToCommaString": { "types": { - "require": "./lib/cjs/formatNumberToCommaString/index.d.ts", - "default": "./lib/esm/formatNumberToCommaString/index.d.ts" + "require": "./@types/formatNumberToCommaString/index.d.ts", + "default": "./@types/formatNumberToCommaString/index.d.ts" }, "import": "./lib/esm/formatNumberToCommaString/index.js", "require": "./lib/cjs/formatNumberToCommaString/index.js" }, "./getDifferenceObject": { "types": { - "require": "./lib/cjs/getDifferenceObject/index.d.ts", - "default": "./lib/esm/getDifferenceObject/index.d.ts" + "require": "./@types/getDifferenceObject/index.d.ts", + "default": "./@types/getDifferenceObject/index.d.ts" }, "import": "./lib/esm/getDifferenceObject/index.js", "require": "./lib/cjs/getDifferenceObject/index.js" }, "./getFileExtension": { "types": { - "require": "./lib/cjs/getFileExtension/index.d.ts", - "default": "./lib/esm/getFileExtension/index.d.ts" + "require": "./@types/getFileExtension/index.d.ts", + "default": "./@types/getFileExtension/index.d.ts" }, "import": "./lib/esm/getFileExtension/index.js", "require": "./lib/cjs/getFileExtension/index.js" }, "./getMinMax": { "types": { - "require": "./lib/cjs/getMinMax/index.d.ts", - "default": "./lib/esm/getMinMax/index.d.ts" + "require": "./@types/getMinMax/index.d.ts", + "default": "./@types/getMinMax/index.d.ts" }, "import": "./lib/esm/getMinMax/index.js", "require": "./lib/cjs/getMinMax/index.js" }, "./groupArrayOfObjectsByValueOfAKey": { "types": { - "require": "./lib/cjs/groupArrayOfObjectsByValueOfAKey/index.d.ts", - "default": "./lib/esm/groupArrayOfObjectsByValueOfAKey/index.d.ts" + "require": "./@types/groupArrayOfObjectsByValueOfAKey/index.d.ts", + "default": "./@types/groupArrayOfObjectsByValueOfAKey/index.d.ts" }, "import": "./lib/esm/groupArrayOfObjectsByValueOfAKey/index.js", "require": "./lib/cjs/groupArrayOfObjectsByValueOfAKey/index.js" }, "./intersectObjects": { "types": { - "require": "./lib/cjs/intersectObjects/index.d.ts", - "default": "./lib/esm/intersectObjects/index.d.ts" + "require": "./@types/intersectObjects/index.d.ts", + "default": "./@types/intersectObjects/index.d.ts" }, "import": "./lib/esm/intersectObjects/index.js", "require": "./lib/cjs/intersectObjects/index.js" }, "./isJSONObject": { "types": { - "require": "./lib/cjs/isJSONObject/index.d.ts", - "default": "./lib/esm/isJSONObject/index.d.ts" + "require": "./@types/isJSONObject/index.d.ts", + "default": "./@types/isJSONObject/index.d.ts" }, "import": "./lib/esm/isJSONObject/index.js", "require": "./lib/cjs/isJSONObject/index.js" }, "./markCheckedByStringMatch": { "types": { - "require": "./lib/cjs/markCheckedByStringMatch/index.d.ts", - "default": "./lib/esm/markCheckedByStringMatch/index.d.ts" + "require": "./@types/markCheckedByStringMatch/index.d.ts", + "default": "./@types/markCheckedByStringMatch/index.d.ts" }, "import": "./lib/esm/markCheckedByStringMatch/index.js", "require": "./lib/cjs/markCheckedByStringMatch/index.js" }, "./objectToFormDataWithFiles": { "types": { - "require": "./lib/cjs/objectToFormDataWithFiles/index.d.ts", - "default": "./lib/esm/objectToFormDataWithFiles/index.d.ts" + "require": "./@types/objectToFormDataWithFiles/index.d.ts", + "default": "./@types/objectToFormDataWithFiles/index.d.ts" }, "import": "./lib/esm/objectToFormDataWithFiles/index.js", "require": "./lib/cjs/objectToFormDataWithFiles/index.js" }, "./omitKey": { "types": { - "require": "./lib/cjs/omitKey/index.d.ts", - "default": "./lib/esm/omitKey/index.d.ts" + "require": "./@types/omitKey/index.d.ts", + "default": "./@types/omitKey/index.d.ts" }, "import": "./lib/esm/omitKey/index.js", "require": "./lib/cjs/omitKey/index.js" }, "./parseToBoolean": { "types": { - "require": "./lib/cjs/parseToBoolean/index.d.ts", - "default": "./lib/esm/parseToBoolean/index.d.ts" + "require": "./@types/parseToBoolean/index.d.ts", + "default": "./@types/parseToBoolean/index.d.ts" }, "import": "./lib/esm/parseToBoolean/index.js", "require": "./lib/cjs/parseToBoolean/index.js" }, "./partitionObjectsByKey": { "types": { - "require": "./lib/cjs/partitionObjectsByKey/index.d.ts", - "default": "./lib/esm/partitionObjectsByKey/index.d.ts" + "require": "./@types/partitionObjectsByKey/index.d.ts", + "default": "./@types/partitionObjectsByKey/index.d.ts" }, "import": "./lib/esm/partitionObjectsByKey/index.js", "require": "./lib/cjs/partitionObjectsByKey/index.js" }, "./removeObjectFromArray": { "types": { - "require": "./lib/cjs/removeObjectFromArray/index.d.ts", - "default": "./lib/esm/removeObjectFromArray/index.d.ts" + "require": "./@types/removeObjectFromArray/index.d.ts", + "default": "./@types/removeObjectFromArray/index.d.ts" }, "import": "./lib/esm/removeObjectFromArray/index.js", "require": "./lib/cjs/removeObjectFromArray/index.js" }, "./scrollToComponent": { "types": { - "require": "./lib/cjs/scrollToComponent/index.d.ts", - "default": "./lib/esm/scrollToComponent/index.d.ts" + "require": "./@types/scrollToComponent/index.d.ts", + "default": "./@types/scrollToComponent/index.d.ts" }, "import": "./lib/esm/scrollToComponent/index.js", "require": "./lib/cjs/scrollToComponent/index.js" }, "./setKeysToValueInObjects": { "types": { - "require": "./lib/cjs/setKeysToValueInObjects/index.d.ts", - "default": "./lib/esm/setKeysToValueInObjects/index.d.ts" + "require": "./@types/setKeysToValueInObjects/index.d.ts", + "default": "./@types/setKeysToValueInObjects/index.d.ts" }, "import": "./lib/esm/setKeysToValueInObjects/index.js", "require": "./lib/cjs/setKeysToValueInObjects/index.js" }, "./setValueOfKeyForMatchingValuesOfAKey": { "types": { - "require": "./lib/cjs/setValueOfKeyForMatchingValuesOfAKey/index.d.ts", - "default": "./lib/esm/setValueOfKeyForMatchingValuesOfAKey/index.d.ts" + "require": "./@types/setValueOfKeyForMatchingValuesOfAKey/index.d.ts", + "default": "./@types/setValueOfKeyForMatchingValuesOfAKey/index.d.ts" }, "import": "./lib/esm/setValueOfKeyForMatchingValuesOfAKey/index.js", "require": "./lib/cjs/setValueOfKeyForMatchingValuesOfAKey/index.js" }, "./splitArrayIntoChunks": { "types": { - "require": "./lib/cjs/splitArrayIntoChunks/index.d.ts", - "default": "./lib/esm/splitArrayIntoChunks/index.d.ts" + "require": "./@types/splitArrayIntoChunks/index.d.ts", + "default": "./@types/splitArrayIntoChunks/index.d.ts" }, "import": "./lib/esm/splitArrayIntoChunks/index.js", "require": "./lib/cjs/splitArrayIntoChunks/index.js" }, "./strictIntersectObjects": { "types": { - "require": "./lib/cjs/strictIntersectObjects/index.d.ts", - "default": "./lib/esm/strictIntersectObjects/index.d.ts" + "require": "./@types/strictIntersectObjects/index.d.ts", + "default": "./@types/strictIntersectObjects/index.d.ts" }, "import": "./lib/esm/strictIntersectObjects/index.js", "require": "./lib/cjs/strictIntersectObjects/index.js" }, "./toggleObjectInArray": { "types": { - "require": "./lib/cjs/toggleObjectInArray/index.d.ts", - "default": "./lib/esm/toggleObjectInArray/index.d.ts" + "require": "./@types/toggleObjectInArray/index.d.ts", + "default": "./@types/toggleObjectInArray/index.d.ts" }, "import": "./lib/esm/toggleObjectInArray/index.js", "require": "./lib/cjs/toggleObjectInArray/index.js" }, "./uniqueValuesOfKey": { "types": { - "require": "./lib/cjs/uniqueValuesOfKey/index.d.ts", - "default": "./lib/esm/uniqueValuesOfKey/index.d.ts" + "require": "./@types/uniqueValuesOfKey/index.d.ts", + "default": "./@types/uniqueValuesOfKey/index.d.ts" }, "import": "./lib/esm/uniqueValuesOfKey/index.js", "require": "./lib/cjs/uniqueValuesOfKey/index.js" }, "./validateObjectsForKey": { "types": { - "require": "./lib/cjs/validateObjectsForKey/index.d.ts", - "default": "./lib/esm/validateObjectsForKey/index.d.ts" + "require": "./@types/validateObjectsForKey/index.d.ts", + "default": "./@types/validateObjectsForKey/index.d.ts" }, "import": "./lib/esm/validateObjectsForKey/index.js", "require": "./lib/cjs/validateObjectsForKey/index.js" diff --git a/readme.md b/readme.md index f03587d..5b3f7ed 100644 --- a/readme.md +++ b/readme.md @@ -42,6 +42,29 @@ To install **@xmanscript/utils** using npm, open your terminal and run the follo pnpm add @xmanscript/utils ``` +### Additional Configuration for TypeScript Projects + +If you're using **@xmanscript/utils** in a TypeScript project, you'll need to add a specific configuration to your `tsconfig.json` file. This is necessary because the TypeScript compiler (TSC) might not automatically detect the declaration files of the package. + +To ensure proper recognition of declaration files, follow these steps: + +1. Open your `tsconfig.json` file in your project. + +2. Add the following configuration within the `"compilerOptions"` section: + +```json +{ + "compilerOptions": { + "baseUrl": "./", + "paths": { + "@xmanscript/utils/*": ["./node_modules/@xmanscript/utils/@types/*"] + } + } +} +``` +This configuration tells TypeScript where to find the declaration files for @xmanscript/utils. With this setup, TypeScript will be able to properly utilize the types provided by the package. + + ## Utility Functions Provided By The Package: 1. partitionObjectsByKey 2. convertNestedKeysToObject diff --git a/tsconfig.json b/tsconfig.json index d792646..6bdf86b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,8 @@ { "compilerOptions": { "target": "ES6", - // "module": "ES2015", "declaration": true, "sourceMap": true, - // "outDir": "./lib", - // "baseUrl": "src/", "strict": true, "lib": ["ES2020", "DOM"], "removeComments": false, @@ -22,7 +19,7 @@ "module": "commonjs", "outDir": "./lib/commonjs", "moduleResolution": "node", - "declarationDir": "./lib/@types" + "declarationDir": "./@types" }, "exclude": ["node_modules",], "include": [".eslintrc.cjs", "src", "src/**/*.ts"]