Add server add-on babel transform
Reviewed By: antonk52 Differential Revision: D34393126 fbshipit-source-id: d910392d9ac7e7a44e2e9ede690a6bed77f018c7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
01a5f3da90
commit
9449f61adb
47
desktop/babel-transformer/src/transform-server-add-on.tsx
Normal file
47
desktop/babel-transformer/src/transform-server-add-on.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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 {default as doTransform} from './transform';
|
||||
import {default as getCacheKey} from './get-cache-key';
|
||||
|
||||
// Copy-paste from transform-plugin with @babel/preset-env instead of @babel/preset-react
|
||||
|
||||
const presets = [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const plugins = [
|
||||
require('./electron-requires'),
|
||||
require('./plugin-flipper-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});
|
||||
}
|
||||
@@ -166,9 +166,7 @@ export default async function bundlePlugin(
|
||||
dev,
|
||||
sourceMapPath: options?.sourceMapPathServerAddOn,
|
||||
babelTransformerPath: require.resolve(
|
||||
`flipper-babel-transformer/${
|
||||
dev ? 'lib/transform-server-dev' : 'lib/transform-server-prod'
|
||||
}`,
|
||||
'flipper-babel-transformer/lib/transform-server-add-on',
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user