From 2cb211694083418e26ea3dfdfbfc27c2a210e96d Mon Sep 17 00:00:00 2001 From: Saud Fatayerji Date: Sat, 11 Nov 2023 13:33:49 +0300 Subject: [PATCH] Fixed nodemon + TS incompatability --- server-node/package.json | 6 ++++-- server-node/tsconfig.json | 4 ++-- shared-operations/functions/common/detectEmptyPages.ts | 2 +- shared-operations/functions/common/getImagesOnPage.ts | 2 +- shared-operations/functions/splitOn.ts | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server-node/package.json b/server-node/package.json index d445039a..668c31c8 100644 --- a/server-node/package.json +++ b/server-node/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "npx tsc", "start": "node dist/index.js", - "dev": "nodemon index.ts" + "dev": "nodemon --watch './**/*.ts' --exec 'node --experimental-specifier-resolution=node --loader ts-node/esm' ./index.ts" }, "keywords": [], "author": "", @@ -26,5 +26,7 @@ "@types/express": "^4.17.21", "ts-node-dev": "^2.0.0", "typescript": "^5.2.2" - } + }, + "exports": "./dist/index.js", + "type": "module" } diff --git a/server-node/tsconfig.json b/server-node/tsconfig.json index 16319f1f..8a7dca9a 100644 --- a/server-node/tsconfig.json +++ b/server-node/tsconfig.json @@ -25,9 +25,9 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ + "module": "ES2020", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + "moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ diff --git a/shared-operations/functions/common/detectEmptyPages.ts b/shared-operations/functions/common/detectEmptyPages.ts index b394b884..964b6b4b 100644 --- a/shared-operations/functions/common/detectEmptyPages.ts +++ b/shared-operations/functions/common/detectEmptyPages.ts @@ -1,5 +1,5 @@ import { DocumentInitParameters, PDFPageProxy } from "pdfjs-dist/types/src/display/api.js"; -import PDFJS from 'pdfjs-dist'; +import * as PDFJS from 'pdfjs-dist'; import { Image } from 'image-js'; import { getImagesOnPage } from "./getImagesOnPage.js"; diff --git a/shared-operations/functions/common/getImagesOnPage.ts b/shared-operations/functions/common/getImagesOnPage.ts index 3a8ef7f3..10ce53c9 100644 --- a/shared-operations/functions/common/getImagesOnPage.ts +++ b/shared-operations/functions/common/getImagesOnPage.ts @@ -1,6 +1,6 @@ import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js"; -import PDFJS from 'pdfjs-dist'; +import * as PDFJS from 'pdfjs-dist'; export async function getImagesOnPage(page: PDFPageProxy) { const ops = await page.getOperatorList(); diff --git a/shared-operations/functions/splitOn.ts b/shared-operations/functions/splitOn.ts index 399718cf..0e09688b 100644 --- a/shared-operations/functions/splitOn.ts +++ b/shared-operations/functions/splitOn.ts @@ -1,6 +1,6 @@ import { PDFDocument } from 'pdf-lib'; -import PDFJS from 'pdfjs-dist'; +import * as PDFJS from 'pdfjs-dist'; import jsQR from "jsqr"; import { detectEmptyPages } from "./common/detectEmptyPages.js";