netlify / zip-it-and-ship-it

Intelligently prepare Node.js Lambda functions for deployment
https://www.npmjs.com/package/@netlify/zip-it-and-ship-it
MIT License
316 stars 35 forks source link

feat: include side files with NFT #1614

Closed eduardoboucas closed 1 year ago

eduardoboucas commented 1 year ago

Summary

In the legacy zisi bundler , functions defined in a sub-directory had any sibling files recursively added to the bundle., regardless of whether they were statically required by the function or not.

As we try to remove this bundler entirely without breaking existing workflows, this PR ports that behaviour over to NFT, only when the default bundler is used (so that we don't affect functions explicitly opting in to nft).

github-actions[bot] commented 1 year ago

⏱ Benchmark results

Comparing with 9f3dab86ae7e3ba894abaffd527b532f6b395d92

largeDepsEsbuild: 2.6s

⬇️ 29.04% decrease vs. 9f3dab86ae7e3ba894abaffd527b532f6b395d92

^                   3.6s                                                                                  
│                   ┌──┐                                    3.4s                            3.3s          
│   3.2s            |  |    3.2s                            ┌──┐                            ┌──┐          
│   ┌──┐            |  |    ┌──┐                            |  |                            |  |          
│   |  |            |  |    |  |    2.8s                    |  |                            |  |          
│ ──┼──┼────2.7s────┼──┼────┼──┼────┌──┐────2.7s────2.7s────┼──┼────2.6s────2.7s────────────┼──┼────2.6s──
│   |  |    ┌──┐    |  |    |  |    |  |    ┌──┐    ┌──┐    |  |    ┌──┐    ┌──┐    2.5s    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend - T-30 (ad2c55d2db23014e0961a776f860e03d781a8eb1): 2.8s - T-29 (304f7f544dfd99ddd3447e18baa1768e06aa646c): 2.6s - T-28 (45ebfeaa3c41aa0af7e8c4e5f7ad0fd0410e13eb): 3.1s - T-27 (2070b46a2c2949b93f9c98f14135f3f76e7db65d): 3.7s - T-26 (5d277e792ad684d29fb95780d2dee162874d3265): 2.7s - T-25 (360f3733e2db910f8e3372f2765b421065d6bf9b): 2.4s - T-24 (5c6c14a08b9d4868bd26cc989262f9e624251a4a): 2.7s - T-23 (1ea5222b0723885c908642390253f9496f378d5f): 2.6s - T-22 (4e2fe8bd69cd9a8b8e5a6b5deb821bf409e378f9): 3s - T-21 (25c1ae4b7522fa328aab3376549e60e902b4b308): 2.6s - T-20 (90325b260492360cc4a4f25630a303d50e7fb394): 2.7s - T-19 (1eccedc3433fe06ab32c3b19f055b77a563515b6): 2.8s - T-18 (c9e5384cbd834396648e3415d677191780dcff11): 2.6s - T-17 (b40788aa9265f117d373cf059b3a0061f0e69953): 2.5s - T-16 (6ff4fbefe2bd4fd83838b29fbd4c60e498aeaad8): 3.6s - T-15 (dfe6dd0aa9a7e914dc2b933adae54596b81ae40e): 3.2s - T-14 (6b85304833228a7643e2284fb1929b13bec54904): 3.4s - T-13 (cd48552ef96dca0cd1120ae8f85905ef860f0ae8): 2.8s - T-12 (cf77a728cbb492a8cdaa7f07f72a1f9e25cc6a54): 3.2s - T-11 (722a724ccf8af8e6f265544ae747cadb19526edf): 2.7s - T-10 (9e3af6a8aaee7e343d770b5ff3f5b854a5e92f59): 3.6s - T-9 (7eb97de88cee636384a29b562cc03f2489bbe99a): 3.2s - T-8 (6be8b420590cd6daa54b72310d5f184b767854ef): 2.8s - T-7 (23405c64e8f3f27b8e384d47dfddd727dd9f9898): 2.7s - T-6 (fffff2193787ccc260c2e8eff83128d10e788139): 2.7s - T-5 (d1a18f186f465878ccc479873e0ed44feb66471a): 3.4s - T-4 (591f2a81052dd85725d2a1b3971a8dc413800819): 2.6s - T-3 (3c294af2821a298f9dde7ce5287d4ed7b7a458be): 2.7s - T-2 (dad329b65e777c60111072e8bf8ae8b73c882866): 2.5s - T-1 (9f3dab86ae7e3ba894abaffd527b532f6b395d92): 3.3s - **T (current commit): 2.6s**

largeDepsNft: 7.6s

⬇️ 32.26% decrease vs. 9f3dab86ae7e3ba894abaffd527b532f6b395d92

^                  11.6s                                                                                  
│                   ┌──┐                                                                                  
│  10.2s            |  |                                   10.7s                                          
│   ┌──┐            |  |    9.8s                            ┌──┐                            10s           
│   |  |            |  |    ┌──┐                            |  |                            ┌──┐          
│ ──┼──┼────────────┼──┼────┼──┼────8.7s────8.5s────8.4s────┼──┼────8.4s────────────────────┼──┼──────────
│   |  |    8.3s    |  |    |  |    ┌──┐    ┌──┐    ┌──┐    |  |    ┌──┐    8.2s            |  |          
│   |  |    ┌──┐    |  |    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    7.8s    |  |    7.6s  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend - T-30 (ad2c55d2db23014e0961a776f860e03d781a8eb1): 8.3s - T-29 (304f7f544dfd99ddd3447e18baa1768e06aa646c): 8.1s - T-28 (45ebfeaa3c41aa0af7e8c4e5f7ad0fd0410e13eb): 10.1s - T-27 (2070b46a2c2949b93f9c98f14135f3f76e7db65d): 12.1s - T-26 (5d277e792ad684d29fb95780d2dee162874d3265): 8.3s - T-25 (360f3733e2db910f8e3372f2765b421065d6bf9b): 7.5s - T-24 (5c6c14a08b9d4868bd26cc989262f9e624251a4a): 8s - T-23 (1ea5222b0723885c908642390253f9496f378d5f): 7.7s - T-22 (4e2fe8bd69cd9a8b8e5a6b5deb821bf409e378f9): 9.3s - T-21 (25c1ae4b7522fa328aab3376549e60e902b4b308): 7.9s - T-20 (90325b260492360cc4a4f25630a303d50e7fb394): 8.4s - T-19 (1eccedc3433fe06ab32c3b19f055b77a563515b6): 8.4s - T-18 (c9e5384cbd834396648e3415d677191780dcff11): 8.3s - T-17 (b40788aa9265f117d373cf059b3a0061f0e69953): 7.8s - T-16 (6ff4fbefe2bd4fd83838b29fbd4c60e498aeaad8): 11.8s - T-15 (dfe6dd0aa9a7e914dc2b933adae54596b81ae40e): 9.4s - T-14 (6b85304833228a7643e2284fb1929b13bec54904): 10.5s - T-13 (cd48552ef96dca0cd1120ae8f85905ef860f0ae8): 8.5s - T-12 (cf77a728cbb492a8cdaa7f07f72a1f9e25cc6a54): 10.2s - T-11 (722a724ccf8af8e6f265544ae747cadb19526edf): 8.3s - T-10 (9e3af6a8aaee7e343d770b5ff3f5b854a5e92f59): 11.6s - T-9 (7eb97de88cee636384a29b562cc03f2489bbe99a): 9.8s - T-8 (6be8b420590cd6daa54b72310d5f184b767854ef): 8.7s - T-7 (23405c64e8f3f27b8e384d47dfddd727dd9f9898): 8.5s - T-6 (fffff2193787ccc260c2e8eff83128d10e788139): 8.4s - T-5 (d1a18f186f465878ccc479873e0ed44feb66471a): 10.7s - T-4 (591f2a81052dd85725d2a1b3971a8dc413800819): 8.4s - T-3 (3c294af2821a298f9dde7ce5287d4ed7b7a458be): 8.2s - T-2 (dad329b65e777c60111072e8bf8ae8b73c882866): 7.8s - T-1 (9f3dab86ae7e3ba894abaffd527b532f6b395d92): 10s - **T (current commit): 7.6s**

largeDepsZisi: 15.4s

⬇️ 30.27% decrease vs. 9f3dab86ae7e3ba894abaffd527b532f6b395d92

^                  21.8s                                                                                  
│                   ┌──┐                                   20.6s                                          
│  19.9s            |  |   19.4s                            ┌──┐                            20s           
│   ┌──┐            |  |    ┌──┐                            |  |                            ┌──┐          
│   |  |            |  |    |  |                            |  |                            |  |          
│ ──┼──┼───16.2s────┼──┼────┼──┼───16.8s───16.2s───16.5s────┼──┼───16.1s───16.3s────────────┼──┼──────────
│   |  |    ┌──┐    |  |    |  |    ┌──┐    ┌──┐    ┌──┐    |  |    ┌──┐    ┌──┐   15.6s    |  |   15.4s  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend - T-30 (ad2c55d2db23014e0961a776f860e03d781a8eb1): 15.9s - T-29 (304f7f544dfd99ddd3447e18baa1768e06aa646c): 15.5s - T-28 (45ebfeaa3c41aa0af7e8c4e5f7ad0fd0410e13eb): 19.3s - T-27 (2070b46a2c2949b93f9c98f14135f3f76e7db65d): 22.4s - T-26 (5d277e792ad684d29fb95780d2dee162874d3265): 15.7s - T-25 (360f3733e2db910f8e3372f2765b421065d6bf9b): 14.4s - T-24 (5c6c14a08b9d4868bd26cc989262f9e624251a4a): 15.7s - T-23 (1ea5222b0723885c908642390253f9496f378d5f): 15.1s - T-22 (4e2fe8bd69cd9a8b8e5a6b5deb821bf409e378f9): 17.9s - T-21 (25c1ae4b7522fa328aab3376549e60e902b4b308): 15.4s - T-20 (90325b260492360cc4a4f25630a303d50e7fb394): 16.3s - T-19 (1eccedc3433fe06ab32c3b19f055b77a563515b6): 15.9s - T-18 (c9e5384cbd834396648e3415d677191780dcff11): 15.7s - T-17 (b40788aa9265f117d373cf059b3a0061f0e69953): 14.8s - T-16 (6ff4fbefe2bd4fd83838b29fbd4c60e498aeaad8): 21.9s - T-15 (dfe6dd0aa9a7e914dc2b933adae54596b81ae40e): 18.3s - T-14 (6b85304833228a7643e2284fb1929b13bec54904): 20.3s - T-13 (cd48552ef96dca0cd1120ae8f85905ef860f0ae8): 16.4s - T-12 (cf77a728cbb492a8cdaa7f07f72a1f9e25cc6a54): 19.9s - T-11 (722a724ccf8af8e6f265544ae747cadb19526edf): 16.2s - T-10 (9e3af6a8aaee7e343d770b5ff3f5b854a5e92f59): 21.8s - T-9 (7eb97de88cee636384a29b562cc03f2489bbe99a): 19.4s - T-8 (6be8b420590cd6daa54b72310d5f184b767854ef): 16.8s - T-7 (23405c64e8f3f27b8e384d47dfddd727dd9f9898): 16.2s - T-6 (fffff2193787ccc260c2e8eff83128d10e788139): 16.5s - T-5 (d1a18f186f465878ccc479873e0ed44feb66471a): 20.6s - T-4 (591f2a81052dd85725d2a1b3971a8dc413800819): 16.1s - T-3 (3c294af2821a298f9dde7ce5287d4ed7b7a458be): 16.3s - T-2 (dad329b65e777c60111072e8bf8ae8b73c882866): 15.6s - T-1 (9f3dab86ae7e3ba894abaffd527b532f6b395d92): 20s - **T (current commit): 15.4s**
eduardoboucas commented 1 year ago

@Skn0tt I pushed https://github.com/netlify/zip-it-and-ship-it/pull/1614/commits/a8af2875f0f2005cdd678ad67e0bbd3ca02f301d with a change to the test, ensuring we run for all bundler variants and don't include the side files unless the default bundler is used.

Can you re-approve, please?