@tilua/compiler 1.0.0
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/README.md +232 -0
- package/dist/chunk-S5C4VH6A.js +2310 -0
- package/dist/cli.cjs +2344 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +54 -0
- package/dist/index.cjs +2369 -0
- package/dist/index.d.cts +233 -0
- package/dist/index.d.ts +233 -0
- package/dist/index.js +55 -0
- package/package.json +55 -0
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
bundle
|
|
4
|
+
} from "./chunk-S5C4VH6A.js";
|
|
5
|
+
|
|
6
|
+
// src/cli.ts
|
|
7
|
+
import { writeFileSync } from "fs";
|
|
8
|
+
import { relative } from "path";
|
|
9
|
+
var usage = "usage: tilua <entry> [--out <file>] [--config <tilua.config.json>] [--noCheck] [--target luau|lua51]";
|
|
10
|
+
var args = process.argv.slice(2);
|
|
11
|
+
var entry;
|
|
12
|
+
var out;
|
|
13
|
+
var config;
|
|
14
|
+
var typeCheck = true;
|
|
15
|
+
var buildTarget;
|
|
16
|
+
for (let i = 0; i < args.length; i++) {
|
|
17
|
+
const arg = args[i];
|
|
18
|
+
if (arg === "--out") out = args[++i];
|
|
19
|
+
else if (arg === "--config") config = args[++i];
|
|
20
|
+
else if (arg === "--noCheck") typeCheck = false;
|
|
21
|
+
else if (arg === "--target") {
|
|
22
|
+
const value = args[++i];
|
|
23
|
+
if (value !== "luau" && value !== "lua51") {
|
|
24
|
+
console.error(`--target must be 'luau' or 'lua51', not '${value}'`);
|
|
25
|
+
process.exit(2);
|
|
26
|
+
}
|
|
27
|
+
buildTarget = value;
|
|
28
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
29
|
+
console.log(usage);
|
|
30
|
+
process.exit(0);
|
|
31
|
+
} else entry = arg;
|
|
32
|
+
}
|
|
33
|
+
if (!entry) {
|
|
34
|
+
console.error(usage);
|
|
35
|
+
process.exit(2);
|
|
36
|
+
}
|
|
37
|
+
async function main(from) {
|
|
38
|
+
const result = await bundle({ entry: from, config, typeCheck, target: buildTarget });
|
|
39
|
+
for (const d of result.diagnostics) {
|
|
40
|
+
console.error(`${relative(process.cwd(), d.file)}:${d.line}:${d.column} ${d.message}`);
|
|
41
|
+
}
|
|
42
|
+
if (result.code === void 0) {
|
|
43
|
+
console.error("no bundle written");
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const target = out ?? from.replace(/\.tilua$/, "") + ".luau";
|
|
47
|
+
writeFileSync(target, result.code);
|
|
48
|
+
console.log(`${target}: ${result.modules.length} module${result.modules.length === 1 ? "" : "s"}`);
|
|
49
|
+
process.exit(result.diagnostics.length ? 1 : 0);
|
|
50
|
+
}
|
|
51
|
+
main(entry).catch((error) => {
|
|
52
|
+
console.error(error instanceof Error ? error.message : error);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|