oldConfig.js.flow 2.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
/**
 * 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.
 *
 * @flow
 * @format
 */

'use strict';

const blacklist = require('./defaults/blacklist');
const os = require('os');
const path = require('path');

const {
  defaultCreateModuleIdFactory,
  platforms,
} = require('./defaults/defaults');
const {FileStore} = require('metro-cache');

import type {OldConfigT as ConfigT} from './configTypes.flow.js';

const DEFAULT = ({
  assetRegistryPath: 'missing-asset-registry-path',
  enhanceMiddleware: middleware => middleware,
  extraNodeModules: {},
  cacheStores: [
    new FileStore({
      root: path.join(os.tmpdir(), 'metro-cache'),
    }),
  ],
  cacheVersion: '1.0',
  createModuleIdFactory: defaultCreateModuleIdFactory,
  dynamicDepsInPackages: 'throwAtRuntime',
  getAsyncRequireModulePath: () => 'metro/src/lib/bundle-modules/asyncRequire',
  getAssetExts: () => [],
  getBlacklistRE: () => blacklist(),
  getEnableBabelRCLookup: () => true,
  getPlatforms: () => platforms,
  getPolyfillModuleNames: () => [],
  getProjectRoots: undefined,
  // We assume the default project path is two levels up from
  // node_modules/metro/
  getProjectRoot: () => path.resolve(__dirname, '../../..'),
  getWatchFolders: () => [],
  getRunModuleStatement: (moduleId: number | string) =>
    `__r(${JSON.stringify(moduleId)});`,
  getSourceExts: () => [],
  getTransformModulePath: () => 'metro-babel-transformer',
  getTransformOptions: async () => ({
    transform: {
      experimentalImportSupport: false,
      inlineRequires: false,
      unstable_disableES6Transforms: false,
    },
    preloadedModules: false,
    ramGroups: [],
  }),
  getPolyfills: () => [],
  getUseGlobalHotkey: () => true,
  postMinifyProcess: x => x,
  postProcessBundleSourcemap: ({code, map, outFileName}) => ({code, map}),
  resolveRequest: null,
  getResolverMainFields: () => ['browser', 'main'],
  getModulesRunBeforeMainModule: () => [],
  getWorkerPath: () => 'metro/src/DeltaBundler/Worker',
  processModuleFilter: module => true,
  transformVariants: () => ({default: {}}),
  virtualMapper: file => [file],
}: ConfigT);

module.exports = {
  DEFAULT,
};