Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
cacheStores: [
new FileStore({
root: path.join(os.tmpdir(), 'metro-cache'),
}),
],
cacheVersion: '1.0',
// We assume the default project path is two levels up from
// node_modules/metro/
projectRoot: projectRoot || path.resolve(__dirname, '../../..'),
stickyWorkers: true,
watchFolders: [],
transformerPath: require.resolve('metro/src/JSTransformer/worker.js'),
maxWorkers: getMaxWorkers(),
resetCache: false,
reporter: new TerminalReporter(new Terminal(process.stdout)),
});
* @flow
* @format
*/
'use strict';
const MetroApi = require('../index');
const TerminalReporter = require('../lib/TerminalReporter');
const {makeAsyncCommand} = require('../cli-utils');
const {loadConfig} = require('metro-config');
const {Terminal} = require('metro-core');
import typeof Yargs from 'yargs';
const term = new Terminal(process.stdout);
const updateReporter = new TerminalReporter(term);
module.exports = (): {|
builder: (yargs: Yargs) => void,
command: string,
description: string,
handler: (argv: any) => void,
|} => ({
command: 'build ',
description:
'Generates a JavaScript bundle containing the specified entrypoint and its descendants',
builder: (yargs: Yargs): void => {
yargs.option('project-roots', {
alias: 'P',
async function runServer(argv: *, ctx: ContextT, args: Args) {
const terminal = new Terminal(process.stdout);
const ReporterImpl = getReporterImpl(args.customLogReporterPath || null);
const reporter = new ReporterImpl(terminal);
const metroConfig = await loadMetroConfig(ctx, {
config: args.config,
maxWorkers: args.maxWorkers,
port: args.port,
resetCache: args.resetCache,
watchFolders: args.watchFolders,
sourceExts: args.sourceExts,
reporter,
});
const middlewareManager = new MiddlewareManager({
host: args.host,
port: metroConfig.server.port,
async function convertOldToNew({
config,
resetCache = false,
maxWorkers = getMaxWorkers(),
minifierPath,
port = null,
reporter = new TerminalReporter(new Terminal(process.stdout)),
}: PublicMetroOptions): Promise {
const {
getBlacklistRE,
cacheStores,
createModuleIdFactory,
cacheVersion,
getProjectRoot,
getWatchFolders,
getTransformModulePath,
resolveRequest,
getAssetExts,
getPlatforms,
getResolverMainFields,
getSourceExts,
hasteImplModulePath,
dynamicDepsInPackages,
async function runServer(_argv: Array, ctx: Config, args: Args) {
const terminal = new Terminal(process.stdout);
const ReporterImpl = getReporterImpl(args.customLogReporterPath);
const reporter = new ReporterImpl(terminal);
const metroConfig = await loadMetroConfig(ctx, {
config: args.config,
maxWorkers: args.maxWorkers,
port: args.port,
resetCache: args.resetCache,
watchFolders: args.watchFolders,
projectRoot: args.projectRoot,
sourceExts: args.sourceExts,
reporter,
});
if (args.assetPlugins) {
metroConfig.transformer.assetPlugins = args.assetPlugins.map(plugin =>
const Router = require('router');
const fs = require('fs');
const metro = require('metro');
const {initializeGraphRoutes} = require('./graph-api/routes');
const {Terminal} = require('metro-core');
const {parse} = require('url');
import type {MetroHistory} from './metroHistory.js';
import type {Graph} from 'metro/src/DeltaBundler';
import type Server from 'metro/src/Server';
import type {GraphId} from 'metro/src/lib/getGraphId';
const router = Router();
const terminal = new Terminal(process.stdout);
let metroServer: Server;
let metroHistory: MetroHistory;
function initializeMiddlewareRoutes(server: Server, history: MetroHistory) {
metroServer = server;
metroHistory = history;
return router;
}
router.get('/', (req, res) => {
const status = 'Launching visualizer';
terminal.status(status);
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(
* @flow
* @format
*/
'use strict';
const MetroApi = require('../index');
const TerminalReporter = require('../lib/TerminalReporter');
const {makeAsyncCommand} = require('../cli-utils');
const {loadConfig} = require('metro-config');
const {Terminal} = require('metro-core');
import typeof Yargs from 'yargs';
const term = new Terminal(process.stdout);
const updateReporter = new TerminalReporter(term);
module.exports = () => ({
command: 'build ',
description:
'Generates a JavaScript bundle containing the specified entrypoint and its descendants',
builder: (yargs: Yargs): void => {
yargs.option('project-roots', {
alias: 'P',
type: 'string',
array: true,
});
yargs.option('out', {alias: 'O', type: 'string', demandOption: true});