Build: [Utilities] Make it easy to generate netlify functions from plugins

Created on 31 Oct 2019  路  4Comments  路  Source: netlify/build

Which problem is this feature request solving?

plugins can add runtime funcitonality instead of just buildtime by generating functions.

its not very clear how to do this in userland. have to figure out which lifecycle, and which path, and how to zip. annoying, and a barrier.

Describe the solution you'd like

from @DavidWells

this is a good candidate for a utility function.
e.g.
await util.addFunction({
   name: 'foo'
   code: 'export.handler lololol'
})
To automagically do this stuff for u
enhancement utilities

Most helpful comment

@talves thanks man btw this is kinda what i was envisioning using it https://github.com/netlify-labs/netlify-plugin-search-index

All 4 comments

After discussing this with @sw-yx on Slack, we came to the following conclusion: all that is needed is copying function files to the constants.FUNCTIONS_SRC directory before functions are handled by @netlify/plugin-functions-core.

await utils.functions.add('./path/to/function')

This should be an easy one to implement :)

Done at #644.

This is awesome! Thanks for thinking this through @sw-yx @DavidWells @ehmicky

@talves thanks man btw this is kinda what i was envisioning using it https://github.com/netlify-labs/netlify-plugin-search-index

Was this page helpful?
0 / 5 - 0 ratings