Branding: "packager" -> "Metro Bundler"

Summary:
This diff renames all the stragglers in comments and strings from variations of "packager" to "Metro Bundler". I did one of three:

* Rename "packager" to "Metro Bundler"
* Rename "react-native-packager" to "Metro Bundler"
* Remove "packager" when code inside of Metro implies that it's about Metro

I also removed `Glossary.md` because it is unmaintained and very old. mjesun is currently starting to write documentation for Metro which will supersede whatever was there before.

Reviewed By: mjesun

Differential Revision: D5802993

fbshipit-source-id: ba99cb5ed04d84b0f7b7a8a0bf28ed99280a940a
This commit is contained in:
Christoph Nakazawa 2017-09-11 19:32:32 -07:00 committed by Facebook Github Bot
parent 467fa563fe
commit 86a943bbcd
16 changed files with 50 additions and 73 deletions

View File

@ -1,22 +0,0 @@
Glossary
===
Terminology commonly used in React Native Packager / Metro Bundler is explained
here. This document is work in progress, please help completing it.
## Build Root
Configuration files (`rn-cli.config.js`) support configuring one or more roots
that are watched for file changes during development. In the context of the
integration with the `js_*` rule family in [Buck][], there is only a single root,
the build root used by Buck.
## Local Path
A *local path* / `localPath` is the path to a file relative to a
[*build root*](#build-root).
[Buck]: http://buckbuild.com/

View File

@ -176,7 +176,7 @@ class Bundler {
});
const cacheKeyParts = [
'react-packager-cache',
'metro-bundler-cache',
VERSION,
opts.cacheVersion,
stableProjectRoots.join(',').split(pathSeparator).join('-'),

View File

@ -33,7 +33,7 @@ describe('Logger', () => {
expect(logEntry).toEqual({
log_entry_label: 'Test',
log_session: jasmine.any(String),
packager_version: jasmine.any(String),
metro_bundler_version: jasmine.any(String),
});
});
@ -44,7 +44,7 @@ describe('Logger', () => {
action_phase: 'start',
log_entry_label: 'Test',
log_session: jasmine.any(String),
packager_version: jasmine.any(String),
metro_bundler_version: jasmine.any(String),
start_timestamp: jasmine.any(Object),
});
});
@ -57,7 +57,7 @@ describe('Logger', () => {
duration_ms: jasmine.any(Number),
log_entry_label: 'Test',
log_session: jasmine.any(String),
packager_version: jasmine.any(String),
metro_bundler_version: jasmine.any(String),
start_timestamp: jasmine.any(Object),
});
});

View File

@ -36,7 +36,7 @@ function createEntry(data: LogEntry | string): LogEntry {
return {
...logEntry,
log_session,
packager_version: VERSION,
metro_bundler_version: VERSION,
};
}

View File

@ -173,8 +173,8 @@ function loadModuleImplementation(moduleId, module) {
}
// keep args in sync with with defineModuleCode in
// packager/src//Resolver/index.js
// and packager/src//ModuleGraph/worker.js
// metro-bundler/src/Resolver/index.js
// and metro-bundler/src/ModuleGraph/worker.js
factory(global, require, moduleObject, exports, dependencyMap);
// avoid removing factory in DEV mode as it breaks HMR
@ -202,8 +202,8 @@ function unknownModuleError(id) {
let message = 'Requiring unknown module "' + id + '".';
if (__DEV__) {
message +=
'If you are sure the module is there, try restarting the packager. ' +
'You may also want to run `npm install`, or `yarn` (depending on your environment).';
'If you are sure the module is there, try restarting Metro Bundler. ' +
'You may also want to run `yarn`, or `npm install` (depending on your environment).';
}
return Error(message);
}

View File

@ -1146,7 +1146,7 @@ class Server {
JSON.stringify({
type: 'InternalError',
message:
'react-packager has encountered an internal error, ' +
'Metro Bundler has encountered an internal error, ' +
'please check your terminal error output for more details',
}),
);

View File

@ -30,7 +30,7 @@ function escapeRegExp(pattern) {
// convert the '/' into an escaped local file separator
return escaped.replace(/\//g, '\\' + path.sep);
} else {
throw new Error('Unexpected packager blacklist pattern: ' + pattern);
throw new Error('Unexpected blacklist pattern: ' + pattern);
}
}

View File

@ -96,7 +96,7 @@ exports.getOrderedDependencyPaths = function(options: Options, depOptions: {
};
function enableDebug() {
// react-packager logs debug messages using the 'debug' npm package, and uses
// Metro Bundler logs debug messages using the 'debug' npm package, and uses
// the following prefix throughout.
// To enable debugging, we need to set our pattern or append it to any
// existing pre-configured pattern to avoid disabling logging for

View File

@ -138,7 +138,7 @@ function loadModuleImplementation(moduleId, module) {
function unknownModuleError(id) {
var message = 'Requiring unknown module \\"' + id + '\\".';
if (__DEV__) {
message += 'If you are sure the module is there, try restarting the packager. ' + 'You may also want to run \`npm install\`, or \`yarn\` (depending on your environment).';
message += 'If you are sure the module is there, try restarting Metro Bundler. ' + 'You may also want to run \`yarn\`, or \`npm install\` (depending on your environment).';
}
return Error(message);
}
@ -411,7 +411,7 @@ function loadModuleImplementation(moduleId, module) {
function unknownModuleError(id) {
var message = 'Requiring unknown module \\"' + id + '\\".';
if (__DEV__) {
message += 'If you are sure the module is there, try restarting the packager. ' + 'You may also want to run \`npm install\`, or \`yarn\` (depending on your environment).';
message += 'If you are sure the module is there, try restarting Metro Bundler. ' + 'You may also want to run \`yarn\`, or \`npm install\` (depending on your environment).';
}
return Error(message);
}

View File

@ -13,7 +13,7 @@
jest.useRealTimers().unmock('fs').unmock('graceful-fs');
const Packager = require('../..');
const Metro = require('../..');
const path = require('path');
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30 * 1000;
@ -93,12 +93,12 @@ describe('basic_bundle', () => {
}
it('bundles package with polyfills', async () => {
const bundleWithPolyfills = await Packager.buildBundle(
const bundleWithPolyfills = await Metro.buildBundle(
{
assetRegistryPath: ASSET_REGISTRY_PATH,
getPolyfills: () => [polyfill1, polyfill2],
projectRoots: [INPUT_PATH, POLYFILLS_PATH],
transformCache: Packager.TransformCaching.none(),
transformCache: Metro.TransformCaching.none(),
transformModulePath: require.resolve('../../transformer'),
nonPersistent: true,
},
@ -112,12 +112,12 @@ describe('basic_bundle', () => {
});
it('bundles package without polyfills', async () => {
const bundleWithoutPolyfills = await Packager.buildBundle(
const bundleWithoutPolyfills = await Metro.buildBundle(
{
assetRegistryPath: ASSET_REGISTRY_PATH,
getPolyfills: () => [],
projectRoots: [INPUT_PATH, POLYFILLS_PATH],
transformCache: Packager.TransformCaching.none(),
transformCache: Metro.TransformCaching.none(),
transformModulePath: require.resolve('../../transformer'),
nonPersistent: true,
},

View File

@ -163,15 +163,15 @@ class TerminalReporter {
}
}
_logPackagerInitializing(port: number, projectRoots: $ReadOnlyArray<string>) {
_logInitializing(port: number, projectRoots: $ReadOnlyArray<string>) {
this.terminal.log(
formatBanner(
'Running packager on port ' +
'Running Metro Bundler on port ' +
port +
'.\n\n' +
'Keep this packager running while developing on any JS projects. ' +
'Feel free to close this tab and run your own packager instance ' +
'if you prefer.\n\n' +
'Keep Metro Bundler running while developing on any JS projects. ' +
'Feel free to close this tab and run your own Metro Bundler ' +
' instance if you prefer.\n\n' +
'https://github.com/facebook/react-native',
{
marginLeft: 1,
@ -188,11 +188,11 @@ class TerminalReporter {
);
}
_logPackagerInitializingFailed(port: number, error: Error) {
_logInitializingFailed(port: number, error: Error) {
if (error.code === 'EADDRINUSE') {
this.terminal.log(
chalk.bgRed.bold(' ERROR '),
chalk.red("Packager can't listen on port", chalk.bold(port)),
chalk.red('Metro Bundler can\'t listen on port', chalk.bold(port)),
);
this.terminal.log(
'Most likely another process is already using this port',
@ -201,7 +201,7 @@ class TerminalReporter {
this.terminal.log('\n ', chalk.bold('lsof -i :' + port), '\n');
this.terminal.log('Then, you can either shut down the other process:');
this.terminal.log('\n ', chalk.bold('kill -9 <PID>'), '\n');
this.terminal.log('or run packager on different port.');
this.terminal.log('or run Metro Bundler on different port.');
} else {
this.terminal.log(chalk.bgRed.bold(' ERROR '), chalk.red(error.message));
const errorAttributes = JSON.stringify(error);
@ -218,14 +218,14 @@ class TerminalReporter {
*/
_log(event: TerminalReportableEvent): void {
switch (event.type) {
case 'initialize_packager_started':
this._logPackagerInitializing(event.port, event.projectRoots);
case 'initialize_started':
this._logInitializing(event.port, event.projectRoots);
break;
case 'initialize_packager_done':
this.terminal.log('\nReact packager ready.\n');
case 'initialize_done':
this.terminal.log('\nMetro Bundler ready.\n');
break;
case 'initialize_packager_failed':
this._logPackagerInitializingFailed(event.port, event.error);
case 'initialize_failed':
this._logInitializingFailed(event.port, event.error);
break;
case 'bundle_build_done':
this._logBundleBuildDone(event.buildID);

View File

@ -90,7 +90,7 @@ class FileBasedCache {
/**
* The root path is where the data will be stored. It shouldn't contain
* other files other than the cache's own files, so it should start empty
* when the packager is first run. When doing a cache reset, it may be
* when Metro Bundler is first run. When doing a cache reset, it may be
* completely deleted.
*/
constructor(rootPath: string) {
@ -259,7 +259,7 @@ class FileBasedCache {
}
/**
* When restarting packager we want to avoid running the collection over
* When restarting Metro Bundler we want to avoid running the collection over
* again, so we store the last collection time in a file and we check that
* first.
*/
@ -426,9 +426,9 @@ function none(): TransformCache {
}
/**
* If packager is running for two different directories, we don't want the
* If Metro Bundler is running for two different directories, we don't want the
* caches to conflict with each other. `__dirname` carries that because
* packager will be, for example, installed in a different `node_modules/`
* Metro Bundler will be, for example, installed in a different `node_modules/`
* folder for different projects.
*/
function useTempDir(): TransformCache {
@ -437,7 +437,7 @@ function useTempDir(): TransformCache {
hash.update(process.getuid().toString());
}
const tmpDir = tmpdir();
const cacheName = 'react-native-packager-cache';
const cacheName = 'metro-bundler-cache';
const rootPath = path.join(tmpDir, cacheName + '-' + hash.digest('hex'));
mkdirp.sync(rootPath);
return new FileBasedCache(rootPath);

View File

@ -28,13 +28,13 @@ export type ReportableEvent =
| {
port: number,
projectRoots: $ReadOnlyArray<string>,
type: 'initialize_packager_started',
type: 'initialize_started',
}
| {
type: 'initialize_packager_done',
type: 'initialize_done',
}
| {
type: 'initialize_packager_failed',
type: 'initialize_failed',
port: number,
error: Error,
}
@ -115,7 +115,7 @@ export type Reporter = {
/**
* A standard way to log a warning to the terminal. This should not be called
* from some arbitrary packager logic, only from the reporters. Instead of
* from some arbitrary Metro Bundler logic, only from the reporters. Instead of
* calling this, add a new type of ReportableEvent instead, and implement a
* proper handler in the reporter(s).
*/

View File

@ -111,7 +111,7 @@ class DependencyGraph extends EventEmitter {
ignorePattern: opts.ignoreFilePath,
maxWorkers: opts.maxWorkers,
mocksPattern: '',
name: 'react-native-packager-' + JEST_HASTE_MAP_CACHE_BREAKER,
name: 'metro-bundler-' + JEST_HASTE_MAP_CACHE_BREAKER,
platforms: Array.from(opts.platforms),
providesModuleNodeModules: opts.providesModuleNodeModules,
resetCache: opts.resetCache,
@ -123,13 +123,12 @@ class DependencyGraph extends EventEmitter {
}
static async load(opts: Options): Promise<DependencyGraph> {
const initializingPackagerLogEntry = log(
createActionStartEntry('Initializing Packager'),
);
opts.reporter.update({type: 'dep_graph_loading'});
const haste = DependencyGraph._createHaste(opts);
const {hasteFS, moduleMap} = await haste.build();
log(createActionEndEntry(initializingPackagerLogEntry));
log(createActionEndEntry(log(
createActionStartEntry('Initializing Metro Bundler'),
)));
opts.reporter.update({type: 'dep_graph_loaded'});
return new DependencyGraph({
haste,

View File

@ -301,7 +301,7 @@ class ModuleResolver<TModule: Moduleish, TPackage: Packageish> {
`To resolve try the following:\n` +
` 1. Clear watchman watches: \`watchman watch-del-all\`.\n` +
` 2. Delete the \`node_modules\` folder: \`rm -rf node_modules && npm install\`.\n` +
' 3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.',
' 3. Reset Metro Bundler cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.',
);
}

View File

@ -32,11 +32,11 @@ module.exports = {
_getRoots() {
// match on either path separator
if (__dirname.match(/node_modules[\/\\]react-native[\/\\]packager$/)) {
// packager is running from node_modules of another project
if (__dirname.match(/node_modules[\/\\]metro-bundler$/)) {
// Metro Bundler is running from node_modules of another project
return [path.resolve(__dirname, '../../..')];
} else if (__dirname.match(/Pods\/React\/packager$/)) {
// packager is running from node_modules of another project
// Metro Bundler is running from node_modules of another project
return [path.resolve(__dirname, '../../..')];
} else {
return [path.resolve(__dirname, '..')];