[react-packager] Make it safe to include files without a newline at the end

Summary:
@public
Fixes #1431
Fixes #1005
Files with no newlines and a comment at the end of the file would've caused a syntax error in the bundle:

```js
__d('module', function() {
hi();
// wow })
```

This fixes the issue by inserting a new lines before `})`.

Test Plan:
* ./runJestTests.sh
* ./runJestTests.sh PackagerIntegration
* open app to the playground app
* add an error
* observe that the redbox has the correct lines
This commit is contained in:
Amjad Masad 2015-06-16 12:04:22 -07:00
parent 24026b6c25
commit 253544cb45
2 changed files with 3 additions and 3 deletions

View File

@ -600,7 +600,8 @@ describe('HasteDependencyResolver', function() {
'require("Y")',
'require( \'z\' )',
'require( "a")',
'require("b" )});',
'require("b" )',
'});',
].join('\n'));
});
});

View File

@ -20,8 +20,7 @@ var DEFINE_MODULE_CODE = [
'_deps_,',
'function(global, require, requireDynamic, requireLazy, module, exports) {',
' _code_',
'}',
');',
'\n});',
].join('');
var DEFINE_MODULE_REPLACE_RE = /_moduleName_|_code_|_deps_/g;