Everything is working as expected up until the point where I tried to include some common functions under the lib/ folder. I cannot figure out what the correct import syntax is and can’t seem to find any docs to help either.
I have tried things like from lib.sample_function import sample as well as relative imports like from ..lib.sample_function import sample. Any help is greatly appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
The contents of the lib folder and the contents of each function’s directory affect what is included in each deployed function and how that function is built.
Here is also an example project that might help:
https://github.com/digitalocean/sample-functions-todo/tree/main
The structure is more or less just the build.sh file and your library.
Here is also another example on how this is implemented:
https://github.com/digitalocean/functions-deployer/tree/main/e2e/use-lib/lib
The above is from an end-to-end test and includes a simple use of the lib directory and a build.sh file.
If your serverless function repository is public, feel free to share it here and I will be happy to take a further look at why the builds might be failing.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.