Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

fix: generate entry file on naming conflicts #1310

Merged
merged 2 commits into from
Jan 12, 2023
Merged

fix: generate entry file on naming conflicts #1310

merged 2 commits into from
Jan 12, 2023

Conversation

danez
Copy link
Contributor

@danez danez commented Jan 12, 2023

Summary

When a naming conflict occurs we need to create a entry file even if there is already a similar named file, but it will be moved to a subfolder.

Fixes the nuxt3 problem

when a functions has this layout

netlify/functions/server/
                         server.js <-- detected as main file
                         server.mjs

previously we would leave everything as is, as server.js is the main file and has the same name as the entry file so nothing to do.

With #1190 we now consider server.mjs also as a potential entry file and detect that it can potentially conflict with the entry file, so we move everything from that function into a subfolder.

netlify/functions/server/src/
                             server.js
                             server.mjs

when we do this we now need to generate an entry file again, even though we would detect that server.js would satisfy as entry-point, but due to everything being moved into a subfolder we need to.

netlify/functions/server/src/
                             server.js
                             server.mjs
                         server.js

And the chain in this scenario is ./server.js -> ./src/server.js -> ./src/server.mjs

This is all not optimal, and we should prioritize changing the AWS entry point to something unique like __netlifyLambdaEntry and disallow a function to be named like that. Then all of this code can be removed.

@danez danez requested review from eduardoboucas and a team January 12, 2023 11:39
@danez danez self-assigned this Jan 12, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2023

⏱ Benchmark results

Comparing with ea4008e

largeDepsEsbuild: 2.1s

⬇️ 3.43% decrease vs. ea4008e

^                                                    3s                                   
│                                                   ┌──┐    2.8s                          
│                                                   |  |    ┌──┐                          
│           2.6s                                    |  |    |  |                          
│           ┌──┐                                    |  |    |  |                          
│           |  |    2.2s                    2.1s    |  |    |  |            2.1s          
│ ───2s─────┼──┼────┌──┐────2.1s────2.1s────┌──┐────┼──┼────┼──┼─────2s─────┌──┐────2.1s──
│   ┌──┐    |  |    |  |    ┌──┐    ┌──┐    |  |    |  |    |  |    ┌──┐    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsNft: 7.4s

⬇️ 9.24% decrease vs. ea4008e

^          13.4s                                                                          
│           ┌──┐                                                                          
│           |  |                                   11.8s                                  
│           |  |                                    ┌──┐                                  
│           |  |   10.6s                            |  |   10.9s                          
│           |  |    ┌──┐   10.3s                    |  |    ┌──┐                          
│ ──9.4s────┼──┼────┼──┼────┌──┐────9.7s────────────┼──┼────┼──┼──────────────────────────
│   ┌──┐    |  |    |  |    |  |    ┌──┐            |  |    |  |                          
│   |  |    |  |    |  |    |  |    |  |     8s     |  |    |  |            8.1s          
│   |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    7.6s    ┌──┐    7.4s  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsZisi: 14.7s

⬇️ 5.49% decrease vs. ea4008e

^                                                  21.2s   20.7s                          
│                                                   ┌──┐    ┌──┐                          
│          18.9s                                    |  |    |  |                          
│           ┌──┐                                    |  |    |  |                          
│           |  |   16.8s                            |  |    |  |                          
│ ──────────┼──┼────┌──┐───15.6s───────────15.8s────┼──┼────┼──┼───────────15.5s──────────
│  14.4s    |  |    |  |    ┌──┐   15.3s    ┌──┐    |  |    |  |   14.9s    ┌──┐   14.7s  
│   ┌──┐    |  |    |  |    |  |    ┌──┐    |  |    |  |    |  |    ┌──┐    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

Copy link
Member

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding a couple of examples to the PR description so that it's easier to understand what happens exactly in the cases we're targeting?

@danez
Copy link
Contributor Author

danez commented Jan 12, 2023

Do you mind adding a couple of examples to the PR description so that it's easier to understand what happens exactly in the cases we're targeting?

Done

@eduardoboucas
Copy link
Member

This is all not optimal, and we should prioritize changing the AWS entry point to something unique like __netlifyLambdaEntry and disallow a function to be named like that. Then all of this code can be removed.

Agreed. Do we have an issue for tracking that work? If not, do you mind creating one?

@danez
Copy link
Contributor Author

danez commented Jan 12, 2023

Agreed. Do we have an issue for tracking that work? If not, do you mind creating one?

It is part of the notion doc about all the improvements for zip-it-and-ship-it.

@khendrikse khendrikse merged commit e74cb49 into main Jan 12, 2023
@khendrikse khendrikse deleted the fix-entry branch January 12, 2023 12:31
Skn0tt pushed a commit to netlify/build that referenced this pull request May 21, 2024
…-it#1310)

Co-authored-by: Karin Hendrikse <30577427+khendrikse@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants