React-native bundler takes exponentially longer (eventually timing out) for very large js files.
See original GitHub issueIs this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment: OS: macOS High Sierra 10.13.2 Node: 6.3.1 Yarn: Not Found npm: 3.10.3 Watchman: 4.6.0 Xcode: Xcode 8.0 Build version 8A218a Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: ^16.0.0-beta.5 => 16.0.0-beta.5 react-native: ^0.51.0 => 0.51.0
Steps to Reproduce
Steps to reproduce this can be found in the README in the following repo: https://github.com/ScottPierce/ReactNativeKotlinError
Expected Behavior
That the kotlin.js file from npm, or other large javascript files, could properly be bundled with react-native.
Actual Behavior
Bundling kotlin.js freezes:
Bundlingindex.js[development, non-minified] ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░ 99.6% (476/477)
And eventually times out:
error: bundling failed: Error: TimeoutError: transforming /Users/spierce7/workspace/KotlinReactNative/kotlin.js took longer than 601 seconds.
at _transform.then.catch.error (/Users/spierce7/workspace/KotlinReactNative/node_modules/metro-bundler/src/JSTransformer/index.js:183:28)
at process._tickCallback (internal/process/next_tick.js:103:7)
I removed most of the content from the javascript file, and things bundled just fine. I slowly added more and more content back to the kotlin.js file, and bundling times rose exponentially. Here are some rough estimates:
At 15k lines, bundling the file took ~17 seconds.
At 18k lines, bundling the file took ~30 seconds.
At 23k lines, bundling the file took ~60 seconds.
The actual file is 37k+ lines, and times out when bundling
Reproducible Demo
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
After further research, the problem seems to come from the large size of the kotlin.js file.
Is there a way I could either allocate more memory to the process, or perhaps I could somehow provide the kotlin.js file myself for develop builds? In production builds, dead code elimination can be run, and the resulting
kotlin.js
will be much smaller. I’d also need to ensure I could debug with this approach as well.@jeffreymendez1993 Because it’s a fantastic high level language that has positioned itself in a good place for cross platform mobile development. i.e. When Kotlin-native is released later this year, it would be a fantastic way to write background tasks that run on separate threads and don’t lag the js thread, and can run on android (jvm), and ios (native). Also I’ve already written a lot of code in Kotlin, and being able to port that over and use that in react-native would be a huge win.
@ScottPierce Is this issue resolved on v0.53.0 ?