Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions jslib/electron/src/services/electronStorage.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as fs from "fs";

import { ipcMain } from "electron";
import Store from "electron-store";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good: The migration from CommonJS require() to ESM import is correct for electron-store v11.

However, there are some additional concerns to address:

  1. Missing webpack configuration: Since electron-store v11 is pure ESM, you may need to add it to webpack externals in webpack.main.js to prevent bundling issues:

    externals: {
      "electron-reload": "commonjs2 electron-reload",
      "electron-store": "commonjs2 electron-store",  // Add this
      keytar: "commonjs2 keytar",
    },
  2. Type safety: The store property on line 11 is still typed as any. Consider using proper typing:

    private store: Store<Record<string, unknown>>;
  3. Verify compatibility: Electron-store v11 requires Electron 30+. Ensure your electron dependency meets this requirement (I see you have v39.2.1, so this is fine).


import { StorageService } from "@/jslib/common/src/abstractions/storage.service";
import { NodeUtils } from "@/jslib/common/src/misc/nodeUtils";

// eslint-disable-next-line
const Store = require("electron-store");

export class ElectronStorageService implements StorageService {
private store: any;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type Safety Issue: The store property is typed as any, which defeats TypeScript's type safety.

Since electron-store v11 is now written in TypeScript with proper type definitions, you should use proper typing:

Suggested change
private store: any;
private store: Store<Record<string, unknown>>;

Or if you know the specific shape of your data, define a proper interface for the store schema.

Expand Down
245 changes: 84 additions & 161 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"electron-builder": "24.13.3",
"electron-log": "5.4.1",
"electron-reload": "2.0.0-alpha.1",
"electron-store": "8.2.0",
"electron-store": "11.0.2",
"electron-updater": "6.6.2",
"eslint": "8.57.1",
"eslint-config-prettier": "10.1.5",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"compilerOptions": {
"pretty": true,
"moduleResolution": "node",
"moduleResolution": "bundler",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration Concern: Changing moduleResolution from "node" to "bundler" is a significant change that affects how TypeScript resolves module imports.

While "bundler" is appropriate for bundled applications, this change should be carefully tested because:

  1. It changes how conditional exports are resolved
  2. It allows importing ESM modules from CJS contexts (which may hide issues)
  3. It affects how package.json exports fields are interpreted

Since you're using Webpack to bundle the application, this change seems reasonable, but you should verify:

  • The application builds successfully
  • All imports resolve correctly at runtime
  • No module resolution errors occur in production

Consider also checking if you need to update the webpack configuration's resolve.conditionNames to match this change.

"noImplicitAny": true,
"target": "ES2016",
"module": "ES2020",
Expand Down
Loading