[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
Родитель 7dd2dd7962
Коммит 477360b8c9
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

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

Просмотреть файл

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