1
0
mirror of https://github.com/rhysd/Mstdn.git synced 2025-01-21 20:52:11 +01:00

remove browserify workaround

This commit is contained in:
rhysd 2017-04-25 17:37:10 +09:00
parent 3d4237e677
commit acedcf750b
6 changed files with 6 additions and 20 deletions

View File

@ -9,9 +9,9 @@
}, },
"scripts": { "scripts": {
"build:ts": "tsc --pretty -p .", "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": "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", "build:release": "npm run build:ts && npm run build:bundle:release",
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"lint": "tslint --project tsconfig.json --type-check $(git ls-files | grep -E \"\\.ts$\")", "lint": "tslint --project tsconfig.json --type-check $(git ls-files | grep -E \"\\.ts$\")",

View File

@ -1,7 +1,5 @@
import {ipcRenderer as ipc} from 'electron';
import log from './log'; 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) { export function on(channel: IpcChannelFromMain, callback: (...args: any[]) => void) {
ipc.on(channel, (_, ...args: any[]) => { ipc.on(channel, (_, ...args: any[]) => {

View File

@ -1,10 +1,9 @@
import * as path from 'path'; import * as path from 'path';
import {remote} from 'electron';
import * as Mousetrap from 'mousetrap'; import * as Mousetrap from 'mousetrap';
import * as Ipc from './ipc'; import * as Ipc from './ipc';
import log from './log'; import log from './log';
import {Config, Account} from '../main/config'; import {Config, Account} from '../main/config';
import r from './require';
const shell = r('electron').remote.shell;
function scrollable() { function scrollable() {
const scrollable = document.querySelector('.scrollable'); const scrollable = document.querySelector('.scrollable');
@ -52,7 +51,7 @@ const ShortcutActions = {
Ipc.send('mstdn:prev-account'); Ipc.send('mstdn:prev-account');
}, },
'open-in-browser': () => { 'open-in-browser': () => {
shell.openExternal(window.location.href); remote.shell.openExternal(window.location.href);
} }
} as {[action: string]: () => void}; } as {[action: string]: () => void};

View File

@ -1,6 +1,5 @@
import * as path from 'path'; import * as path from 'path';
import {Config, Account} from '../main/config'; import {Config, Account} from '../main/config';
import r from './require';
import log from './log'; import log from './log';
interface Plugin { interface Plugin {
@ -27,7 +26,7 @@ export default class PluginsLoader {
for (const plugin of this.account.plugins || []) { for (const plugin of this.account.plugins || []) {
const plugin_path = path.join(dir_base, `mstdn-plugin-${plugin}`); const plugin_path = path.join(dir_base, `mstdn-plugin-${plugin}`);
try { try {
this.preloads[plugin_path] = r(plugin_path) as Plugin; this.preloads[plugin_path] = require(plugin_path) as Plugin;
} catch (e) { } catch (e) {
log.error(`Failed to load plugin ${plugin_path}:`, e); log.error(`Failed to load plugin ${plugin_path}:`, e);
} }

View File

@ -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;

View File

@ -1,6 +0,0 @@
declare namespace NodeJS {
interface Global {
require: NodeRequireFunction;
}
}