From 56552d581bf8489d6d834b720f1fea58d56d1de9 Mon Sep 17 00:00:00 2001 From: LukasHeimann <48723560+LukasHeimann@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:17:35 +0100 Subject: [PATCH] fix: TypeScript Module Configuration (especially for ESM) (#574) fixes #573 --- src/lib/Logger.ts | 2 +- src/lib/authentication/BTPAuthenticator.ts | 2 +- src/lib/authentication/BasicAuthenticator.ts | 2 +- src/lib/authentication/CustomAuthenticator.ts | 2 +- src/lib/authentication/Office365Authenticator.ts | 2 +- src/lib/wdi5-bridge.ts | 4 ++-- src/lib/wdi5-control.ts | 2 +- src/lib/wdi5-object.ts | 2 +- src/service.ts | 2 +- src/types/browser-commands.ts | 4 ++-- src/types/wdi5.types.ts | 4 ++-- tsconfig-cjs.json | 1 + tsconfig.base.json | 1 - tsconfig.json | 4 ++-- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lib/Logger.ts b/src/lib/Logger.ts index a7c48ff4..af6efbe4 100644 --- a/src/lib/Logger.ts +++ b/src/lib/Logger.ts @@ -1,4 +1,4 @@ -import { wdi5LogLevel } from "../types/wdi5.types" +import { wdi5LogLevel } from "../types/wdi5.types.js" const translate = (color) => { switch (color) { diff --git a/src/lib/authentication/BTPAuthenticator.ts b/src/lib/authentication/BTPAuthenticator.ts index f50efe26..29ab7c86 100644 --- a/src/lib/authentication/BTPAuthenticator.ts +++ b/src/lib/authentication/BTPAuthenticator.ts @@ -1,4 +1,4 @@ -import { BTPAuthenticator as BTPAuthenticatorType } from "../../types/wdi5.types" +import { BTPAuthenticator as BTPAuthenticatorType } from "../../types/wdi5.types.js" import Authenticator from "./Authenticator.js" class BTPAuthenticator extends Authenticator { diff --git a/src/lib/authentication/BasicAuthenticator.ts b/src/lib/authentication/BasicAuthenticator.ts index 966d70d3..d00ce4b9 100644 --- a/src/lib/authentication/BasicAuthenticator.ts +++ b/src/lib/authentication/BasicAuthenticator.ts @@ -1,5 +1,5 @@ import Authenticator from "./Authenticator.js" -import { BasicAuthAuthenticator as BasicAuthenticatorType } from "../../types/wdi5.types" +import { BasicAuthAuthenticator as BasicAuthenticatorType } from "../../types/wdi5.types.js" class BasicAuthenticator extends Authenticator { private options: BasicAuthenticatorType diff --git a/src/lib/authentication/CustomAuthenticator.ts b/src/lib/authentication/CustomAuthenticator.ts index 3612cecf..c9a04f22 100644 --- a/src/lib/authentication/CustomAuthenticator.ts +++ b/src/lib/authentication/CustomAuthenticator.ts @@ -1,4 +1,4 @@ -import { CustomAuthenticator as CustomAuthenticatorType } from "../../types/wdi5.types" +import { CustomAuthenticator as CustomAuthenticatorType } from "../../types/wdi5.types.js" import { Logger } from "../Logger.js" import Authenticator from "./Authenticator.js" diff --git a/src/lib/authentication/Office365Authenticator.ts b/src/lib/authentication/Office365Authenticator.ts index adf2830a..cc2a2304 100644 --- a/src/lib/authentication/Office365Authenticator.ts +++ b/src/lib/authentication/Office365Authenticator.ts @@ -1,4 +1,4 @@ -import { Office365Authenticator as Office365AuthenticatorType } from "../../types/wdi5.types" +import { Office365Authenticator as Office365AuthenticatorType } from "../../types/wdi5.types.js" import Authenticator from "./Authenticator.js" class Office365Authenticator extends Authenticator { diff --git a/src/lib/wdi5-bridge.ts b/src/lib/wdi5-bridge.ts index 0f4a2739..a332db03 100644 --- a/src/lib/wdi5-bridge.ts +++ b/src/lib/wdi5-bridge.ts @@ -4,7 +4,7 @@ import { tmpdir } from "os" import * as semver from "semver" import { mark as marky_mark, stop as marky_stop } from "marky" -import { clientSide_ui5Object, clientSide_ui5Response, wdi5Config, wdi5Selector } from "../types/wdi5.types" +import { clientSide_ui5Object, clientSide_ui5Response, wdi5Config, wdi5Selector } from "../types/wdi5.types.js" import { MultiRemoteBrowser } from "webdriverio" import { WDI5Control } from "./wdi5-control.js" import { WDI5FE } from "./wdi5-fe.js" @@ -19,7 +19,7 @@ import { clientSide_allControls } from "../../client-side-js/allControls.cjs" import { Logger as _Logger } from "./Logger.js" import { WDI5Object } from "./wdi5-object.js" import BTPAuthenticator from "./authentication/BTPAuthenticator.js" -import { BTPAuthenticator as BTPAuthenticatorType } from "../types/wdi5.types" +import { BTPAuthenticator as BTPAuthenticatorType } from "../types/wdi5.types.js" import BasicAuthenticator from "./authentication/BasicAuthenticator.js" import CustomAuthenticator from "./authentication/CustomAuthenticator.js" import Office365Authenticator from "./authentication/Office365Authenticator.js" diff --git a/src/lib/wdi5-control.ts b/src/lib/wdi5-control.ts index b31007fc..a56a2057 100644 --- a/src/lib/wdi5-control.ts +++ b/src/lib/wdi5-control.ts @@ -7,7 +7,7 @@ import { clientSide_interactWithControl } from "../../client-side-js/interactWit import { clientSide_executeControlMethod } from "../../client-side-js/executeControlMethod.cjs" import { clientSide_getAggregation } from "../../client-side-js/_getAggregation.cjs" import { clientSide_fireEvent } from "../../client-side-js/fireEvent.cjs" -import { clientSide_ui5Response, wdi5ControlMetadata, wdi5Selector } from "../types/wdi5.types" +import { clientSide_ui5Response, wdi5ControlMetadata, wdi5Selector } from "../types/wdi5.types.js" import { Logger as _Logger } from "./Logger.js" import { wdioApi } from "./wdioApi.js" import { WDI5Object } from "./wdi5-object.js" diff --git a/src/lib/wdi5-object.ts b/src/lib/wdi5-object.ts index 410aa628..38c3063e 100644 --- a/src/lib/wdi5-object.ts +++ b/src/lib/wdi5-object.ts @@ -1,5 +1,5 @@ import { clientSide_executeObjectMethod } from "../../client-side-js/executeObjectMethod.cjs" -import { clientSide_ui5Response } from "../types/wdi5.types" +import { clientSide_ui5Response } from "../types/wdi5.types.js" import { Logger as _Logger } from "./Logger.js" const Logger = _Logger.getInstance() diff --git a/src/service.ts b/src/service.ts index d9c1258d..9e73babc 100644 --- a/src/service.ts +++ b/src/service.ts @@ -2,7 +2,7 @@ import { Capabilities, Services } from "@wdio/types" import { MultiRemoteBrowser } from "webdriverio" import { start, injectUI5, setup, checkForUI5Page, authenticate } from "./lib/wdi5-bridge.js" -import { wdi5Config } from "./types/wdi5.types" +import { wdi5Config } from "./types/wdi5.types.js" import { Logger as _Logger } from "./lib/Logger.js" const Logger = _Logger.getInstance() diff --git a/src/types/browser-commands.ts b/src/types/browser-commands.ts index dfc0e38b..879ed416 100644 --- a/src/types/browser-commands.ts +++ b/src/types/browser-commands.ts @@ -1,6 +1,6 @@ import Control from "sap/ui/core/Control" -import { wdi5Config, wdi5Selector } from "./wdi5.types" -import { WDI5Control } from "../lib/wdi5-control" +import { wdi5Config, wdi5Selector } from "./wdi5.types.js" +import { WDI5Control } from "../lib/wdi5-control.js" /** * wdi5 control cache aka diff --git a/src/types/wdi5.types.ts b/src/types/wdi5.types.ts index 74044790..0bc48352 100644 --- a/src/types/wdi5.types.ts +++ b/src/types/wdi5.types.ts @@ -1,7 +1,7 @@ import Log from "sap/base/Log" import RecordReplay from "sap/ui/test/RecordReplay" import { ControlSelector } from "sap/ui/test/RecordReplay" -import { WDI5Object } from "../lib/wdi5-object" +import { WDI5Object } from "../lib/wdi5-object.js" // // copypasta from // // https://stackoverflow.com/questions/41285211/overriding-interface-property-type-defined-in-typescript-d-ts-file/65561287#65561287 @@ -262,4 +262,4 @@ export interface wdi5Bridge extends Window { } } -export type { WDI5Control as wdi5Control } from "../lib/wdi5-control" +export type { WDI5Control as wdi5Control } from "../lib/wdi5-control.js" diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json index f2ec2ade..bcba2fd8 100644 --- a/tsconfig-cjs.json +++ b/tsconfig-cjs.json @@ -3,6 +3,7 @@ "compilerOptions": { "noEmit": false, "outDir": "cjs", + "moduleResolution": "Node", "module": "CommonJS" } } diff --git a/tsconfig.base.json b/tsconfig.base.json index e42801ef..e1edd1bc 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -7,7 +7,6 @@ "declaration": true, "declarationMap": true, "downlevelIteration": true, - "moduleResolution": "node", "types": ["node", "@wdio/globals/types", "@wdio/mocha-framework", "openui5"] }, "include": ["src"] diff --git a/tsconfig.json b/tsconfig.json index 5dffee9c..c0d00638 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "noEmit": false, "outDir": "esm", - "module": "ESNext", - "target": "ESNext" + "module": "Node16", + "moduleResolution": "Node16" } }