Skip to content

Commit

Permalink
docs(readme): Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jcowman2 committed Dec 30, 2018
1 parent 5b1ada4 commit bf219f8
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions README.md
Expand Up @@ -4,7 +4,13 @@
[![Coverage Status](https://coveralls.io/repos/github/regal/regal-bundler/badge.svg?branch=master)](https://coveralls.io/github/regal/regal-bundler?branch=master)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Utility that packages a [Regal](https://github.com/regal/regal) game into a deployable game bundle.
`regal-bundler` is a tool that packages a [Regal](https://github.com/regal/regal) game into a deployable game bundle.

## Overview

In order to be used by clients, a [Regal](https://github.com/regal/regal) game must be bundled. *Bundling* is the process of converting a Regal game's **development source** (i.e. the TypeScript or JavaScript source files that the game developer writes) into a **game bundle**, which is a self-contained file that contains all the code necessary to play the game via a single API.

Game bundles are the form through which Regal games are shared, downloaded, and played.

## Usage

Expand All @@ -18,21 +24,28 @@ npm install --save-dev regal-bundler

### Bundling a Game

Generate a game bundle with the `bundle` function.
Generate a game bundle with the `bundle` function. This creates a JavaScript file that exports an implementation of the [Regal `GameApi`](https://github.com/regal/regal/blob/master/src/api/game-api.ts) (see [bundles](#bundles) for more information).

```ts
import { bundle } from "regal-bundler";

bundle({
configLocation: "PATH/TO/MY/PROJECT"
});
bundle({ configLocation: "PATH/TO/MY/PROJECT" });
```

`bundle` takes an optional configuration argument, which is specified below.

### Configuration

Configuration options can be stored in `regal.json` or the `regal` property in `package.json`.
Configuration for both the Regal game and the game bundler are stored in the same place. Config values can be stored in `regal.json` or the `regal` property in `package.json` with the following schema:

```
{
game: GameMetadata
bundler: BundleConfig
}
```

See the [Regal documentation](https://github.com/regal/regal/blob/master/src/config/game-metadata.ts) for a description of `GameMetadata`.

`bundle` takes a single, optional argument with the following structure:

Expand All @@ -54,6 +67,8 @@ Configuration options can be stored in `regal.json` or the `regal` property in `
}
```

Values in `bundler` will override those found in any configuration files. If no value is found for a given property, a default value will be used in its place. Note that no configuration is necessary to bundle a game.

#### `configLocation`: string

Location of `regal.json` and/or `package.json`. Defaults to the project's root directory.
Expand Down Expand Up @@ -94,4 +109,21 @@ The module format of the bundle. Options: `cjs`, `esm`, `umd`. Defaults to `cjs`

#### `bundler.output.minify`: boolean

Whether minification should be done on the bundle after it's generated. Defaults to true.
Whether minification should be done on the bundle after it's generated. Defaults to true.

### Bundles

Game bundles are the form through which Regal games are shared, downloaded, and played.

Since games built on the Regal framework are intended to be *enjoyed by all people, on all platforms*, the goal is for many bundle types to allow the same game to be ported to different platforms with no extra work.

Currently, only the **standard** bundle is supported, which is simply an implementation of the [Regal `GameApi`](https://github.com/regal/regal/blob/master/src/api/game-api.ts).

A standard Regal game bundle can be consumed like so:

```ts
const Game: GameApi = await import("./my-game.regal.js");

let response = Game.postStartCommand();
response = Game.postPlayerCommand(response.instance, "command");
```

0 comments on commit bf219f8

Please sign in to comment.