Skip to content

Creating a Bundle

Cloud edited this page Jan 13, 2022 · 10 revisions

This page contains a guide for Source Module authors to create their very own Source Module Bundle as well as details and explanations on the structure of a Source Module Bundle.

Introduction

A Source Module Bundle is the implementation of the suite of functions that are provided by the module.

For example, the binary_tree module may want to provide an abstraction for Source programs to interact with the Binary Tree data structure. Thus, the binary_tree module would expose functions such as make_tree, left_branch and right_branch to be used in Source programs.

The Source Module Bundle folder will then contain the TypeScript logic that is responsible for the implementation of the suite of functions.

export function make_tree(value: any, left: BinaryTree, right: BinaryTree): BinaryTree {
  return [left, value, right];
}

...

Structure

The main structure of the entry point file to the Source Module Bundle looks like this.

1  import { ... } from '...';
2  ...
3  export default (__params) => {
4    ...
5    return { ... }
6  });
Line Description
1 The import declarations of the various dependencies used by this file.
2 The truncated implementation of the Source Module Bundle.
3 The default export function of the Source Module Bundle.
4 The truncated implementation of the Source Module Bundle.
5 The JavaScript object of functions provided by the Source Module Bundle.
Clone this wiki locally