Package Optimization

Overview

Unlike traditional package managers that dump entire repositories into your project, Jelly intelligently processes packages to keep only what you need. This results in smaller package directories.

Smart Package Cleanup

Jelly automatically removes unnecessary files and optimizes package structure during installation.

Before: Raw Wally Package

When you install a package with traditional tools, you get everything:

some_messy_package/
โ”œโ”€โ”€ README.md           # โŒ Documentation bloat
โ”œโ”€โ”€ LICENSE             # โŒ Legal files
โ”œโ”€โ”€ .gitignore          # โŒ Git configuration
โ”œโ”€โ”€ .github/            # โŒ CI/CD configurations
โ”‚   โ”œโ”€โ”€ workflows/
โ”‚   โ””โ”€โ”€ ISSUE_TEMPLATE/
โ”œโ”€โ”€ docs/               # โŒ Documentation
โ”‚   โ”œโ”€โ”€ getting-started.md
โ”‚   โ””โ”€โ”€ api-reference.md
โ”œโ”€โ”€ test/               # โŒ Test files
โ”‚   โ”œโ”€โ”€ init.spec.lua
โ”‚   โ””โ”€โ”€ TestUtils.lua
โ”œโ”€โ”€ examples/           # โŒ Example code
โ”‚   โ”œโ”€โ”€ basic-usage.lua
โ”‚   โ””โ”€โ”€ advanced-usage.lua
โ”œโ”€โ”€ wally.toml          # โŒ Package configuration
โ”œโ”€โ”€ default.project.json
โ”œโ”€โ”€ build/              # โŒ Build artifacts
โ”œโ”€โ”€ node_modules/       # โŒ Node.js dependencies
โ””โ”€โ”€ lib/                # โœ… Actual module
    โ”œโ”€โ”€ init.lua        # โœ… Main module file
    โ”œโ”€โ”€ Utils.lua       # โœ… Supporting modules
    โ””โ”€โ”€ Types.lua       # โœ… Type definitions

After: Jelly Processed

Jelly extracts only the essential code:

some_messy_package/
โ””โ”€โ”€ init.lua            # โœ… Only the essential module

Or for more complex packages:

complex_package/
โ”œโ”€โ”€ init.lua            # โœ… Main module
โ”œโ”€โ”€ Utils.lua           # โœ… Supporting modules
โ””โ”€โ”€ Types.lua           # โœ… Type definitions

Intelligent Module Resolution

Jelly automatically handles different package structures and finds the main module:

Standard Packages

For packages with init.lua at the root:

package/
โ””โ”€โ”€ init.lua

Result: Direct require("@self/package_name")

Nested Packages

For packages using default.project.json structure:

package/
โ”œโ”€โ”€ default.project.json
โ””โ”€โ”€ lib/
    โ””โ”€โ”€ init.lua

Jelly reads the project file and extracts the main module:

Result: require("@self/lib")

Messy Repositories

For packages with complex directory structures:

messy_package/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ MyModule/
โ”‚       โ””โ”€โ”€ init.lua
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ docs/
โ””โ”€โ”€ examples/

Jelly intelligently locates the main module and flattens the structure:

Result: Clean, optimized package structure

File Type Filtering

Jelly removes files based on patterns known to be unnecessary for runtime:

Removed File Types

  • Documentation: README.md, LICENSE, CHANGELOG.md
  • Configuration: .gitignore, .editorconfig, wally.toml
  • CI/CD: .github/, .gitlab-ci.yml, azure-pipelines.yml
  • Development: test/, tests/, spec/, __tests__/
  • Examples: examples/, demo/, sample/
  • Build artifacts: node_modules/, target/, dist/, build/
  • IDE files: .vscode/, .idea/, *.code-workspace

Preserved File Types

  • Lua modules: *.lua
  • Type definitions: *.d.lua
  • Project files: default.project.json
  • Essential configs: Files required for module resolution

Configuration Options

Control Jellyโ€™s optimization behavior in your jelly.json:

{
  "jelly": {
    "cleanup": true,        // Enable file cleanup
    "optimize": true,       // Enable structure optimization
    "packagesPath": "Packages"
  }
}

Cleanup Option

Default: true

Controls whether Jelly removes unnecessary files:

{
  "jelly": {
    "cleanup": false  // Keep all files
  }
}

Optimize Option

Default: true

Controls whether Jelly optimizes package structure:

{
  "jelly": {
    "optimize": false  // Keep original structure
  }
}