Compiler.Package

A module for loading and saving the outline and source code of packages (projects with a package-formatted gren.json).

type alias Package = { outline : PkgOutline, sources : Dict String String }

The outline and source files of a package.

Load from file system

loadFromPath : Permission -> Path -> Task LoadFromPathError Package

Loads an entire package from disk. The provided Path needs to point to the root directory of the package (the directory containing gren.json).

For core packages, like gren-lang/core, the sources might include JavaScript files.

type LoadFromPathError
= FromPathOutlineFileSystemError Error
| FromPathOutlineInvalidString
| FromPathOutlineInvalidJson Error
| FromPathOutlineIsApp
| FromPathFindSourcesError FindSourceFilesError

The types of errors that can happen as you load a package from the file system.

Bundles

The compiler will store entire projects in compressed form in a project's gren_packages directory. These functions will let you read and write such files, also known as package bundles.

loadFromStream : Readable Bytes -> Task LoadFromStreamError Package

This reads a package off a Stream.

This gives you some flexibility as to how the package bundle is retrieved. You can get Streams from FileSystem and HttpClient.

type LoadFromStreamError
= FromStreamStreamError Error
| FromStreamInvalidJson Error

The sort of errors that can occur when reading a bundle off a Stream.

saveToStream : Package -> Writable Bytes -> Task Error {}

Save a package to a Stream.

You'll have to create the Stream yourself using FileSystem, HttpClient or some other module.

The package will be encoded to JSON and compressed with gzip.