Skip to content

Commit 477360b

Browse files
author
Amjad Masad
committed
[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
1 parent 7dd2dd7 commit 477360b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packager/react-packager/src/DependencyResolver/haste/__tests__/HasteDependencyResolver-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ describe('HasteDependencyResolver', function() {
600600
'require("Y")',
601601
'require( \'z\' )',
602602
'require( "a")',
603-
'require("b" )});',
603+
'require("b" )',
604+
'});',
604605
].join('\n'));
605606
});
606607
});

packager/react-packager/src/DependencyResolver/haste/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ var DEFINE_MODULE_CODE = [
2020
'_deps_,',
2121
'function(global, require, requireDynamic, requireLazy, module, exports) {',
2222
' _code_',
23-
'}',
24-
');',
23+
'\n});',
2524
].join('');
2625

2726
var DEFINE_MODULE_REPLACE_RE = /_moduleName_|_code_|_deps_/g;

0 commit comments

Comments
 (0)