From 047626450a3f8dbef6a37bd6c55a2f23c949b2db Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Mon, 20 Feb 2023 08:35:25 +0000 Subject: [PATCH] feat: add nodenext compatibility (#252) --- .npmignore | 4 ++-- package.json | 1 + src/index.js | 8 ++++---- tsconfig.json | 3 ++- {src => types}/index.d.ts | 1 + 5 files changed, 10 insertions(+), 7 deletions(-) rename {src => types}/index.d.ts (98%) diff --git a/.npmignore b/.npmignore index 31faac7..a3591c8 100644 --- a/.npmignore +++ b/.npmignore @@ -3,7 +3,7 @@ # should improve installation performance slightly * !src/index.js -!src/index.d.ts !src/lib/win32/unrtf*/bin/** !src/lib/win32/unrtf*/contrib/**/COPYING -!src/lib/win32/unrtf*/contrib/**/README \ No newline at end of file +!src/lib/win32/unrtf*/contrib/**/README +!types/index.d.ts \ No newline at end of file diff --git a/package.json b/package.json index 6d1c0db..8749afc 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "wpml" ], "main": "src/index.js", + "types": "types/index.d.ts", "repository": "git+https://github.com/Fdawgs/node-unrtf.git", "homepage": "https://github.com/Fdawgs/node-unrtf", "bugs": { diff --git a/src/index.js b/src/index.js index d9a586c..6541bea 100644 --- a/src/index.js +++ b/src/index.js @@ -15,7 +15,8 @@ const execFileAsync = promisify(execFile); * @param {object} acceptedOptions - Object containing options that a binary accepts. * @param {object} options - Object containing options to pass to binary. * @param {string=} version - Semantic version of binary. - * @returns {Array|Error} Array of CLI arguments or Error object if invalid arguments provided. + * @returns {Array} Array of CLI arguments. + * @throws {Error} If invalid arguments provided. */ function parseOptions(acceptedOptions, options, version) { const args = []; @@ -212,6 +213,5 @@ class UnRTF { } } -module.exports = { - UnRTF, -}; +module.exports.UnRTF = UnRTF; +module.exports.default = UnRTF; diff --git a/tsconfig.json b/tsconfig.json index 5c03648..b3efe84 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,10 @@ { "include": ["src/index.js"], "compilerOptions": { + "allowJs": true, "declaration": true, "emitDeclarationOnly": true, - "allowJs": true, + "outDir": "types", "strict": true } } diff --git a/src/index.d.ts b/types/index.d.ts similarity index 98% rename from src/index.d.ts rename to types/index.d.ts index 26494e7..b6688d7 100644 --- a/src/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,4 @@ +export default UnRTF; export class UnRTF { /** * @param {string=} binPath - Path of UnRTF binary.