react-native start 运行流程

在CMD下键入

C:Node_JSMyAwesomeProject>react-native start

运行流程:

C:UsersGrartAppDataRoaming pm eact-native.cmd

C:UsersGrartAppDataRoaming pm ode_modules eact-native-cliindex.js    

cli.run();

 

C:Node_JSMyAwesomeProject ode_modules eact-nativecli.js

module.exports = require('./local-cli/cli.js');

 

C:Node_JSMyAwesomeProject ode_modules eact-nativelocal-clicli.js

module.exports = {

  run: run,

  init: init,

};

 

 

 

C:Node_JSMyAwesomeProject ode_modules eact-nativeprivate-clisrcserverserver.js

C:Node_JSMyAwesomeProject ode_modules eact-nativeprivate-clisrcserver unServer.js

function getAppMiddleware(args, config) {

    ………………………...

  return ReactPackager.middleware({

    nonPersistent: args.nonPersistent,

    projectRoots: args.projectRoots,

    blacklistRE: config.getBlacklistRE(),

    cacheVersion: '3',

    transformModulePath: transformerPath,

    assetRoots: args.assetRoots,

    assetExts: ['png', 'jpeg', 'jpg'],

    resetCache: args.resetCache || args['reset-cache'],

    polyfillModuleNames: [

      require.resolve(

        '../../../Libraries/JavaScriptAppEngine/polyfills/document.js'

      ),

    ],

    verbose: args.verbose,

  });

}

C:Node_JSMyAwesomeProject ode_modules eact-nativepackager eact-packagerindex.js

function createServer(options) {

  // the debug module is configured globally, we need to enable debugging

  // *before* requiring any packages that use `debug` for logging

  if (options.verbose) {

    enableDebug();

  }

 

  startSocketInterface();

  var Server = require('./src/Server');

  return new Server(omit(options, ['verbose']));

}

C:Node_JSMyAwesomeProject ode_modules eact-nativepackager eact-packagersrcServerindex.js

function processRequest(req, res, next) {

…………

const building = this._bundles[optionsJson] || this.buildBundle(options);

 

    this._bundles[optionsJson] = building;

    building.then(……

)

…………

}

C:Node_JSMyAwesomeProject ode_modules eact-nativepackager eact-packagersrcBundlerindex.js

function bundle(main, runModule, sourceMapUrl, isDev, platform) {

    const bundle = new Bundle(sourceMapUrl);

    const findEventId = Activity.startEvent('find dependencies');

    let transformEventId;

 

    return this.getDependencies(main, isDev, platform)

    .then(………………

    .………………..

}

 

function getDependencies(main, isDev, platform) {

    return this._resolver.getDependencies(main, { dev: isDev, platform });

  }

 

 

C:Node_JSMyAwesomeProject ode_modules eact-nativepackager eact-packagersrcDependencyResolverindex.js

 

HasteDependencyResolver.prototype.getDependencies = function(main, options) {

  var opts = getDependenciesValidateOpts(options);

 

  return this._depGraph.getDependencies(main, opts.platform)

  .then(

    resolutionResponse => {

      this._getPolyfillDependencies(opts.dev).reverse().forEach(

        polyfill => resolutionResponse.prependDependency(polyfill)

      );

 

      return resolutionResponse.finalize();

    }

  );

};

C:Node_JSMyAwesomeProject ode_modules eact-nativepackager eact-packagersrcDependencyResolverDependencyGraphindex

 

  getDependencies(entryPath, platform) {

    console.log('call DependencyGraph entryPath='+entryPath);

    return this.load()

    .then(

      () => {

        platform = this._getRequestPlatform(entryPath, platform);

        const absPath = this._getAbsolutePath(entryPath);

        const req = new ResolutionRequest({

          platform,

          entryPath: absPath,

          deprecatedAssetMap: this._deprecatedAssetMap,

          hasteMap: this._hasteMap,

          helpers: this._helpers,

          moduleCache: this._moduleCache,

          fastfs: this._fastfs,

        });

 

        const response = new ResolutionResponse();

        console.log('call ResolutionRequest');

        return Promise.all([

          req.getOrderedDependencies(response),

          req.getAsyncDependencies(response),

        ]).then(() => response);

      }

    );

  }

C:Node_JSMyAwesomeProject ode_modules eact-nativepackager eact-packagersrcDependencyResolverDependencyGraphResolutionRequest.js

getOrderedDependencies(response) {….

resolveDependency(fromModule, toModuleName) {….

_resolveNodeDependency(fromModule, toModuleName) {….

_loadAsFile(potentialModulePath, fromModule, toModule) {….

  this._fastfs.fileExists(potentialModulePath)

 

原文地址:https://www.cnblogs.com/Grart/p/5081656.html