polybundle 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +12 -5
- package/package.json +2 -2
- package/src/bundler.js +1 -1
- package/src/cli.js +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,6 +4,11 @@ Simple (heavily clanker-made) Lua script bundler for Polytoria.
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
+
install globally
|
|
8
|
+
```
|
|
9
|
+
npm install -g polybundle
|
|
10
|
+
```
|
|
11
|
+
|
|
7
12
|
install from this repo:
|
|
8
13
|
|
|
9
14
|
```
|
|
@@ -43,6 +48,8 @@ An array of entry script paths (order matters):
|
|
|
43
48
|
```
|
|
44
49
|
|
|
45
50
|
## Example Output:
|
|
51
|
+
[Instance2Lua](https://github.com/geringverdien/Polytoria-Instance2Lua) is built using polybundle! Below is the bundled output from the boilerplate init scripts
|
|
52
|
+
|
|
46
53
|
```lua
|
|
47
54
|
local __module_env = {}
|
|
48
55
|
|
|
@@ -58,18 +65,18 @@ return returnedLib
|
|
|
58
65
|
end)()
|
|
59
66
|
|
|
60
67
|
-- polybundle: begin scripts\init1.lua
|
|
61
|
-
|
|
68
|
+
spawn(function()
|
|
62
69
|
local lib = __module_env["scripts/lib/library1.module.lua"]
|
|
63
70
|
|
|
64
71
|
local addResult = lib.Add(2, 50)
|
|
65
72
|
|
|
66
73
|
print(addResult)
|
|
67
74
|
print("added successfully in init1")
|
|
68
|
-
end)
|
|
75
|
+
end)
|
|
69
76
|
-- polybundle: end scripts\init1.lua
|
|
70
77
|
|
|
71
78
|
-- polybundle: begin scripts\init2.lua
|
|
72
|
-
|
|
79
|
+
spawn(function()
|
|
73
80
|
local addLib = __module_env["scripts/lib/library1.module.lua"]
|
|
74
81
|
|
|
75
82
|
local addResult = addLib.Add(9, 10)
|
|
@@ -79,6 +86,6 @@ local res = "add result is "
|
|
|
79
86
|
local final = res .. tostring(addResult)
|
|
80
87
|
|
|
81
88
|
print(final)
|
|
82
|
-
end)
|
|
89
|
+
end)
|
|
83
90
|
-- polybundle: end scripts\init2.lua
|
|
84
|
-
```
|
|
91
|
+
```
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polybundle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Lua script bundler for Polytoria.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
|
-
"polybundle": "
|
|
7
|
+
"polybundle": "bin/polybundle.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
package/src/bundler.js
CHANGED
|
@@ -140,7 +140,7 @@ function bundleEntries(entries, rootDir) {
|
|
|
140
140
|
|
|
141
141
|
const entrySource = fs.readFileSync(entryPath, "utf8");
|
|
142
142
|
const replaced = replaceRequiresWithModuleRefs(entrySource, entryPath, rootDir, moduleKeyMap);
|
|
143
|
-
const wrapped = `
|
|
143
|
+
const wrapped = `spawn(function()\n${normalizeLuaSource(replaced)}end)`;
|
|
144
144
|
const header = `-- polybundle: begin ${path.relative(rootDir, entryPath)}\n`;
|
|
145
145
|
const footer = `-- polybundle: end ${path.relative(rootDir, entryPath)}\n`;
|
|
146
146
|
chunks.push(header + normalizeLuaSource(wrapped) + footer);
|
package/src/cli.js
CHANGED
|
@@ -123,7 +123,14 @@ function run(args) {
|
|
|
123
123
|
: path.resolve(cwd, "dist", "bundle.lua");
|
|
124
124
|
|
|
125
125
|
try {
|
|
126
|
+
// save output file, warn user about localscript string lenght limit if output exceeds 65,535 characters
|
|
126
127
|
const bundled = bundleEntries(entries, cwd);
|
|
128
|
+
if (bundled.length > 65535) {
|
|
129
|
+
console.warn(
|
|
130
|
+
"Warning: Output exceeds 65,535 characters, which is the limit for LocalScripts in Polytoria.\n" +
|
|
131
|
+
"Consider splitting your code into multiple bundles or optimizing your code to reduce size."
|
|
132
|
+
);
|
|
133
|
+
}
|
|
127
134
|
fs.mkdirSync(path.dirname(outFile), { recursive: true });
|
|
128
135
|
fs.writeFileSync(outFile, bundled, "utf8");
|
|
129
136
|
console.log(`Bundled ${entries.length} entries into ${outFile}`);
|