Make loading of bundled plugins working and robust

Summary:
Bundled plugins so far didn't load because the defaultPlugins was not generated yet. Fixed follow up errors that resulted from node modules not being available in the browser, and made the process more robust so that one plugin that fails to initialise doesn't kill all bundled plugins from being loaded.

Cleaned up the server scripts, and reused the BUILTINS list that is already maintained in the babel transformer.

Report errors during the build process if modules are referred that are stubbed out (later on we could maybe error on that)

Reviewed By: aigoncharov

Differential Revision: D33020243

fbshipit-source-id: 3ce13b0049664b5fb19c1f45f0b33c1d7fdbea4c
This commit is contained in:
Michel Weststrate
2021-12-13 05:46:42 -08:00
committed by Facebook GitHub Bot
parent 5564251aac
commit 5ce5d897c8
9 changed files with 108 additions and 85 deletions

View File

@@ -7,15 +7,17 @@
* @format
*/
const dotenv = require('dotenv').config();
import child from 'child_process';
import chalk from 'chalk';
import path from 'path';
import {compileServerMain} from './build-utils';
import {compileServerMain, prepareDefaultPlugins} from './build-utils';
import Watchman from './watchman';
import {serverDir} from './paths';
import isFB from './isFB';
import yargs from 'yargs';
import open from 'open';
import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable';
const argv = yargs
.usage('yarn start [args]')
@@ -191,10 +193,20 @@ async function startWatchChanges() {
}
(async () => {
if (dotenv && dotenv.parsed) {
console.log('✅ Loaded env vars from .env file: ', dotenv.parsed);
}
await prepareDefaultPlugins(
process.env.FLIPPER_RELEASE_CHANNEL === 'insiders',
);
// build?
if (argv['build']) {
await compileServerMain();
} else {
// watch
await startWatchChanges();
await ensurePluginFoldersWatchable();
// builds and starts
await restartServer();