Skip to content

Commit

Permalink
Export Config/defaults on Metro's main module
Browse files Browse the repository at this point in the history
Reviewed By: arcanis

Differential Revision: D6435529

fbshipit-source-id: a9549dc5900025fcc798ccb92b49e96c982c2e1e
  • Loading branch information
cpojer authored and facebook-github-bot committed Nov 29, 2017
1 parent 654fed4 commit 0091496
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
16 changes: 9 additions & 7 deletions local-cli/bundle/buildBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,27 @@ const TerminalReporter = require('metro/src/lib/TerminalReporter');
* run Flow. */
const TransformCaching = require('metro/src/lib/TransformCaching');

const {defaults} = require('metro');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const outputBundle = require('metro/src/shared/output/bundle');
const path = require('path');
const saveAssets = require('./saveAssets');
const defaultAssetExts = require('metro/src/defaults').assetExts;
const defaultSourceExts = require('metro/src/defaults').sourceExts;
const defaultPlatforms = require('metro/src/defaults').platforms;
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const defaultProvidesModuleNodeModules = require('metro/src/defaults').providesModuleNodeModules;

const {ASSET_REGISTRY_PATH} = require('../core/Constants');

import type {RequestOptions, OutputOptions} from './types.flow';
import type {ConfigT} from 'metro';

const defaultAssetExts = defaults.assetExts;
const defaultSourceExts = defaults.sourceExts;
const defaultPlatforms = defaults.platforms;
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const defaultProvidesModuleNodeModules = defaults.providesModuleNodeModules;

async function buildBundle(
args: OutputOptions & {
assetsDest: mixed,
Expand Down
14 changes: 7 additions & 7 deletions local-cli/server/runServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require('../../setupBabel')();
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const ReactPackager = require('metro');
const Metro = require('metro');

const HmrServer = require('metro/src/HmrServer');

Expand All @@ -31,14 +31,14 @@ const attachWebsocketServer = require('./util/attachWebsocketServer');
* run Flow. */
const connect = require('connect');
const copyToClipBoardMiddleware = require('./middleware/copyToClipBoardMiddleware');
const defaultAssetExts = require('metro/src/defaults').assetExts;
const defaultSourceExts = require('metro/src/defaults').sourceExts;
const defaultPlatforms = require('metro/src/defaults').platforms;
const defaultAssetExts = Metro.defaults.assetExts;
const defaultSourceExts = Metro.defaults.sourceExts;
const defaultPlatforms = Metro.defaults.platforms;
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const defaultProvidesModuleNodeModules = require('metro/src/defaults')
.providesModuleNodeModules;
const defaultProvidesModuleNodeModules =
Metro.defaults.providesModuleNodeModules;
const fs = require('fs');
const getDevToolsMiddleware = require('./middleware/getDevToolsMiddleware');
const http = require('http');
Expand Down Expand Up @@ -178,7 +178,7 @@ function getPackagerServer(args, config, reporter) {
const providesModuleNodeModules =
args.providesModuleNodeModules || defaultProvidesModuleNodeModules;

return ReactPackager.createServer({
return Metro.createServer({
assetExts: defaultAssetExts.concat(args.assetExts),
assetRegistryPath: ASSET_REGISTRY_PATH,
blacklistRE: config.getBlacklistRE(),
Expand Down

2 comments on commit 0091496

@janicduplessis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer Could you do a metro release, this currently breaks rn master since the export doesn’t exist in the latest published metro version.

@cpojer
Copy link
Contributor Author

@cpojer cpojer commented on 0091496 Dec 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do today.

Please sign in to comment.