-
-
Notifications
You must be signed in to change notification settings - Fork 36
feat(ios): add JS bundle compression support #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds JS bundle compression support for iOS App Clips to reduce bundle size. The implementation includes build-time compression using zlib during Release builds, runtime decompression in AppDelegate, and cache invalidation to prevent stale bundles.
Changes:
- Added
enableCompressionconfiguration option across plugin components - Implemented Xcode build phase to compress
main.jsbundleusing Node.js zlib - Injected Swift decompression logic into AppDelegate with fallback handling
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 20 comments.
| File | Description |
|---|---|
| plugin/src/xcode/addBuildPhases.ts | Adds shell script build phase for bundle compression in Release builds |
| plugin/src/withXcode.ts | Passes enableCompression parameter to build phase configuration |
| plugin/src/withCompression.ts | Implements AppDelegate modification to inject bundle decompression logic |
| plugin/src/index.ts | Adds enableCompression config option and wires up withCompression plugin |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0153fa9 to
7785d58
Compare
|
@trentrand Woah this looks great! Let me know once this is ready for review, and I'd be happy to help out with testing. We have an internal ticket for this feature that's been sitting in backlog for the past year and a half, so I'd also be happy to give this a shot in production if that can help validate the implementation here. |
This introduces JavaScript bundle compression functionality for iOS App Clips to help meet Apple's strict size limits. The implementation includes a new `enableCompression` parameter that compresses the main.jsbundle using gzip during the build process and automatically decompresses it at runtime using native Swift zlib APIs. Added detailed documentation about App Clip size constraints and optimization strategies.
ac7ce98 to
74cc3a3
Compare
|
Hey @nathan-ahn, I'm glad you're excited about this too! I pushed some additional changes and marked this as ready for review. In my own app, Stamp Cards, the .jsbundle was reduced 56% from 3597 KB → 1566 KB. Published here for testing: |
|
I'm going to adjust 74cc3a3 to inject .env from PROJECT_DIR rather than PROJECT_ROOT, that way we're not assuming a monorepo-like directory. |
74cc3a3 to
7c5eeca
Compare
Ensure environment variables are available during the bundling process for the App Clip target. The file is sourced from project root.
7c5eeca to
6be8fd8
Compare
|
Thanks for the published package for testing! No issues in building on my end, and the
Compressed App Clip File Size ( Even though the jsbundle file itself is significantly smaller, I'm seeing that the resulting final compressed file size is 2.4 MB larger. My guess is that compressing |
|
Interesting. I am getting good results in both the jsbundle and final app clip size:
Compressed App Clip File Size (enableCompression: false): 17.95 MB Here's my process (repeated with enableCompression false & true):
The failures confirm the sizes above - build 104 showed 16 MB, build 105 showed 18 MB (both over the 15 MB limit). I suspect our results differ due to double compression. Apple compresses the entire .ipa during archiving. Pre-compressed data (like .gz) doesn't compress well a second time and can even expand a bit. For me, the 1.98 MB bundle savings outweighs any penalty. For you, with a much larger 7.4 MB bundle reduction, maybe the double-compression penalty scales up and ends up costing more than it saves. Seems like |
|
@trentrand Super good to know. Considering that there'll be at least one person benefiting from this feature (and I'm sure many others), I'm open to merging this in. Could you update the README to make it clear that this feature may increase the resulting bundle size and that developers should experiment for themselves before enabling in production? |
|
Absolutely! I updated documentation with these notes in 6749ad4 |
|
Lovely, thank you for the contribution! Just released in 0.7.0. |
enableCompressionconfig optionmain.jsbundleusing zlibAppDelegate.swiftResolves #1