Package multiple Lua, Wren, Squirrel, Javascript, or ChaiScript scripts together into one bundle, through JavaScript.
- 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
npm i -g scriptpacker
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: ""]
-
Create a script file to import,
Unicorn.wren
for example:class Unicorn { construct new() { System.print("Greetings.") } run() { System.print("Running!") } }
-
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()
-
Run the build command
scriptpack build index.wren --output=packed.wren
-
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()
The following are examples of loading the Unicorn script across the different languages...
require "Unicorn"
// ... or
require("Unicorn")
import "Unicorn"
import("Unicorn")
require("Unicorn")
require("Unicorn")
#include "Unicorn.gravity"