Minee: Earth Engine Module Bundler
Minee is a command-line interface (CLI) tool specifically designed to bundle modules for Google Earth Engine. It addresses the challenge of managing multiple script dependencies within Earth Engine by consolidating them into a single, compact JavaScript file. This process significantly reduces import times and file sizes, improving performance when working with complex Earth Engine projects. The current stable version is `0.0.9`, with a release cadence that has seen several minor updates in quick succession, indicating active development and responsiveness to bug fixes. A key differentiator is its specialized focus on the Earth Engine ecosystem, handling its specific module resolution requirements. It offers options for minification, custom output paths, and configuration via a `.minee.json` file, allowing developers to streamline their Earth Engine development workflow. It primarily functions as a CLI tool, without an exposed programmatic API for direct JavaScript integration.
Common errors
-
error: git-credential-gcloud.sh: exit status 128
cause Improper or missing authentication with Earth Engine Git repositories. The `~/.gitcookies` file may be missing, corrupted, or contain incorrect credentials.fixRe-authenticate by visiting https://earthengine.googlesource.com/new-password and following the instructions to set up your `.gitcookies` file correctly. -
Error: Cannot read properties of undefined (reading 'dest')
cause This error or similar `TypeError` related to `dest` might occur in versions prior to 0.0.8 due to a bug in default destination path handling.fixEnsure `minee` is updated to version 0.0.8 or newer. Explicitly specify the `--dest` option, or ensure your `.minee.json` file has a valid `dest` property. -
Bundled module appears empty or is missing submodules.
cause A module caching bug in versions prior to 0.0.7 could lead to incomplete bundles, where submodules were not correctly included.fixUpdate `minee` to version 0.0.7 or newer to fix the module caching issue. Clear any local caches if the problem persists (though `minee` handles its own caching internally for repositories).
Warnings
- gotcha Before using minee to bundle modules from Earth Engine Git repositories, you must authenticate your machine with Earth Engine's Git service. This involves generating a password and storing credentials in `~/.gitcookies` via https://earthengine.googlesource.com/new-password.
- breaking In version 0.0.6, the `--entry` argument for specifying the module entry path was changed from a required positional argument to an optional named argument. Earlier versions would expect it without a flag.
- gotcha Older versions (pre-0.0.8) had a bug where the `--dest` path could be incorrectly handled, leading to bundled files not being written to the expected location or having incorrect names.
Install
-
npm install minee -
yarn add minee -
pnpm add minee
Imports
- minee CLI
import minee from 'minee'
npm install -g minee
Quickstart
# First, install minee globally:
npm install -g minee
# Ensure you have authenticated with Earth Engine Git repositories if you haven't already:
# Go to https://earthengine.googlesource.com/new-password and follow instructions to set up ~/.gitcookies.
# Example: Bundle an Earth Engine module and save it to a 'bundled' directory,
# keeping original variable names for easier debugging.
minee --entry=users/aazuspan/geeSharp:geeSharp --dest=./bundled/geeSharp.min.js --keep-names
# Alternatively, use a configuration file (.minee.json):
# Create a file named .minee.json in your project root:
# {
# "entry": "users/aazuspan/geeSharp:geeSharp",
# "dest": "./bundled/geeSharp.min.js",
# "keepNames": true
# }
# Then run minee without arguments:
minee