Make `assetTransforms` option available to the new metro CLI

Reviewed By: arcanis

Differential Revision: D6424404

fbshipit-source-id: 30c56128b914d86491fce6276775d75e7b497146
This commit is contained in:
Burak Yigit Kaya 2017-11-28 06:40:59 -08:00 committed by Facebook Github Bot
parent 37995e2196
commit cf9ef1b30f
2 changed files with 11 additions and 7 deletions

View File

@ -66,7 +66,7 @@ exports.handler = makeAsyncCommand(async (argv: any) => {
}
if (server) {
console.log('Configuration changed... restarting the server...');
console.log('Configuration changed. Restarting the server...');
await promisify(server.close).call(server);
}

View File

@ -79,10 +79,12 @@ async function runMetro({
}: PrivateMetroOptions) {
const normalizedConfig = config ? normalizeConfig(config) : DEFAULT_CONFIG;
const assetExts =
(normalizedConfig.getAssetExts && normalizedConfig.getAssetExts()) || [];
const sourceExts =
(normalizedConfig.getSourceExts && normalizedConfig.getSourceExts()) || [];
const assetExts = defaultAssetExts.concat(
(normalizedConfig.getAssetExts && normalizedConfig.getAssetExts()) || [],
);
const sourceExts = defaultSourceExts.concat(
(normalizedConfig.getSourceExts && normalizedConfig.getSourceExts()) || [],
);
const platforms =
(normalizedConfig.getPlatforms && normalizedConfig.getPlatforms()) || [];
@ -96,7 +98,7 @@ async function runMetro({
: defaultProvidesModuleNodeModules;
const serverOptions: ServerOptions = {
assetExts: defaultAssetExts.concat(assetExts),
assetExts: normalizedConfig.assetTransforms ? [] : assetExts,
assetRegistryPath: normalizedConfig.assetRegistryPath,
blacklistRE: normalizedConfig.getBlacklistRE(),
extraNodeModules: normalizedConfig.extraNodeModules,
@ -114,7 +116,9 @@ async function runMetro({
providesModuleNodeModules,
resetCache: false,
reporter: new TerminalReporter(new Terminal(process.stdout)),
sourceExts: defaultSourceExts.concat(sourceExts),
sourceExts: normalizedConfig.assetTransforms
? sourceExts.concat(assetExts)
: sourceExts,
transformCache: TransformCaching.useTempDir(),
transformModulePath,
watch,