fix(frontend): add .js extension to electron-log/main imports
Node.js ESM module resolution requires explicit file extensions for package subpath imports. Since electron-log is externalized in the vite config, it's resolved at runtime where ESM rules apply. This fixes the ERR_MODULE_NOT_FOUND error when running dev mode.
This commit is contained in:
@@ -18,7 +18,7 @@ const mockGetFile = vi.fn();
|
||||
const mockGetPath = vi.fn();
|
||||
|
||||
// Mock electron-log before importing
|
||||
vi.mock('electron-log/main', () => ({
|
||||
vi.mock('electron-log/main.js', () => ({
|
||||
default: {
|
||||
initialize: vi.fn(),
|
||||
transports: {
|
||||
@@ -433,7 +433,7 @@ describe('Application Logger', () => {
|
||||
describe('Beta version detection', () => {
|
||||
it('should detect beta version from app version', async () => {
|
||||
// The mock returns '2.7.2-beta.10' which should be detected as beta
|
||||
const electronLog = await import('electron-log/main');
|
||||
const electronLog = await import('electron-log/main.js');
|
||||
|
||||
// Beta version should set file level to debug
|
||||
// This is tested implicitly by the mock setup
|
||||
|
||||
@@ -57,7 +57,7 @@ vi.mock('../notification-service', () => ({
|
||||
}));
|
||||
|
||||
// Mock electron-log to prevent Electron binary dependency
|
||||
vi.mock('electron-log/main', () => ({
|
||||
vi.mock('electron-log/main.js', () => ({
|
||||
default: {
|
||||
initialize: vi.fn(),
|
||||
transports: {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* - Beta version detection for enhanced logging
|
||||
*/
|
||||
|
||||
import log from 'electron-log/main';
|
||||
import log from 'electron-log/main.js';
|
||||
import { app } from 'electron';
|
||||
import { existsSync, readdirSync, statSync, readFileSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
|
||||
Reference in New Issue
Block a user