diff --git a/packager.js b/packager.js index e20bb99d..58f93a58 100644 --- a/packager.js +++ b/packager.js @@ -81,7 +81,7 @@ function openStackFrameInEditor(req, res, next) { function getAppMiddleware(options) { return ReactPackager.middleware({ dev: true, - projectRoot: options.projectRoot, + projectRoots: options.projectRoots, blacklistRE: blacklist(false), cacheVersion: '2', polyfillModuleNames: [ @@ -98,9 +98,13 @@ function runServer( var app = connect() .use(loadRawBody) .use(openStackFrameInEditor) - .use(getAppMiddleware(options)) - .use(connect.static(options.projectRoot)) - .use(connect.logger()) + .use(getAppMiddleware(options)); + + options.projectRoots.forEach(function(root) { + app.use(connect.static(root)); + }); + + app.use(connect.logger()) .use(connect.compress()) .use(connect.errorHandler()); diff --git a/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js b/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js index 0cf05411..9a939620 100644 --- a/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js +++ b/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js @@ -7,6 +7,7 @@ var docblock = require('./docblock'); var path = require('path'); var isAbsolutePath = require('absolute-path'); var debug = require('debug')('DependecyGraph'); +var util = require('util'); var readFile = q.nfbind(fs.readFile); var readDir = q.nfbind(fs.readdir); @@ -22,6 +23,7 @@ function DependecyGraph(options) { this._packageByRoot = Object.create(null); this._packagesById = Object.create(null); this._moduleById = Object.create(null); + this._debugUpdateEvents = []; this._fileWatcher = options.fileWatcher; // Kick off the search process to precompute the dependency graph. @@ -196,16 +198,20 @@ DependecyGraph.prototype._search = function() { return readDir(dir) .then(function(files){ return q.all(files.map(function(filePath) { - return realpath(path.join(dir, filePath)); + return realpath(path.join(dir, filePath)).catch(handleBrokenLink); })); }) .then(function(filePaths) { filePaths = filePaths.filter(function(filePath) { + if (filePath == null) { + return false + } + return !self._ignoreFilePath(filePath); }); var statsP = filePaths.map(function(filePath) { - return lstat(filePath); + return lstat(filePath).catch(handleBrokenLink); }); return [ @@ -397,6 +403,8 @@ DependecyGraph.prototype._processFileChange = function(eventType, filePath, root return; } + this._debugUpdateEvents.push({event: eventType, path: filePath}); + if (eventType === 'delete') { var module = this._graph[absPath]; if (module == null) { @@ -412,6 +420,13 @@ DependecyGraph.prototype._processFileChange = function(eventType, filePath, root } }; +DependecyGraph.prototype.getDebugInfo = function() { + return '
' + util.inspect(this._debugUpdateEvents) + '' + + '
' + util.inspect(this._graph) + ''; +}; + /** * Searches all roots for the file and returns the first one that has file of the same path. */ @@ -471,4 +486,9 @@ function withExtJs(file) { } } +function handleBrokenLink(e) { + debug('WARNING: error stating, possibly broken symlink', e.message); + return q(); +} + module.exports = DependecyGraph; diff --git a/react-packager/src/DependencyResolver/haste/index.js b/react-packager/src/DependencyResolver/haste/index.js index feb69cce..211da365 100644 --- a/react-packager/src/DependencyResolver/haste/index.js +++ b/react-packager/src/DependencyResolver/haste/index.js @@ -119,8 +119,13 @@ HasteDependencyResolver.prototype.wrapModule = function(module, code) { }); }; + HasteDependencyResolver.prototype.end = function() { return this._fileWatcher.end(); }; +HasteDependencyResolver.prototype.getDebugInfo = function() { + return this._depGraph.getDebugInfo(); +}; + module.exports = HasteDependencyResolver; diff --git a/react-packager/src/Packager/Package.js b/react-packager/src/Packager/Package.js index f3f5d992..787684bc 100644 --- a/react-packager/src/Packager/Package.js +++ b/react-packager/src/Packager/Package.js @@ -108,3 +108,25 @@ Package.prototype._getMappings = function() { } return mappings; }; + +Package.prototype.getDebugInfo = function() { + return [ + '
' +
+ _.escape(m.transformedCode) + '