Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Latest commit

 

History

History
51 lines (40 loc) · 1.42 KB

File metadata and controls

51 lines (40 loc) · 1.42 KB

Building a function with external dependencies

This example demonstrates how to package external dependencies into a single text file and package it into a Crossplane Composition resource.

The function source code is located in src/index.js file, and it uses NPM package YAML as an external dependency.

Eternal dependencies are bundled into a single file by esbuild and then transpiled with Babel to ES5 syntax supported by Goja. The resulting source code is used to build the composition.yaml file.

By default, the function server also transpiles the input code into ES 5.1 syntax using Babel, but since the input code is already ES 5.1, .spec.source.transpile is set to false. Setting this flag for large bundles can significantly improve performance.

Running this example

Make sure you have Node.js installed.

You can run your function locally and test it using crossplane beta render with these example manifests.

Run the function locally in the background:

$ make run &

Then call it with example manifests:

$ make render
---
apiVersion: example.crossplane.io/v1
kind: XR
metadata:
  name: example-xr
---
# ...function results

Stop the function running in background:

$ fg
# Press Ctrl-C
^C