-
Notifications
You must be signed in to change notification settings - Fork 16
Functions:Packages
Daniel Willemse edited this page Oct 13, 2021
·
4 revisions
Using packages with Functions works the same way as it does in a regular yarn
project.
You can simply add them with yarn and then use them in your function files as normal.
You can then import the package as you would in the index.js
of your function.
To add a package, simply yarn add <package>
to add it to your package.json.
Example:
$ yarn add fs-extra
// cli-wiki/package.json
{
"name": "cli-wiki",
"version": "1.0.0",
"dependencies": {
"lodash": "^4.17.21"
},
"private": "true"
}
Example:
// cli-wiki/functions/say-hello/index.js
import join from 'lodash/join';
const sayHello = async ({ name }) => {
return {as: join(['Hello', name], ', ')}
}
Due to the nature in which Functions are compiled and executed, it may not be possible to use a desired package because of the functionality it uses. For example, packages relying on fs will not install or may not function correctly. We currently do not have a defined list of packages that are not supported.
- Getting started
- Page Builder Components
- Action Functions
- [deprecated] CustomFunctions