Fix flipper-server build

Summary:
flipper-server build fails when a server add-on uses one of the ignored modules.
For instance, React DevTools is goin got use `ws` which has an optional dependency on `utf-8-validate` and `bufferutil`. Even though it is optional, it is still required, and therefore picked up by Metro.
This way it is silently ignored.

Reviewed By: mweststrate

Differential Revision: D34716514

fbshipit-source-id: a9d463d2d5d7c954e35d9a16f3da44ce17615673
This commit is contained in:
Andrey Goncharov
2022-03-31 04:01:33 -07:00
committed by Facebook GitHub Bot
parent 26ea544f82
commit b1bc31044d
2 changed files with 10 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ import {CallExpression} from '@babel/types';
import {NodePath} from '@babel/traverse';
import {resolve} from 'path';
import {BUILTINS} from './electron-requires';
import {BUILTINS, IGNORED_MODULES} from './electron-requires';
const pluginsRootDir = resolve(__dirname, '../../plugins');
@@ -44,7 +44,13 @@ module.exports = () => ({
// yet we should exclude built-ins
!(
BUILTINS.includes(source) ||
BUILTINS.some((moduleName) => source.startsWith(`${moduleName}/`))
BUILTINS.some((moduleName) =>
source.startsWith(`${moduleName}/`),
) ||
IGNORED_MODULES.includes(source) ||
IGNORED_MODULES.some((moduleName) =>
source.startsWith(`${moduleName}/`),
)
))
) {
return;

View File

@@ -53,7 +53,7 @@ export const BUILTINS = [
'@testing-library/dom',
];
const IGNORED_MODULES = [
export const IGNORED_MODULES = [
'bufferutil',
'utf-8-validate',
'spawn-sync',
@@ -92,3 +92,4 @@ module.exports = () => ({
// used by startWebServerDev to know which modules to stub
module.exports.BUILTINS = BUILTINS;
module.exports.IGNORED_MODULES = IGNORED_MODULES;