1

As of today, in the IBM Bluemix docs for the IBM Bluemix OpenWhisk service I could not find any clues as to how to use libraries.

How am I missing the obvious that all apps invariably require a library and therefore why isn't that at least mentioned in the OpenWhisk docs?

If libraries are called something else or the concept doesn't apply in the usual way (such as maybe Libraries need to be converted into "OpenWhisk Packages"?), the OpenWhisk docs should SAY SOMETHING about the word/term/concept "libraries".

Rick
  • 572
  • 1
  • 7
  • 21
  • You did not specify how you want to use OpenWhisk, which language to use, or where you looked for documentation. – data_henrik Jan 30 '17 at 17:24
  • I specified I want to use OpenWhisk with Libraries. I didn't specify a language because I want to know about using libraries with OpenWhisk regardless of language. I looked for docs in the IBM Bluemix docs. – Rick Jan 30 '17 at 17:36
  • And I asked because there is http://openwhisk.org/ with documentation and we have the IBM docs. In addition, you can use Docker containers. For JavaScript the IBM docs list the available runtime and libraries: https://console.ng.bluemix.net/docs/openwhisk/openwhisk_reference.html#openwhisk_ref_runtime_environment – data_henrik Jan 30 '17 at 17:40
  • That link doesn't take me to anything about "libraries" with Bluemix OpenWhisk. The point of my question is my confusion about libraries in relation to OpenWhisk. Is the concept of "libraries" called something else in the Bluemix OpenWhisk docs? – Rick Jan 30 '17 at 17:46

2 Answers2

3

You can use webpack to bundle all your dependencies and create the final .js file you'll use as your OpenWhisk action.

See this example: These are all the actions before webpack build: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/tree/dev/actions

Invoking webpack: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/blob/dev/package.json webpack --config webpack.config.js

Here is another more simpler example: https://github.com/IBM-Bluemix/openwhisk-webpack

Ram Vennam
  • 3,536
  • 1
  • 12
  • 19
  • 1
    Thank you Ram. I think you have me pointed in the right direction. I'm going to play around with this today. I also discovered that the Serverless Framework as of Jan 30th now works with OpenWhisk as well! – Rick Feb 01 '17 at 21:04
1

To cover another language for anyone who finds this question…

For Swift, OpenWhisk comes with the Kitura-net, SwiftyJSON & swift-watson-sdk packages (Swift term for libraries) built in.

If you want to include any other packages then you have to either build your own Docker container for your action or concatenate all the Swift source files that are in the packages together with your action file to create a single .swift file for upload with wsk action update. I've used cat to do this:

cat lib/Redis/Redis*.swift actions/_common.swift actions/counts.swift > build/counts.swift

which creates a single build/counts.swift containing Kitura-Redis, some common code and my counts action.

Rob Allen
  • 12,643
  • 1
  • 40
  • 49