Skip to content

Package multiple Wren, Squirrel or ChaiScript files into one, through JavaScript.

License

Notifications You must be signed in to change notification settings

RobLoach/scriptpacker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScriptPacker

Package multiple Lua, Wren, Squirrel, Javascript, or ChaiScript scripts together into one bundle, through JavaScript.

Features

  • Lua require "MyModule"
  • Squirrel import("MyModule")
  • Wren import "MyModule"
  • Gravity #include "MyModule.gravity"
  • ChaiScript require("MyModule")
  • JavaScript require("MyModule")
  • Retains dependency tree
  • Relative import paths

Installation

npm i -g scriptpacker

Usage

scriptpacker build [input]

Build the given file

Positionals:
  input  The input file to build                         [default: "index.wren"]

Options:
  --version     Show version number                                    [boolean]
  --help        Show help                                              [boolean]
  --output, -o  Where to write the file       [string] [default: "packed.<ext>"]
  --minify, -m  Minify the output                     [boolean] [default: false]
  --prefix, -p  Text to prefix the output                 [string] [default: ""]

Example

  1. Create a script file to import, Unicorn.wren for example:

    class Unicorn {
    	construct new() {
    		System.print("Greetings.")
    	}
    	run() {
    		System.print("Running!")
    	}
    }
  2. Use import to bundle the module:

    import "Unicorn"
    // In Squirrel, it would be: import("Unicorn")
    // Use the imported class.
    var unicorn = Unicorn.new()
    unicorn.run()
  3. Run the build command

    scriptpack build index.wren --output=packed.wren
  4. See the resulting packed.wren

    // Unicorn.wren
    class Unicorn {
    	construct new() {
    		System.print("Greetings.")
    	}
    	run() {
    		System.print("Running!")
    	}
    }
    // Game.wren
    // import "Unicorn"
    var unicorn = Unicorn.new()
    unicorn.run()

Documentation

The following are examples of loading the Unicorn script across the different languages...

require "Unicorn"

// ... or
require("Unicorn")
import "Unicorn"
import("Unicorn")
require("Unicorn")

JavaScript

require("Unicorn")
#include "Unicorn.gravity"

About

Package multiple Wren, Squirrel or ChaiScript files into one, through JavaScript.

Topics

Resources

License

Stars

Watchers

Forks