move node types, stub node modules
Summary: This diff stubs all node modules when running in the browser, so that, albeit with a lot of errors and without plugins, the UI loads in a browser. To be continued in the rest of this diff Reviewed By: antonk52 Differential Revision: D32665705 fbshipit-source-id: 4632e241f59c5b9712a41d01a26878afb01f69b5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d0402d7268
commit
ad4a55f263
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {RenderHost} from 'flipper-ui-core';
|
||||
import type {RenderHost} from 'flipper-ui-core';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
||||
@@ -14,6 +14,13 @@ import {createFlipperServer} from './flipperServerConnection';
|
||||
document.getElementById('root')!.innerText = 'flipper-ui-browser started';
|
||||
|
||||
async function start() {
|
||||
(global as any).electronRequire = function (path: string) {
|
||||
console.error(
|
||||
`[decapitate] Tried to electronRequire ${path}, this module is not available in the browser and will be stubbed`,
|
||||
);
|
||||
return {};
|
||||
};
|
||||
|
||||
const logger = createDelegatedLogger();
|
||||
setLoggerInstance(logger);
|
||||
|
||||
@@ -28,10 +35,11 @@ async function start() {
|
||||
// before starting the rest of the Flipper process.
|
||||
// This prevent issues where the render host is referred at module initialisation level,
|
||||
// but not set yet, which might happen when using normal imports.
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
// TODO: replace
|
||||
// TODO: remove
|
||||
window.flipperShowError?.('Connected to Flipper Server successfully');
|
||||
// TODO: require('flipper-ui-core').startFlipperDesktop(flipperServer);
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
require('flipper-ui-core').startFlipperDesktop(flipperServer);
|
||||
window.flipperHideError?.();
|
||||
}
|
||||
|
||||
start().catch((e) => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import {FlipperServer, FlipperServerConfig} from 'flipper-common';
|
||||
import {getRenderHostInstance, RenderHost} from 'flipper-ui-core';
|
||||
import {RenderHost} from 'flipper-ui-core';
|
||||
|
||||
export function initializeRenderHost(
|
||||
flipperServer: FlipperServer,
|
||||
@@ -63,10 +63,7 @@ export function initializeRenderHost(
|
||||
flipperServer,
|
||||
async requirePlugin(path) {
|
||||
// TODO: use `await import(path)`?
|
||||
const source = await getRenderHostInstance().flipperServer.exec(
|
||||
'plugin-source',
|
||||
path,
|
||||
);
|
||||
const source = await flipperServer.exec('plugin-source', path);
|
||||
// eslint-disable-next-line no-eval
|
||||
return eval(source);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user