From a68cc06f0b448cb6c2dd7f2c553a3f27ab17e01c Mon Sep 17 00:00:00 2001 From: James Ide Date: Fri, 17 Apr 2015 09:52:57 -0700 Subject: [PATCH] [Errors] Fix Red Box by fixing providesModule parsing Summary: cc @amasad An error occurred while trying to display the Red Box since loadSourceMap was not included in the JS bundle. This is because node-haste was treating its docblock as a multiline directive which doesn't make sense for `@providesModule`. In loadSourceMap.js's case, the directive's value was parsed as "loadSourceMap -- disabled flow due to mysterious validation errors --". There are two fixes: add a newline under the `@providesModule` directive, and change the module ID code to look at only the first token of the directive. I opted for the latter so we avoid this class of bugs entirely and AFAIK it's nonsensical to have multiple `@providesModule` values anyway. Closes https://github.com/facebook/react-native/pull/866 Github Author: James Ide Test Plan: Run the packager, trigger an error in an app, see the red box now show up again. --- .../src/DependencyResolver/haste/DependencyGraph/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js b/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js index 9257d788..dba6265a 100644 --- a/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js +++ b/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js @@ -437,8 +437,9 @@ DependecyGraph.prototype._processModule = function(modulePath) { .then(function(content) { var moduleDocBlock = docblock.parseAsObject(content); if (moduleDocBlock.providesModule || moduleDocBlock.provides) { - moduleData.id = - moduleDocBlock.providesModule || moduleDocBlock.provides; + moduleData.id = /^(\S*)/.exec( + moduleDocBlock.providesModule || moduleDocBlock.provides + )[1]; // Incase someone wants to require this module via // packageName/path/to/module