Make flipper-server NPX-able
Summary: Make sure flipper-server is bundled in such a way that it is self-contained NPX-able. Also added some checks to make sure that dev dependencies don't accidentallly end up in in Flipper buidls Reviewed By: nikoant Differential Revision: D33190254 fbshipit-source-id: 443162e537d8ca9f956acac2d7bd52cbf0c92172
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6ff4abbc67
commit
86b6d2c99d
@@ -45,7 +45,12 @@ const BUILTINS = [
|
||||
'v8',
|
||||
'repl',
|
||||
'timers',
|
||||
// MWE node-fetch looks strange here, not sure what the effect of changing that would be
|
||||
'node-fetch',
|
||||
// jest is referred to in source code, like in TestUtils, but we don't want to ever bundle it up!
|
||||
'jest',
|
||||
'@testing-library/react',
|
||||
'@testing-library/dom',
|
||||
];
|
||||
|
||||
const IGNORED_MODULES = [
|
||||
|
||||
@@ -20,6 +20,8 @@ const presets = [
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
// In DEV builds, we keep node_modules as is, as to not waste resources on trying to bundle them
|
||||
const plugins = [require('./electron-requires-server'), require('./fb-stubs')];
|
||||
|
||||
module.exports = {
|
||||
46
desktop/babel-transformer/src/transform-server-prod.ts
Normal file
46
desktop/babel-transformer/src/transform-server-prod.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its 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 {default as doTransform} from './transform';
|
||||
import {default as getCacheKey} from './get-cache-key';
|
||||
|
||||
const presets = [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
// In PROD builds, we bundle up all node_modules as well, so that there is a single JS file to run in the end, without
|
||||
// needing to install deps for either flipper-server or flipper-server-core.
|
||||
// This is also the reason that all server deps are DEV deps
|
||||
// electron-requires makes sure that *only* requires of built in node_modules are using "electronRequire"
|
||||
// (which effectively makes them external, as electronRequire === require, but not rolled up with Metro)
|
||||
const plugins = [require('./electron-requires'), require('./fb-stubs')];
|
||||
|
||||
module.exports = {
|
||||
transform,
|
||||
getCacheKey,
|
||||
};
|
||||
|
||||
function transform({
|
||||
filename,
|
||||
options,
|
||||
src,
|
||||
}: {
|
||||
filename: string;
|
||||
options: any;
|
||||
src: string;
|
||||
}) {
|
||||
return doTransform({filename, options, src, presets, plugins});
|
||||
}
|
||||
Reference in New Issue
Block a user