0

So I am trying to deploy a function that uses multiple javascript files. The only way I see to deploy a function is with a single index.js file. Is there some what to add more files?

I have the CLI setup but still only see examples uploading a single js file rather than a zip.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • You mean a single function `Foo()` that is broken down on multiple separate js files? Why would you need that? – Abana Clara Apr 03 '19 at 02:37
  • An IBM Cloud Function. The function they provide expects to be in index.js. I want the main() function to be able to call other functions in different files. Normally you would use require("file/path") to access other files but I don't see a way to upload other files. The program has been deployed on AWS Lambda and GCF and was split into multiple files to be more organized. –  Apr 03 '19 at 03:12
  • Ah I see, the initial wording of the post title and body combined makes things confusing. I would suggest an edit for clarification. – Abana Clara Apr 03 '19 at 03:22

1 Answers1

4

Having an IBM Cloud Functions action that has its logic contained in multiple files is supported, not just for Node.js / Javascript. The documentation for IBM Cloud Function has a section on how to create an action as Node.js module. You would then pack the files as single ZIP file and upload it when you create or update the action.

Alternatives would be to package all into a single file using webpack or using Docker actions.

data_henrik
  • 16,724
  • 2
  • 28
  • 49