From acedcf750b012ad23b2f3376e2baf671f2cdaa05 Mon Sep 17 00:00:00 2001 From: rhysd Date: Tue, 25 Apr 2017 17:37:10 +0900 Subject: [PATCH] remove browserify workaround --- package.json | 4 ++-- renderer/ipc.ts | 4 +--- renderer/key_handler.ts | 5 ++--- renderer/plugins.ts | 3 +-- renderer/require.ts | 4 ---- typings/browserify_workaround.d.ts | 6 ------ 6 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 renderer/require.ts delete mode 100644 typings/browserify_workaround.d.ts diff --git a/package.json b/package.json index 1fd8021..8a908b4 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ }, "scripts": { "build:ts": "tsc --pretty -p .", - "build:bundle": "NODE_ENV=development browserify renderer/index.js -o renderer/preload.js", + "build:bundle": "NODE_ENV=development browserify -x electron renderer/index.js -o renderer/preload.js", "build": "npm run build:ts && npm run build:bundle", - "build:bundle:release": "NODE_ENV=production browserify renderer/index.js -o renderer/preload.js", + "build:bundle:release": "NODE_ENV=production browserify -x electron renderer/index.js -o renderer/preload.js", "build:release": "npm run build:ts && npm run build:bundle:release", "test": "echo \"Error: no test specified\" && exit 1", "lint": "tslint --project tsconfig.json --type-check $(git ls-files | grep -E \"\\.ts$\")", diff --git a/renderer/ipc.ts b/renderer/ipc.ts index a36fbc8..81d7393 100644 --- a/renderer/ipc.ts +++ b/renderer/ipc.ts @@ -1,7 +1,5 @@ +import {ipcRenderer as ipc} from 'electron'; import log from './log'; -import r from './require'; -const electron = r('electron'); -const ipc = electron.ipcRenderer; export function on(channel: IpcChannelFromMain, callback: (...args: any[]) => void) { ipc.on(channel, (_, ...args: any[]) => { diff --git a/renderer/key_handler.ts b/renderer/key_handler.ts index 32e627d..b8c31fd 100644 --- a/renderer/key_handler.ts +++ b/renderer/key_handler.ts @@ -1,10 +1,9 @@ import * as path from 'path'; +import {remote} from 'electron'; import * as Mousetrap from 'mousetrap'; import * as Ipc from './ipc'; import log from './log'; import {Config, Account} from '../main/config'; -import r from './require'; -const shell = r('electron').remote.shell; function scrollable() { const scrollable = document.querySelector('.scrollable'); @@ -52,7 +51,7 @@ const ShortcutActions = { Ipc.send('mstdn:prev-account'); }, 'open-in-browser': () => { - shell.openExternal(window.location.href); + remote.shell.openExternal(window.location.href); } } as {[action: string]: () => void}; diff --git a/renderer/plugins.ts b/renderer/plugins.ts index 3eecbd1..e5ac8a9 100644 --- a/renderer/plugins.ts +++ b/renderer/plugins.ts @@ -1,6 +1,5 @@ import * as path from 'path'; import {Config, Account} from '../main/config'; -import r from './require'; import log from './log'; interface Plugin { @@ -27,7 +26,7 @@ export default class PluginsLoader { for (const plugin of this.account.plugins || []) { const plugin_path = path.join(dir_base, `mstdn-plugin-${plugin}`); try { - this.preloads[plugin_path] = r(plugin_path) as Plugin; + this.preloads[plugin_path] = require(plugin_path) as Plugin; } catch (e) { log.error(`Failed to load plugin ${plugin_path}:`, e); } diff --git a/renderer/require.ts b/renderer/require.ts deleted file mode 100644 index 918594e..0000000 --- a/renderer/require.ts +++ /dev/null @@ -1,4 +0,0 @@ -// In preload script, global.require does not exist. -// So we need to wrap require() to avoid to be bundled. - -export default require; diff --git a/typings/browserify_workaround.d.ts b/typings/browserify_workaround.d.ts deleted file mode 100644 index b369cee..0000000 --- a/typings/browserify_workaround.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace NodeJS { - interface Global { - require: NodeRequireFunction; - } -} -