Skip to content

Commit 072b1c4

Browse files
committed
remove esm dep. fix dev env
1 parent b86a5ab commit 072b1c4

File tree

10 files changed

+74
-50
lines changed

10 files changed

+74
-50
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Built with [Electron](https://electronjs.org). Uses [node-exiftool](https://www.
5555

5656
```
5757
$ npm install
58-
$ npm start
58+
$ npm run dev #this command is set up to give you HMR in dev
5959
```
6060

6161
### Publish

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"description": "Clean exif data from images",
66
"license": "MIT",
77
"repository": "github:szTheory/exifcleaner",
8-
"type": "module",
9-
"main": "src/main/entrypoint.js",
8+
"main": "src/main/index.js",
109
"author": {
1110
"name": "szTheory",
1211
"email": "[email protected]",
@@ -33,15 +32,14 @@
3332
"electron-unhandled": "^3.0.0",
3433
"electron-updater": "^4.2.0",
3534
"electron-util": "^0.13.0",
36-
"esm": "^3.2.25",
3735
"js-yaml": "^3.13.1",
3836
"node-exiftool": "^2.3.0",
3937
"serialize-javascript": "^2.1.1",
4038
"source-map-support": "^0.5.16",
4139
"spectre.css": "^0.5.8"
4240
},
4341
"devDependencies": {
44-
"electron": "7.1.8",
42+
"electron": "7.1.9",
4543
"electron-builder": "^22.2.0",
4644
"electron-webpack": "^2.7.4",
4745
"node-sass": "^4.13.0",

src/main/app_setup.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { app } from "electron";
2-
import { is } from "electron-util";
3-
import { createMainWindow } from "./window_setup";
1+
const { app } = require("electron");
2+
const { is } = require("electron-util");
3+
const { createMainWindow } = require("./window_setup");
44

55
function preventMultipleAppInstances() {
66
if (!app.requestSingleInstanceLock()) {
@@ -35,9 +35,13 @@ function createWindowOnActivate({ win }) {
3535
});
3636
}
3737

38-
export const setupApp = function({ win }) {
38+
const setupApp = function({ win }) {
3939
preventMultipleAppInstances();
4040
openMinimizedIfAlreadyExists({ win: win });
4141
quitOnWindowsAllClosed();
4242
createWindowOnActivate({ win: win });
4343
};
44+
45+
module.exports = {
46+
setupApp
47+
};

src/main/auto_update.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { is } from "electron-util";
2-
import { autoUpdater } from "electron-updater";
3-
import logger from "electron-log";
1+
const { is } = require("electron-util");
2+
const { autoUpdater } = require("electron-updater");
3+
const logger = require("electron-log");
44

55
const FOUR_HOURS = 1000 * 60 * 60 * 4;
66

@@ -19,7 +19,7 @@ function checkNow() {
1919
autoUpdater.checkForUpdates();
2020
}
2121

22-
export const setupAutoUpdate = function() {
22+
const setupAutoUpdate = function() {
2323
if (is.development) {
2424
return;
2525
}
@@ -28,3 +28,7 @@ export const setupAutoUpdate = function() {
2828
checkPeriodically();
2929
checkNow();
3030
};
31+
32+
module.exports = {
33+
setupAutoUpdate
34+
};

src/main/entrypoint.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/main/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// electron-webpack HMR for development
2-
import { is } from "electron-util";
2+
const is = require("electron-util");
33
if (is.development && module.hot) {
44
module.hot.accept();
55
}
66

7-
import { app } from "electron";
8-
import { setupMenu } from "./menu";
9-
import { init } from "./init";
10-
import { createMainWindow, setupMainWindow } from "./window_setup";
7+
const { app } = require("electron");
8+
const { setupMenu } = require("./menu");
9+
const { init } = require("./init");
10+
const { createMainWindow, setupMainWindow } = require("./window_setup");
1111

1212
// Maintain reference to window to
1313
// prevent it from being garbage collected

src/main/init.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { app } from "electron";
1+
const { app } = require("electron");
22
const unhandled = require("electron-unhandled");
33
const debug = require("electron-debug");
44
const contextMenu = require("electron-context-menu");
55
const packageJson = require("../../package.json");
6-
import { setupAutoUpdate } from "./auto_update";
7-
import { setupApp } from "./app_setup";
6+
const { setupAutoUpdate } = require("./auto_update");
7+
const { setupApp } = require("./app_setup");
88

99
function setupErrorHandling() {
1010
unhandled();
@@ -23,11 +23,15 @@ function setupUserModelId() {
2323
app.setAppUserModelId(packageJson.build.appId);
2424
}
2525

26-
export const init = function({ win }) {
26+
const init = function({ win }) {
2727
setupErrorHandling();
2828
setupDevTools();
2929
setupContextMenu();
3030
setupUserModelId();
3131
setupAutoUpdate();
3232
setupApp({ win: win });
3333
};
34+
35+
module.exports = {
36+
init
37+
};

src/main/menu.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ function buildMenu() {
180180
return Menu.buildFromTemplate(template);
181181
}
182182

183-
export const setupMenu = function() {
183+
const setupMenu = function() {
184184
Menu.setApplicationMenu(buildMenu());
185185
};
186+
187+
module.exports = {
188+
setupMenu
189+
};

src/main/window_setup.js

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { BrowserWindow, ipcMain, app } from "electron";
2-
import { is } from "electron-util";
3-
import url from "url";
4-
import path from "path";
1+
const { BrowserWindow, ipcMain, app } = require("electron");
2+
const { is } = require("electron-util");
3+
const url = require("url");
4+
const path = require("path");
55

66
const DEFAULT_WINDOW_WIDTH = 580;
77
const DEFAULT_WINDOW_HEIGHT = 312;
@@ -10,28 +10,40 @@ function setupMainWindowClose({ win }) {
1010
win.on("closed", () => {
1111
// Dereference the window
1212
// For multiple windows store them in an array
13-
win = undefined;
13+
win = null;
1414
});
1515
}
1616

1717
function showWindowOnReady({ win }) {
18-
win.on("ready-to-show", () => {
18+
win.once("ready-to-show", () => {
1919
win.show();
2020
});
2121
}
2222

23+
function urlForLoad() {
24+
if (is.development) {
25+
const port = process.env.ELECTRON_WEBPACK_WDS_PORT;
26+
if (!port) {
27+
throw "No Electron webpack WDS port set for dev. Try running `yarn run dev` instead for development mode.";
28+
}
29+
30+
return `http://localhost:${port}`;
31+
} else {
32+
return url.format({
33+
pathname: path.join(__dirname, "index.html"),
34+
protocol: "file",
35+
slashes: true
36+
});
37+
}
38+
}
39+
2340
function mainWindowLoadUrl({ win }) {
24-
const urlForLoad = is.development
25-
? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`
26-
: url.format({
27-
pathname: path.join(__dirname, "index.html"),
28-
protocol: "file",
29-
slashes: true
30-
});
31-
win.loadURL(urlForLoad);
41+
const url = urlForLoad();
42+
43+
win.loadURL(url);
3244
}
3345

34-
export const createMainWindow = async function() {
46+
const createMainWindow = async function() {
3547
return new BrowserWindow({
3648
title: app.name,
3749
show: false,
@@ -41,8 +53,13 @@ export const createMainWindow = async function() {
4153
});
4254
};
4355

44-
export const setupMainWindow = function({ win }) {
56+
const setupMainWindow = function({ win }) {
4557
setupMainWindowClose({ win: win });
4658
showWindowOnReady({ win: win });
4759
mainWindowLoadUrl({ win: win });
4860
};
61+
62+
module.exports = {
63+
createMainWindow,
64+
setupMainWindow
65+
};

yarn.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,10 +3223,10 @@ electron-webpack@^2.7.4:
32233223
webpack-merge "^4.2.1"
32243224
yargs "^13.2.4"
32253225

3226-
3227-
version "7.1.8"
3228-
resolved "https://registry.yarnpkg.com/electron/-/electron-7.1.8.tgz#7cd50fdf42c55c9de86ab126e983d23fd89d5d99"
3229-
integrity sha512-1cWT7toVcSTKu3HdnhDQpbTmI5QCSKtIbg+wHUkSZCdAqjPcuH+dpm+j21g38LbE2DoIzdryaN0RTZOqTPebMA==
3226+
3227+
version "7.1.9"
3228+
resolved "https://registry.yarnpkg.com/electron/-/electron-7.1.9.tgz#5053195d2e476a3ecd881ece4edf64f0a8c32fa3"
3229+
integrity sha512-gkzDr08XxRaNZhwPLRXYNXDaPuiAeCrRPcClowlDVfCLKi+kRNhzekZpfYUBq8DdZCD29D3rCtgc9IHjD/xuHw==
32303230
dependencies:
32313231
"@electron/get" "^1.0.1"
32323232
"@types/node" "^12.0.12"
@@ -3622,11 +3622,6 @@ eslint@^6.4.0:
36223622
text-table "^0.2.0"
36233623
v8-compile-cache "^2.0.3"
36243624

3625-
esm@^3.2.25:
3626-
version "3.2.25"
3627-
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10"
3628-
integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
3629-
36303625
espree@^6.0.0, espree@^6.1.1, espree@^6.1.2:
36313626
version "6.1.2"
36323627
resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d"

0 commit comments

Comments
 (0)