Summary: Flipper server itself requires no babel transforms. We applied extra transforms only for the bundled plugins. However, we pack and ship all plugins in the /static folder. They are always available on the FS. Therefore we could stop bundling any plugins into flipper-server's source code. Reviewed By: lblasa Differential Revision: D38910251 fbshipit-source-id: b3e9fe5ae2ab69ce5579b01b6793ebf7e88baf66
35 lines
872 B
TypeScript
35 lines
872 B
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import Module from 'module';
|
|
|
|
Module.prototype.require = new Proxy(Module.prototype.require, {
|
|
apply(target, thisArg, argumentsList) {
|
|
const name = argumentsList[0];
|
|
|
|
if (
|
|
process.env.FLIPPER_FORCE_PUBLIC_BUILD !== 'true' &&
|
|
typeof name === 'string' &&
|
|
name.includes('fb-stubs')
|
|
) {
|
|
const replacement = name.replace('/fb-stubs/', '/fb/');
|
|
try {
|
|
return Reflect.apply(target, thisArg, [
|
|
replacement,
|
|
argumentsList.slice(1),
|
|
]);
|
|
} catch {
|
|
return Reflect.apply(target, thisArg, argumentsList);
|
|
}
|
|
}
|
|
|
|
return Reflect.apply(target, thisArg, argumentsList);
|
|
},
|
|
});
|