Skip to content

Commit c269942

Browse files
hl662Copilot
andcommitted
fix(electron): add .js extensions to fix ESM exports
The ESM build output had bare import specifiers (missing .js extensions) which breaks Node's ESM resolver. Switch tsconfig.esm.json to module esnext + moduleResolution bundler, add .js extensions to all relative imports, and emit lib/esm/package.json with {"type":"module"} so Node treats the output as ES modules. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b290e6e commit c269942

17 files changed

+41
-38
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"overrides": {
4242
"path-to-regexp": "0.1.12",
4343
"minimatch@>=9.0.0 <9.0.7": ">=9.0.7",
44-
"serialize-javascript@<=7.0.2": ">=7.0.3"
44+
"serialize-javascript@<=7.0.2": ">=7.0.3",
45+
"flatted@<=3.4.1": ">=3.4.2"
4546
}
4647
},
4748
"packageManager": "pnpm@9.15.9+sha512.68046141893c66fad01c079231128e9afb89ef87e2691d69e4d40eee228988295fd4682181bae55b58418c3a253bde65a505ec7c5f9403ece5cc3cd37dcf2531"

packages/electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "pnpm run -s build:cjs && pnpm run -s build:esm && pnpm run copy:assets",
1919
"build:cjs": "tsc 1>&2 -p tsconfig.cjs.json",
2020
"build:esm": "tsc 1>&2 -p tsconfig.esm.json",
21-
"copy:assets": "cpx src/static/* dist/main/static && cpx src/static/* lib/cjs/main/static && cpx src/static/* lib/esm/main/static",
21+
"copy:assets": "cpx src/static/* dist/main/static && cpx src/static/* lib/cjs/main/static && cpx src/static/* lib/esm/main/static && echo '{\"type\":\"module\"}' > lib/esm/package.json",
2222
"cover": "nyc npm test",
2323
"clean": "rimraf lib",
2424
"docs": "RUSHSTACK_FILE_ERROR_BASE_FOLDER='../..' betools docs --includes=../../generated-docs/extract --json=../../generated-docs/auth-clients/electron-authorization/file.json --tsIndexFile=./docsIndex.ts --onlyJson",

packages/electron/src/ElectronMain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
* See LICENSE.md in the project root for license terms and full copyright notice.
44
*--------------------------------------------------------------------------------------------*/
55

6-
export * from "./main/Client";
6+
export * from "./main/Client.js";
77

packages/electron/src/ElectronRenderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* See LICENSE.md in the project root for license terms and full copyright notice.
44
*--------------------------------------------------------------------------------------------*/
55

6-
export * from "./renderer/Client";
6+
export * from "./renderer/Client.js";

packages/electron/src/integration-test/helpers/TestHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import type { Page } from "@playwright/test";
7-
import type { SignInOptions } from "../types";
7+
import type { SignInOptions } from "../types.js";
88

99
/**
1010
* Helper class for tests

packages/electron/src/integration-test/integration.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import type { ElectronApplication, Page } from "@playwright/test";
77
import { _electron as electron, expect, test } from "@playwright/test";
8-
import type { SignInOptions } from "./types";
9-
import { loadConfig } from "./helpers/loadConfig";
10-
import { TestHelper } from "./helpers/TestHelper";
11-
import { RefreshTokenStore } from "../main/TokenStore";
12-
import { getPrefixedClientId } from "../common/IpcChannelNames";
8+
import type { SignInOptions } from "./types.js";
9+
import { loadConfig } from "./helpers/loadConfig.js";
10+
import { TestHelper } from "./helpers/TestHelper.js";
11+
import { RefreshTokenStore } from "../main/TokenStore.js";
12+
import { getPrefixedClientId } from "../common/IpcChannelNames.js";
1313

1414
const { clientId, envPrefix, email, password } = loadConfig();
1515

packages/electron/src/integration-test/test-app/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ElectronMainAuthorization } from "../../main/Client";
1+
import { ElectronMainAuthorization } from "../../main/Client.js";
22
import { app, BrowserWindow } from "electron";
33
import { config } from "dotenv";
44

packages/electron/src/integration-test/test-app/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ElectronRendererAuthorization } from "../../renderer/Client";
1+
import { ElectronRendererAuthorization } from "../../renderer/Client.js";
22

33
if (!process.env.IMJS_TEST_ELECTRON_CLIENT_ID)
44
throw new Error("Please provide a clientId in env");

packages/electron/src/main/Client.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ import {
3535
TokenRequest,
3636
} from "@openid/appauth";
3737
import { NodeCrypto, NodeRequestor } from "@openid/appauth/built/node_support";
38-
import { ElectronAuthorizationEvents } from "./Events";
39-
import { ElectronMainAuthorizationRequestHandler } from "./ElectronMainAuthorizationRequestHandler";
40-
import { RefreshTokenStore } from "./TokenStore";
41-
import { LoopbackWebServer } from "./LoopbackWebServer";
38+
import { ElectronAuthorizationEvents } from "./Events.js";
39+
import { ElectronMainAuthorizationRequestHandler } from "./ElectronMainAuthorizationRequestHandler.js";
40+
import { RefreshTokenStore } from "./TokenStore.js";
41+
import { LoopbackWebServer } from "./LoopbackWebServer.js";
4242
import * as electron from "electron";
43-
import { defaultExpiryBufferInSeconds } from "../common/constants";
44-
import type { IpcChannelNames } from "../common/IpcChannelNames";
45-
import { getIpcChannelNames, getPrefixedClientId } from "../common/IpcChannelNames";
43+
import { defaultExpiryBufferInSeconds } from "../common/constants.js";
44+
import type { IpcChannelNames } from "../common/IpcChannelNames.js";
45+
import { getIpcChannelNames, getPrefixedClientId } from "../common/IpcChannelNames.js";
4646
const loggerCategory = "electron-auth";
4747

4848
/**

packages/electron/src/main/ElectronMainAuthorizationRequestHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
AuthorizationError, AuthorizationRequestHandler, AuthorizationResponse, BasicQueryStringUtils,
1414
} from "@openid/appauth";
1515
import { NodeCrypto } from "@openid/appauth/built/node_support";
16-
import type { ElectronAuthorizationEvents } from "./Events";
16+
import type { ElectronAuthorizationEvents } from "./Events.js";
1717
import { shell } from "electron";
1818

1919
const electronAuthLoggerCategory = "electron-auth";

0 commit comments

Comments
 (0)