https://github.com/le0developer/yuepack
https://github.com/le0developer/yuepack
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/le0developer/yuepack
- Owner: Le0Developer
- Created: 2024-10-27T14:45:19.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-30T11:12:03.000Z (over 1 year ago)
- Last Synced: 2024-11-17T13:38:53.448Z (over 1 year ago)
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yuepack
A tool for packing yuescript projects into a single file.
Yuepack heavily depends on Yuescript. If you need a general solution for packing instead, use [luapack](https://github.com/le0developer/luapack).
Unlike luapack (which uses the regular `package` and `require` system of Lua), yuepack uses aliasing to import and export modules.
## Usage
Yuepack uses two "magic" macros that are inserted during the packing process.
- `$import "module", "name"`
- `$export "name", value`
The `$import` macro is used to import a module, and the `$export` macro is used to export a value.
Here is an example of a simple project:
```yue
-- main.yue
text = $import "module", "text"
print "Hello", text
-- module.yue
$export "text", "world"
```
You can find this example in the `example` directory.
To pack this project, run the following command:
```bash
yue -e yuepack.yue main.yue
```
This will generate a single Lua file with the following content:
```lua
-- yuepacked using 0.1.0
local _export_module_text
do
do
_export_module_text = "world"
end
end
do
local text = _export_module_text
print("Hello", text)
end
```