Skip to content

fix: use Edge Bundler to merge edge function declarations #5551

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

Merged
merged 7 commits into from
Mar 14, 2023

Conversation

eduardoboucas
Copy link
Member

@eduardoboucas eduardoboucas commented Mar 12, 2023

Summary

CLI had its own logic for merging edge function declarations coming from different sources (i.e. netlify.toml, in-source declarations, and deploy configuration API). This PR replaces that with the logic exported by @netlify/edge-bundler.

Using the same logic in both places ensures that the local development and production environments behave the same way.

It also moves the definition of the bootstrap URL out of Edge Bundler and into the CLI.

This PR needs netlify/edge-bundler#334 to be merged and released — I'll leave it as a draft until that happens.

Closes netlify/edge-functions-examples#42 and https://github.com/netlify/pod-compute/issues/429.

Supersedes #5561.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@github-actions
Copy link

github-actions bot commented Mar 12, 2023

📊 Benchmark results

Comparing with b4d888b

Package size: 270 MB

⬆️ 2.62% increase vs. b4d888b

^                                  270 MB  270 MB  270 MB  270 MB  270 MB  270 MB                  270 MB 
│  263 MB  263 MB  263 MB  263 MB   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐   263 MB  263 MB   ┌──┐  
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    ┌──┐    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@eduardoboucas eduardoboucas marked this pull request as ready for review March 13, 2023 16:43
@eduardoboucas eduardoboucas requested a review from a team March 13, 2023 16:43
danez
danez previously approved these changes Mar 13, 2023
Copy link
Contributor

@danez danez left a comment

Choose a reason for hiding this comment

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

Some questions, but otherwise LGTM

this.declarationsFromSource = functions.reduce(
(acc, func, index) => ({ ...acc, [func.name]: functionsConfig[index] }),
{},
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see why we changed this because edge-bundler expects it that way. It is surprising that this does not follow the Declaration type that toml and deploy config declarations have.

Would you happen to know why that is? Are we trying to avoid duplicates with this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, I'm not sure. I guess we could change it so that it follows the Declaration type, but I'd rather do that in a separate PR.

return this.declarationsFromConfig?.find((declaration) => declaration.function === func)?.name
const declarations = [...this.declarationsFromTOML, ...this.declarationsFromDeployConfig]

return declarations.find((declaration) => declaration.function === func)?.name
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not support the displayName in the ISC?

Copy link
Member Author

Choose a reason for hiding this comment

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

@eduardoboucas
Copy link
Member Author

CI is failing because we'll need netlify/edge-bundler#337. 😢

khendrikse
khendrikse previously approved these changes Mar 14, 2023
@danez danez dismissed stale reviews from khendrikse and themself via 0a66087 March 14, 2023 09:02
@eduardoboucas eduardoboucas merged commit 2c99006 into main Mar 14, 2023
@eduardoboucas eduardoboucas deleted the fix/edge-function-declarations branch March 14, 2023 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running this project with netlify dev doesn't work
3 participants