[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 <ide@jameside.com>

Test Plan:  Run the packager, trigger an error in an app, see the red box now show up again.
This commit is contained in:
James Ide 2015-04-17 09:52:57 -07:00
parent 691297ab0d
commit 0b6dbdb827
1 changed files with 3 additions and 2 deletions

View File

@ -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