Repository navigation
Description
Description
I have a need to bundle a pre-optimized external lib with my RN application. Until RN 0.42 I had been using a .babelignore to prevent the packager from trying to optimize this file and choke.
It seems in 0.42 and higher I'm no longer allowed to ignore the file.
This issue has also been reported as #12071
I've chatted with @loganfsmyth from BabelJS and his comments were:
cool, I think this is a regression in react-native, their code in that stacktrace is not handling ignored files: https://github.com/facebook/react-native/blob/master/packager/transformer.js#L110,
astwill beundefinedif the file was ignored (edited)
I believe that code was added recently for their faster sourcemap generation logic
Reproduction Steps and Sample Code
A project running 0.43.0-rc4 which produces a more verbose error than 0.42 does is here:
https://github.com/kevinold/RNBabelIgnoreIssue
Upon running react-native run-ios the following error is produced:
error: bundling: TypeError: Cannot read property 'tokens' of undefined
at new Generator (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/babel-generator/lib/index.js:51:21)
at exports.default (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/babel-generator/lib/index.js:19:13)
at Object.transform (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/react-native/packager/transformer.js:110:20)
at transformCode (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/react-native/packager/src/JSTransformer/worker/worker.js:91:31)
at exports.transformAndExtractDependencies (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/react-native/packager/src/JSTransformer/worker/worker.js:148:3)
at handle (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/worker-farm/lib/child/index.js:41:8)
at process.<anonymous> (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/worker-farm/lib/child/index.js:47:3)
at emitTwo (events.js:106:13)
at process.emit (events.js:194:7)
TransformError: /Users/kold/eval-projects/RNBabelIgnoreIssue/epublican-native-context-opt.js: Cannot read property 'tokens' of undefined
Bundling `index.ios.js` 99.0% (403/405), failed.
Solution
Handle babel ignored (in .babelrc ignore sections or .babelignore) files in the packager: https://github.com/facebook/react-native/blob/master/packager/transformer.js#L110
Additional Information
- React Native version: Broken: 0.42-0.43.0-rc4, works on 0.41
- Platform: iOS (I assume Android too)
- Development Operating System: OS X El Capitan
Activity
kevinold commentedon Mar 27, 2017
@davidaurelio Hi David, see this issue. Adding you here as this might be related to your recent patch (0849f84#diff-4676ea0b3c55c65c3929aa993144f07f).
kevinold commentedon Apr 25, 2017
@davidaurelio Any chance you could look into this?
@loganfsmyth Would you be able to provide me with a bit of guidance on a patch for this issue if David is not able to?
kevinold commentedon Apr 26, 2017
As a workaround I am using haul to package my app with my ignored files in
.babelrcinstead of a.babelignorelike so:Properly handle babel ignored files, returning only the contents
Properly handle babel ignored files, returning only the contents
Properly handle babel ignored files, returning only the contents
alexanderkjeldaas commentedon May 25, 2017
I'm having this issue, but with 0.45.0-rc.0, I'm getting out of memory. The behavior is not the same as with 0.40.0:
node v7.10.0
hramos commentedon Jul 31, 2017
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.
alexanderkjeldaas commentedon Aug 2, 2017
I still have the same out-of-memory issue with 0.46.4
GarimaMathur07 commentedon Jan 10, 2018
@alexanderkjeldaas did you find any solution for Android?
sujitpk-perennial commentedon Jul 12, 2018
@alexanderkjeldaas @GarimaMathur07 I am also getting JavaScript heap out of memory issue for large file. How you resolved this?
React sync for revisions ae14317...ca0941f