@xnoxs/flux-lang 3.2.2 → 3.3.1
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/dist/flux-cli.js +206 -26
- package/dist/flux.cjs.js +63 -2
- package/dist/flux.esm.js +63 -2
- package/dist/flux.min.js +18 -16
- package/index.js +4 -0
- package/package.json +15 -13
- package/src/config.js +99 -0
package/dist/flux-cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*!
|
|
3
|
-
* flux-lang v3.
|
|
3
|
+
* flux-lang v3.3.1
|
|
4
4
|
* Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
|
|
5
5
|
* (c) 2026 Flux Lang Contributors
|
|
6
6
|
* Released under the MIT License
|
|
@@ -15,6 +15,63 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
// src/config.js
|
|
19
|
+
var require_config = __commonJS({
|
|
20
|
+
"src/config.js"(exports2, module2) {
|
|
21
|
+
"use strict";
|
|
22
|
+
var fs2 = require("fs");
|
|
23
|
+
var path2 = require("path");
|
|
24
|
+
var CONFIG_NAMES = [
|
|
25
|
+
"flux.config.js",
|
|
26
|
+
"flux.config.cjs",
|
|
27
|
+
".fluxrc.js"
|
|
28
|
+
];
|
|
29
|
+
function loadConfig2(cwd) {
|
|
30
|
+
const dir = cwd || process.cwd();
|
|
31
|
+
for (const name of CONFIG_NAMES) {
|
|
32
|
+
const configPath = path2.join(dir, name);
|
|
33
|
+
if (!fs2.existsSync(configPath)) continue;
|
|
34
|
+
delete require.cache[require.resolve(configPath)];
|
|
35
|
+
try {
|
|
36
|
+
const raw = require(configPath);
|
|
37
|
+
const cfg = raw && raw.default ? raw.default : raw;
|
|
38
|
+
if (typeof cfg !== "object" || cfg === null) {
|
|
39
|
+
process.stderr.write(
|
|
40
|
+
`[flux] warning: ${name} must export a plain object \u2014 ignoring
|
|
41
|
+
`
|
|
42
|
+
);
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
return cfg;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
process.stderr.write(
|
|
48
|
+
`[flux] error loading ${name}: ${e.message}
|
|
49
|
+
`
|
|
50
|
+
);
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
function mergeConfig2(fileConfig, cliOpts) {
|
|
57
|
+
const cfg = fileConfig || {};
|
|
58
|
+
const cli = cliOpts || {};
|
|
59
|
+
return {
|
|
60
|
+
jsxTarget: cli.jsxTarget !== void 0 ? cli.jsxTarget : cfg.jsxTarget || "browser",
|
|
61
|
+
outDir: cli.outDir !== void 0 ? cli.outDir : cfg.outDir || null,
|
|
62
|
+
sourcemap: cli.sourcemap !== void 0 ? cli.sourcemap : cfg.sourcemap || false,
|
|
63
|
+
mangle: cli.mangle !== void 0 ? cli.mangle : cfg.mangle !== void 0 ? cfg.mangle : true,
|
|
64
|
+
ignore: cli.ignore !== void 0 ? cli.ignore : cfg.ignore || [],
|
|
65
|
+
entry: cli.entry !== void 0 ? cli.entry : cfg.entry || null
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function defineConfig(config) {
|
|
69
|
+
return config;
|
|
70
|
+
}
|
|
71
|
+
module2.exports = { loadConfig: loadConfig2, mergeConfig: mergeConfig2, defineConfig };
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
18
75
|
// src/lexer.js
|
|
19
76
|
var require_lexer = __commonJS({
|
|
20
77
|
"src/lexer.js"(exports2, module2) {
|
|
@@ -7106,7 +7163,7 @@ var require_package = __commonJS({
|
|
|
7106
7163
|
"package.json"(exports2, module2) {
|
|
7107
7164
|
module2.exports = {
|
|
7108
7165
|
name: "@xnoxs/flux-lang",
|
|
7109
|
-
version: "3.
|
|
7166
|
+
version: "3.3.1",
|
|
7110
7167
|
description: "Flux \u2014 A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.",
|
|
7111
7168
|
main: "dist/flux.cjs.js",
|
|
7112
7169
|
module: "dist/flux.esm.js",
|
|
@@ -7131,6 +7188,7 @@ var require_package = __commonJS({
|
|
|
7131
7188
|
require: "./dist/flux.cjs.js",
|
|
7132
7189
|
default: "./dist/flux.cjs.js"
|
|
7133
7190
|
},
|
|
7191
|
+
"./config": "./src/config.js",
|
|
7134
7192
|
"./dist/cjs": "./dist/flux.cjs.js",
|
|
7135
7193
|
"./dist/esm": "./dist/flux.esm.js",
|
|
7136
7194
|
"./dist/min": "./dist/flux.min.js",
|
|
@@ -7142,6 +7200,7 @@ var require_package = __commonJS({
|
|
|
7142
7200
|
"dist/",
|
|
7143
7201
|
"src/stdlib.js",
|
|
7144
7202
|
"src/formatter.js",
|
|
7203
|
+
"src/config.js",
|
|
7145
7204
|
"src/self/",
|
|
7146
7205
|
"scripts/build.js",
|
|
7147
7206
|
"index.js",
|
|
@@ -8117,6 +8176,9 @@ var require_test_runner = __commonJS({
|
|
|
8117
8176
|
var fs2 = require("fs");
|
|
8118
8177
|
var path2 = require("path");
|
|
8119
8178
|
var os = require("os");
|
|
8179
|
+
var CONFIG_PATH = JSON.stringify(path2.join(__dirname, "config.js"));
|
|
8180
|
+
var TRANSPILER_PATH = JSON.stringify(path2.join(__dirname, "transpiler.js"));
|
|
8181
|
+
var TEST_RUNNER_PATH = JSON.stringify(__filename);
|
|
8120
8182
|
var C2 = {
|
|
8121
8183
|
reset: "\x1B[0m",
|
|
8122
8184
|
bold: "\x1B[1m",
|
|
@@ -8228,8 +8290,19 @@ function __runAll(mod) {
|
|
|
8228
8290
|
while ((match = fnRe.exec(result.output)) !== null) {
|
|
8229
8291
|
fnNames.push(match[1]);
|
|
8230
8292
|
}
|
|
8293
|
+
const shimPreamble = [
|
|
8294
|
+
`// \u2500\u2500 shim globals for flux.config.js tests \u2500\u2500`,
|
|
8295
|
+
`const __configMod = require(${CONFIG_PATH});`,
|
|
8296
|
+
`const __transpilerMod= require(${TRANSPILER_PATH});`,
|
|
8297
|
+
`const __runnerMod = require(${TEST_RUNNER_PATH});`,
|
|
8298
|
+
`const mergeConfigShim = __configMod.mergeConfig;`,
|
|
8299
|
+
`const defineConfigShim = __configMod.defineConfig;`,
|
|
8300
|
+
`const transpileShim = __transpilerMod.transpile;`,
|
|
8301
|
+
`const matchIgnoreShim = __runnerMod.matchIgnore;`
|
|
8302
|
+
].join("\n");
|
|
8231
8303
|
const runner = [
|
|
8232
8304
|
TEST_HELPERS,
|
|
8305
|
+
shimPreamble,
|
|
8233
8306
|
result.output,
|
|
8234
8307
|
"",
|
|
8235
8308
|
"// \u2500\u2500 auto-generated test runner \u2500\u2500",
|
|
@@ -8261,7 +8334,21 @@ function __runAll(mod) {
|
|
|
8261
8334
|
}
|
|
8262
8335
|
}
|
|
8263
8336
|
}
|
|
8264
|
-
function
|
|
8337
|
+
function matchIgnore(filePath, patterns) {
|
|
8338
|
+
if (!patterns || patterns.length === 0) return false;
|
|
8339
|
+
const normalize = (p) => p.replace(/\\/g, "/");
|
|
8340
|
+
const fp = normalize(filePath);
|
|
8341
|
+
for (const pattern of patterns) {
|
|
8342
|
+
let re = normalize(pattern).replace(/\*\*/g, "\0DSTAR\0");
|
|
8343
|
+
re = re.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
8344
|
+
re = re.replace(/\*/g, "[^/]*");
|
|
8345
|
+
re = re.replace(/\x00DSTAR\x00\//g, "(.+/)?").replace(/\x00DSTAR\x00/g, ".*");
|
|
8346
|
+
if (new RegExp(`(^|/)${re}$`).test(fp)) return true;
|
|
8347
|
+
}
|
|
8348
|
+
return false;
|
|
8349
|
+
}
|
|
8350
|
+
function runTests(target, transpile2, opts) {
|
|
8351
|
+
const ignorePatterns = opts && opts.ignore || [];
|
|
8265
8352
|
let files;
|
|
8266
8353
|
try {
|
|
8267
8354
|
files = discoverTestFiles(target);
|
|
@@ -8269,6 +8356,13 @@ function __runAll(mod) {
|
|
|
8269
8356
|
console.error(clr2(C2.red, `\u2717 ${e.message}`));
|
|
8270
8357
|
process.exit(1);
|
|
8271
8358
|
}
|
|
8359
|
+
if (ignorePatterns.length > 0) {
|
|
8360
|
+
const before = files.length;
|
|
8361
|
+
files = files.filter((f) => !matchIgnore(f, ignorePatterns));
|
|
8362
|
+
const skipped = before - files.length;
|
|
8363
|
+
if (skipped > 0)
|
|
8364
|
+
console.log(clr2(C2.gray, ` (skipped ${skipped} file${skipped === 1 ? "" : "s"} via ignore patterns)`));
|
|
8365
|
+
}
|
|
8272
8366
|
if (files.length === 0) {
|
|
8273
8367
|
console.log(clr2(C2.yellow, `No *.test.flux files found in: ${target}`));
|
|
8274
8368
|
return;
|
|
@@ -8315,13 +8409,14 @@ function __runAll(mod) {
|
|
|
8315
8409
|
console.log();
|
|
8316
8410
|
if (totalFail > 0) process.exitCode = 1;
|
|
8317
8411
|
}
|
|
8318
|
-
module2.exports = { runTests, runTestFile, discoverTestFiles };
|
|
8412
|
+
module2.exports = { runTests, runTestFile, discoverTestFiles, matchIgnore };
|
|
8319
8413
|
}
|
|
8320
8414
|
});
|
|
8321
8415
|
|
|
8322
8416
|
// src/cli.js
|
|
8323
8417
|
var fs = require("fs");
|
|
8324
8418
|
var path = require("path");
|
|
8419
|
+
var { loadConfig, mergeConfig } = require_config();
|
|
8325
8420
|
var USE_SELF_HOSTED = process.argv.includes("--self-hosted") || process.env.FLUX_SELF_HOSTED === "1";
|
|
8326
8421
|
process.argv = process.argv.filter((a) => a !== "--self-hosted");
|
|
8327
8422
|
function loadTranspiler() {
|
|
@@ -8407,6 +8502,7 @@ function showHelp() {
|
|
|
8407
8502
|
console.log(clr(C.bold, "OPTIONS:"));
|
|
8408
8503
|
console.log(` ${clr(C.yellow, "--out, -o <file>")} Output file name`);
|
|
8409
8504
|
console.log(` ${clr(C.yellow, "--sourcemap, -m")} Generate source map (.js.map)`);
|
|
8505
|
+
console.log(` ${clr(C.yellow, "--watch, -w")} Watch mode (re-run on save)`);
|
|
8410
8506
|
console.log(` ${clr(C.yellow, "--stdout")} Print output to terminal`);
|
|
8411
8507
|
console.log(` ${clr(C.yellow, "--no-color")} Disable colors`);
|
|
8412
8508
|
console.log();
|
|
@@ -8583,6 +8679,18 @@ function cmdInit(name) {
|
|
|
8583
8679
|
dependencies: {},
|
|
8584
8680
|
devDependencies: { "flux-lang": `^${VERSION}` }
|
|
8585
8681
|
}, null, 2), "utf8");
|
|
8682
|
+
fs.writeFileSync(path.join(dir, "flux.config.js"), [
|
|
8683
|
+
"// Flux Lang project configuration",
|
|
8684
|
+
"// All options are optional \u2014 CLI flags always override these values.",
|
|
8685
|
+
"module.exports = {",
|
|
8686
|
+
" // jsxTarget : 'browser', // 'browser' | 'server' | 'react'",
|
|
8687
|
+
" // outDir : './dist', // output directory for compiled files",
|
|
8688
|
+
" // sourcemap : false, // generate .js.map files",
|
|
8689
|
+
" // mangle : true, // obfuscate names in output",
|
|
8690
|
+
" // ignore : [], // glob patterns to skip in `flux test`",
|
|
8691
|
+
" // entry : 'src/main.flux', // default entry for `flux bundle`",
|
|
8692
|
+
"};"
|
|
8693
|
+
].join("\n"), "utf8");
|
|
8586
8694
|
fs.writeFileSync(path.join(dir, ".gitignore"), [
|
|
8587
8695
|
"node_modules/",
|
|
8588
8696
|
"dist/",
|
|
@@ -8616,6 +8724,7 @@ function cmdInit(name) {
|
|
|
8616
8724
|
console.log();
|
|
8617
8725
|
console.log(clr(C.gray, " Files created:"));
|
|
8618
8726
|
console.log(" " + clr(C.cyan, `${projectName}/src/main.flux`));
|
|
8727
|
+
console.log(" " + clr(C.cyan, `${projectName}/flux.config.js`));
|
|
8619
8728
|
console.log(" " + clr(C.cyan, `${projectName}/package.json`));
|
|
8620
8729
|
console.log(" " + clr(C.cyan, `${projectName}/.gitignore`));
|
|
8621
8730
|
console.log(" " + clr(C.cyan, `${projectName}/README.md`));
|
|
@@ -8628,12 +8737,22 @@ function cmdInit(name) {
|
|
|
8628
8737
|
}
|
|
8629
8738
|
function cmdCompile(filePath, opts) {
|
|
8630
8739
|
const { source, abs } = readFluxFile(filePath);
|
|
8631
|
-
|
|
8740
|
+
let outPath;
|
|
8741
|
+
if (opts.out) {
|
|
8742
|
+
outPath = path.resolve(opts.out);
|
|
8743
|
+
} else if (opts.outDir) {
|
|
8744
|
+
const dir = path.resolve(opts.outDir);
|
|
8745
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
8746
|
+
outPath = path.join(dir, path.basename(filePath, ".flux") + ".js");
|
|
8747
|
+
} else {
|
|
8748
|
+
outPath = deriveOutPath(filePath, null);
|
|
8749
|
+
}
|
|
8632
8750
|
const mapPath = outPath + ".map";
|
|
8633
8751
|
const t0 = Date.now();
|
|
8634
8752
|
const result = transpile(source, {
|
|
8635
8753
|
sourcemap: opts.sourcemap,
|
|
8636
8754
|
mangle: opts.mangle,
|
|
8755
|
+
jsxTarget: opts.jsxTarget,
|
|
8637
8756
|
sourceFile: path.relative(path.dirname(outPath), abs),
|
|
8638
8757
|
outputFile: path.basename(outPath)
|
|
8639
8758
|
});
|
|
@@ -8685,9 +8804,12 @@ function cmdBundle(entryPath, opts) {
|
|
|
8685
8804
|
clr(C.green, `\u2713 Bundle done`) + clr(C.gray, ` (${elapsed}ms)`) + ` ${path.basename(abs)} + ${result.modules - 1} module(s) \u2192 ` + clr(C.cyan, path.relative(process.cwd(), outFile)) + clr(C.gray, ` [${kb} KB]`)
|
|
8686
8805
|
);
|
|
8687
8806
|
}
|
|
8688
|
-
function cmdRun(filePath) {
|
|
8807
|
+
function cmdRun(filePath, opts) {
|
|
8689
8808
|
const { source, abs } = readFluxFile(filePath);
|
|
8690
|
-
const result = transpile(source
|
|
8809
|
+
const result = transpile(source, {
|
|
8810
|
+
jsxTarget: opts && opts.jsxTarget,
|
|
8811
|
+
mangle: opts && opts.mangle
|
|
8812
|
+
});
|
|
8691
8813
|
if (!result.success) {
|
|
8692
8814
|
console.error(clr(C.red, `
|
|
8693
8815
|
\u2717 Compile error`));
|
|
@@ -8711,8 +8833,8 @@ function cmdRun(filePath) {
|
|
|
8711
8833
|
}
|
|
8712
8834
|
}
|
|
8713
8835
|
}
|
|
8714
|
-
function
|
|
8715
|
-
const
|
|
8836
|
+
function runCheck(abs) {
|
|
8837
|
+
const source = fs.readFileSync(abs, "utf8");
|
|
8716
8838
|
const baseName = path.basename(abs);
|
|
8717
8839
|
const result = transpile(source, { check: true, typecheck: true });
|
|
8718
8840
|
if (!result.success) {
|
|
@@ -8721,15 +8843,15 @@ function cmdCheck(filePath) {
|
|
|
8721
8843
|
console.error(clr(C.red, `
|
|
8722
8844
|
\u2717 ${baseName}: ${n} ${kind} error${n > 1 ? "s" : ""}`));
|
|
8723
8845
|
printErrors(result.errors, source, abs);
|
|
8724
|
-
|
|
8846
|
+
return { ok: false, typeErrors: 0, warnings: 0 };
|
|
8725
8847
|
}
|
|
8726
|
-
let
|
|
8848
|
+
let ok = true;
|
|
8727
8849
|
const typeErrors = result.typeErrors || [];
|
|
8728
8850
|
if (typeErrors.length > 0) {
|
|
8729
8851
|
console.error(clr(C.red, `
|
|
8730
8852
|
\u2717 ${baseName}: ${typeErrors.length} type error(s)`));
|
|
8731
8853
|
printErrors(typeErrors, source, abs);
|
|
8732
|
-
|
|
8854
|
+
ok = false;
|
|
8733
8855
|
}
|
|
8734
8856
|
const warnings = [...result.typeWarnings || []];
|
|
8735
8857
|
for (const w of warnings) {
|
|
@@ -8745,7 +8867,7 @@ function cmdCheck(filePath) {
|
|
|
8745
8867
|
const tw = typeErrors.length;
|
|
8746
8868
|
const ww = warnings.length;
|
|
8747
8869
|
console.log();
|
|
8748
|
-
if (
|
|
8870
|
+
if (ok) {
|
|
8749
8871
|
console.log(
|
|
8750
8872
|
clr(C.green, `\u2713 ${baseName} \u2014 no errors`) + (ww > 0 ? clr(C.yellow, ` (${ww} warning${ww > 1 ? "s" : ""})`) : "")
|
|
8751
8873
|
);
|
|
@@ -8754,7 +8876,45 @@ function cmdCheck(filePath) {
|
|
|
8754
8876
|
}
|
|
8755
8877
|
console.log(clr(C.gray, ` Functions: ${fns} | Classes: ${cls} | JS output: ${lines} lines`));
|
|
8756
8878
|
console.log();
|
|
8757
|
-
|
|
8879
|
+
return { ok, typeErrors: tw, warnings: ww };
|
|
8880
|
+
}
|
|
8881
|
+
function cmdCheck(filePath, opts) {
|
|
8882
|
+
const abs = path.resolve(filePath);
|
|
8883
|
+
const baseName = path.basename(abs);
|
|
8884
|
+
if (!fs.existsSync(abs)) {
|
|
8885
|
+
console.error(clr(C.red, `[Error] File not found: ${abs}`));
|
|
8886
|
+
process.exit(1);
|
|
8887
|
+
}
|
|
8888
|
+
if (!opts || !opts.watch) {
|
|
8889
|
+
const { ok } = runCheck(abs);
|
|
8890
|
+
if (!ok) process.exit(1);
|
|
8891
|
+
return;
|
|
8892
|
+
}
|
|
8893
|
+
const CLEAR = "\x1B[2J\x1B[H";
|
|
8894
|
+
const HEADER = clr(C.cyan, `
|
|
8895
|
+
\u{1F441} flux check --watch: ${baseName}
|
|
8896
|
+
`);
|
|
8897
|
+
function doCheck() {
|
|
8898
|
+
if (!noColor) process.stdout.write(CLEAR);
|
|
8899
|
+
console.log(HEADER);
|
|
8900
|
+
const ts = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
8901
|
+
console.log(clr(C.gray, ` Last check: ${ts}`));
|
|
8902
|
+
console.log();
|
|
8903
|
+
try {
|
|
8904
|
+
runCheck(abs);
|
|
8905
|
+
} catch (e) {
|
|
8906
|
+
console.error(clr(C.red, `[Error] ${e.message}`));
|
|
8907
|
+
}
|
|
8908
|
+
console.log(clr(C.gray, ` Watching for changes\u2026 (Ctrl+C to exit)`));
|
|
8909
|
+
}
|
|
8910
|
+
doCheck();
|
|
8911
|
+
let debounce = null;
|
|
8912
|
+
fs.watch(abs, { persistent: true }, (event) => {
|
|
8913
|
+
if (event === "change") {
|
|
8914
|
+
clearTimeout(debounce);
|
|
8915
|
+
debounce = setTimeout(doCheck, 80);
|
|
8916
|
+
}
|
|
8917
|
+
});
|
|
8758
8918
|
}
|
|
8759
8919
|
function cmdLint(filePath) {
|
|
8760
8920
|
const { source, abs } = readFluxFile(filePath);
|
|
@@ -8885,10 +9045,10 @@ function cmdFmt(filePath, opts) {
|
|
|
8885
9045
|
const diff = Math.abs(output.split("\n").length - source.split("\n").length);
|
|
8886
9046
|
console.log(clr(C.green, `\u2713 ${path.basename(abs)} \u2014 formatted`) + (diff > 0 ? clr(C.gray, ` (${diff} line${diff === 1 ? "" : "s"} changed)`) : ""));
|
|
8887
9047
|
}
|
|
8888
|
-
function cmdTest(dirOrFile) {
|
|
9048
|
+
function cmdTest(dirOrFile, opts) {
|
|
8889
9049
|
const { runTests } = require_test_runner();
|
|
8890
9050
|
const target = dirOrFile || "tests";
|
|
8891
|
-
runTests(target, transpile);
|
|
9051
|
+
runTests(target, transpile, { ignore: opts && opts.ignore || [] });
|
|
8892
9052
|
}
|
|
8893
9053
|
function cmdTokens(filePath) {
|
|
8894
9054
|
const { source } = readFluxFile(filePath);
|
|
@@ -8925,13 +9085,26 @@ function cmdWatch(filePath, opts) {
|
|
|
8925
9085
|
function doCompile() {
|
|
8926
9086
|
try {
|
|
8927
9087
|
const source = fs.readFileSync(abs, "utf8");
|
|
8928
|
-
const result = transpile(source
|
|
9088
|
+
const result = transpile(source, {
|
|
9089
|
+
jsxTarget: opts.jsxTarget,
|
|
9090
|
+
sourcemap: opts.sourcemap,
|
|
9091
|
+
mangle: opts.mangle
|
|
9092
|
+
});
|
|
8929
9093
|
const ts = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
8930
9094
|
if (!result.success) {
|
|
8931
9095
|
console.error(clr(C.red, `[${ts}] \u2717 Error`));
|
|
8932
9096
|
printErrors(result.errors, source, abs);
|
|
8933
9097
|
} else {
|
|
8934
|
-
|
|
9098
|
+
let outPath;
|
|
9099
|
+
if (opts.out) {
|
|
9100
|
+
outPath = path.resolve(opts.out);
|
|
9101
|
+
} else if (opts.outDir) {
|
|
9102
|
+
const dir = path.resolve(opts.outDir);
|
|
9103
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
9104
|
+
outPath = path.join(dir, path.basename(filePath, ".flux") + ".js");
|
|
9105
|
+
} else {
|
|
9106
|
+
outPath = deriveOutPath(filePath, null);
|
|
9107
|
+
}
|
|
8935
9108
|
fs.writeFileSync(outPath, result.output, "utf8");
|
|
8936
9109
|
console.log(clr(C.gray, `[${ts}]`) + clr(C.green, ` \u2713 Compiled \u2192 ${path.relative(process.cwd(), outPath)}`));
|
|
8937
9110
|
}
|
|
@@ -9422,7 +9595,7 @@ function parseArgs(argv) {
|
|
|
9422
9595
|
const args = argv.slice(2);
|
|
9423
9596
|
const cmd = args[0];
|
|
9424
9597
|
const file = args[1] && !args[1].startsWith("-") ? args[1] : null;
|
|
9425
|
-
const opts = { stdout: false, out: null, sourcemap:
|
|
9598
|
+
const opts = { stdout: false, out: null, sourcemap: void 0, mangle: void 0, jsxTarget: void 0, watch: false };
|
|
9426
9599
|
const publishOpts = {
|
|
9427
9600
|
bump: "patch",
|
|
9428
9601
|
ver: null,
|
|
@@ -9439,6 +9612,9 @@ function parseArgs(argv) {
|
|
|
9439
9612
|
if (args[i] === "--no-mangle" || args[i] === "-nm") opts.mangle = false;
|
|
9440
9613
|
if ((args[i] === "-o" || args[i] === "--out") && args[i + 1]) opts.out = args[++i];
|
|
9441
9614
|
if (args[i] === "--no-color") process.env.NO_COLOR = "1";
|
|
9615
|
+
if ((args[i] === "--jsx-target" || args[i] === "--jsxTarget") && args[i + 1])
|
|
9616
|
+
opts.jsxTarget = args[++i];
|
|
9617
|
+
if (args[i] === "--watch" || args[i] === "-w") opts.watch = true;
|
|
9442
9618
|
if (args[i] === "--patch") publishOpts.bump = "patch";
|
|
9443
9619
|
if (args[i] === "--minor") publishOpts.bump = "minor";
|
|
9444
9620
|
if (args[i] === "--major") publishOpts.bump = "major";
|
|
@@ -9454,6 +9630,9 @@ function parseArgs(argv) {
|
|
|
9454
9630
|
}
|
|
9455
9631
|
function main() {
|
|
9456
9632
|
const { cmd, file, opts, publishOpts } = parseArgs(process.argv);
|
|
9633
|
+
const fileConfig = loadConfig();
|
|
9634
|
+
const merged = mergeConfig(fileConfig, opts);
|
|
9635
|
+
const finalOpts = { stdout: opts.stdout, out: opts.out, ...merged };
|
|
9457
9636
|
switch (cmd) {
|
|
9458
9637
|
case "init": {
|
|
9459
9638
|
const name = process.argv[3] && !process.argv[3].startsWith("-") ? process.argv[3] : null;
|
|
@@ -9465,15 +9644,16 @@ function main() {
|
|
|
9465
9644
|
console.error(clr(C.red, "Specify a file: flux compile <file.flux>"));
|
|
9466
9645
|
process.exit(1);
|
|
9467
9646
|
}
|
|
9468
|
-
cmdCompile(file,
|
|
9647
|
+
cmdCompile(file, finalOpts);
|
|
9469
9648
|
break;
|
|
9470
9649
|
}
|
|
9471
9650
|
case "bundle": {
|
|
9472
|
-
|
|
9651
|
+
const entryFile = file || finalOpts.entry;
|
|
9652
|
+
if (!entryFile) {
|
|
9473
9653
|
console.error(clr(C.red, "Specify a file: flux bundle <entry.flux>"));
|
|
9474
9654
|
process.exit(1);
|
|
9475
9655
|
}
|
|
9476
|
-
cmdBundle(
|
|
9656
|
+
cmdBundle(entryFile, finalOpts);
|
|
9477
9657
|
break;
|
|
9478
9658
|
}
|
|
9479
9659
|
case "run": {
|
|
@@ -9481,7 +9661,7 @@ function main() {
|
|
|
9481
9661
|
console.error(clr(C.red, "Specify a file: flux run <file.flux>"));
|
|
9482
9662
|
process.exit(1);
|
|
9483
9663
|
}
|
|
9484
|
-
cmdRun(file);
|
|
9664
|
+
cmdRun(file, finalOpts);
|
|
9485
9665
|
break;
|
|
9486
9666
|
}
|
|
9487
9667
|
case "check": {
|
|
@@ -9489,7 +9669,7 @@ function main() {
|
|
|
9489
9669
|
console.error(clr(C.red, "Specify a file: flux check <file.flux>"));
|
|
9490
9670
|
process.exit(1);
|
|
9491
9671
|
}
|
|
9492
|
-
cmdCheck(file);
|
|
9672
|
+
cmdCheck(file, finalOpts);
|
|
9493
9673
|
break;
|
|
9494
9674
|
}
|
|
9495
9675
|
case "lint": {
|
|
@@ -9521,7 +9701,7 @@ function main() {
|
|
|
9521
9701
|
console.error(clr(C.red, "Specify a file: flux watch <file.flux>"));
|
|
9522
9702
|
process.exit(1);
|
|
9523
9703
|
}
|
|
9524
|
-
cmdWatch(file,
|
|
9704
|
+
cmdWatch(file, finalOpts);
|
|
9525
9705
|
break;
|
|
9526
9706
|
}
|
|
9527
9707
|
case "fmt": {
|
|
@@ -9533,7 +9713,7 @@ function main() {
|
|
|
9533
9713
|
break;
|
|
9534
9714
|
}
|
|
9535
9715
|
case "test": {
|
|
9536
|
-
cmdTest(file || process.argv[3]);
|
|
9716
|
+
cmdTest(file || process.argv[3], finalOpts);
|
|
9537
9717
|
break;
|
|
9538
9718
|
}
|
|
9539
9719
|
case "publish": {
|
package/dist/flux.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* flux-lang v3.
|
|
2
|
+
* flux-lang v3.3.1
|
|
3
3
|
* Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
|
|
4
4
|
* (c) 2026 Flux Lang Contributors
|
|
5
5
|
* Released under the MIT License
|
|
@@ -7192,6 +7192,63 @@ var require_bundler = __commonJS({
|
|
|
7192
7192
|
}
|
|
7193
7193
|
});
|
|
7194
7194
|
|
|
7195
|
+
// src/config.js
|
|
7196
|
+
var require_config = __commonJS({
|
|
7197
|
+
"src/config.js"(exports2, module2) {
|
|
7198
|
+
"use strict";
|
|
7199
|
+
var fs = require("fs");
|
|
7200
|
+
var path = require("path");
|
|
7201
|
+
var CONFIG_NAMES = [
|
|
7202
|
+
"flux.config.js",
|
|
7203
|
+
"flux.config.cjs",
|
|
7204
|
+
".fluxrc.js"
|
|
7205
|
+
];
|
|
7206
|
+
function loadConfig2(cwd) {
|
|
7207
|
+
const dir = cwd || process.cwd();
|
|
7208
|
+
for (const name of CONFIG_NAMES) {
|
|
7209
|
+
const configPath = path.join(dir, name);
|
|
7210
|
+
if (!fs.existsSync(configPath)) continue;
|
|
7211
|
+
delete require.cache[require.resolve(configPath)];
|
|
7212
|
+
try {
|
|
7213
|
+
const raw = require(configPath);
|
|
7214
|
+
const cfg = raw && raw.default ? raw.default : raw;
|
|
7215
|
+
if (typeof cfg !== "object" || cfg === null) {
|
|
7216
|
+
process.stderr.write(
|
|
7217
|
+
`[flux] warning: ${name} must export a plain object \u2014 ignoring
|
|
7218
|
+
`
|
|
7219
|
+
);
|
|
7220
|
+
return {};
|
|
7221
|
+
}
|
|
7222
|
+
return cfg;
|
|
7223
|
+
} catch (e) {
|
|
7224
|
+
process.stderr.write(
|
|
7225
|
+
`[flux] error loading ${name}: ${e.message}
|
|
7226
|
+
`
|
|
7227
|
+
);
|
|
7228
|
+
return {};
|
|
7229
|
+
}
|
|
7230
|
+
}
|
|
7231
|
+
return {};
|
|
7232
|
+
}
|
|
7233
|
+
function mergeConfig2(fileConfig, cliOpts) {
|
|
7234
|
+
const cfg = fileConfig || {};
|
|
7235
|
+
const cli = cliOpts || {};
|
|
7236
|
+
return {
|
|
7237
|
+
jsxTarget: cli.jsxTarget !== void 0 ? cli.jsxTarget : cfg.jsxTarget || "browser",
|
|
7238
|
+
outDir: cli.outDir !== void 0 ? cli.outDir : cfg.outDir || null,
|
|
7239
|
+
sourcemap: cli.sourcemap !== void 0 ? cli.sourcemap : cfg.sourcemap || false,
|
|
7240
|
+
mangle: cli.mangle !== void 0 ? cli.mangle : cfg.mangle !== void 0 ? cfg.mangle : true,
|
|
7241
|
+
ignore: cli.ignore !== void 0 ? cli.ignore : cfg.ignore || [],
|
|
7242
|
+
entry: cli.entry !== void 0 ? cli.entry : cfg.entry || null
|
|
7243
|
+
};
|
|
7244
|
+
}
|
|
7245
|
+
function defineConfig2(config) {
|
|
7246
|
+
return config;
|
|
7247
|
+
}
|
|
7248
|
+
module2.exports = { loadConfig: loadConfig2, mergeConfig: mergeConfig2, defineConfig: defineConfig2 };
|
|
7249
|
+
}
|
|
7250
|
+
});
|
|
7251
|
+
|
|
7195
7252
|
// index.js
|
|
7196
7253
|
var { transpile } = require_transpiler();
|
|
7197
7254
|
var { format } = require_formatter();
|
|
@@ -7199,6 +7256,7 @@ var { buildStdlib, detectUsedSymbols, STDLIB_SYMBOLS } = require_stdlib();
|
|
|
7199
7256
|
var { Lexer } = require_lexer();
|
|
7200
7257
|
var { Parser } = require_parser();
|
|
7201
7258
|
var { bundle } = require_bundler();
|
|
7259
|
+
var { loadConfig, mergeConfig, defineConfig } = require_config();
|
|
7202
7260
|
module.exports = {
|
|
7203
7261
|
transpile,
|
|
7204
7262
|
format,
|
|
@@ -7207,5 +7265,8 @@ module.exports = {
|
|
|
7207
7265
|
STDLIB_SYMBOLS,
|
|
7208
7266
|
Lexer,
|
|
7209
7267
|
Parser,
|
|
7210
|
-
bundle
|
|
7268
|
+
bundle,
|
|
7269
|
+
loadConfig,
|
|
7270
|
+
mergeConfig,
|
|
7271
|
+
defineConfig
|
|
7211
7272
|
};
|
package/dist/flux.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* flux-lang v3.
|
|
2
|
+
* flux-lang v3.3.1
|
|
3
3
|
* Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
|
|
4
4
|
* (c) 2026 Flux Lang Contributors
|
|
5
5
|
* Released under the MIT License
|
|
@@ -7197,6 +7197,63 @@ var require_bundler = __commonJS({
|
|
|
7197
7197
|
}
|
|
7198
7198
|
});
|
|
7199
7199
|
|
|
7200
|
+
// src/config.js
|
|
7201
|
+
var require_config = __commonJS({
|
|
7202
|
+
"src/config.js"(exports, module) {
|
|
7203
|
+
"use strict";
|
|
7204
|
+
var fs = __require("fs");
|
|
7205
|
+
var path = __require("path");
|
|
7206
|
+
var CONFIG_NAMES = [
|
|
7207
|
+
"flux.config.js",
|
|
7208
|
+
"flux.config.cjs",
|
|
7209
|
+
".fluxrc.js"
|
|
7210
|
+
];
|
|
7211
|
+
function loadConfig(cwd) {
|
|
7212
|
+
const dir = cwd || process.cwd();
|
|
7213
|
+
for (const name of CONFIG_NAMES) {
|
|
7214
|
+
const configPath = path.join(dir, name);
|
|
7215
|
+
if (!fs.existsSync(configPath)) continue;
|
|
7216
|
+
delete __require.cache[__require.resolve(configPath)];
|
|
7217
|
+
try {
|
|
7218
|
+
const raw = __require(configPath);
|
|
7219
|
+
const cfg = raw && raw.default ? raw.default : raw;
|
|
7220
|
+
if (typeof cfg !== "object" || cfg === null) {
|
|
7221
|
+
process.stderr.write(
|
|
7222
|
+
`[flux] warning: ${name} must export a plain object \u2014 ignoring
|
|
7223
|
+
`
|
|
7224
|
+
);
|
|
7225
|
+
return {};
|
|
7226
|
+
}
|
|
7227
|
+
return cfg;
|
|
7228
|
+
} catch (e) {
|
|
7229
|
+
process.stderr.write(
|
|
7230
|
+
`[flux] error loading ${name}: ${e.message}
|
|
7231
|
+
`
|
|
7232
|
+
);
|
|
7233
|
+
return {};
|
|
7234
|
+
}
|
|
7235
|
+
}
|
|
7236
|
+
return {};
|
|
7237
|
+
}
|
|
7238
|
+
function mergeConfig(fileConfig, cliOpts) {
|
|
7239
|
+
const cfg = fileConfig || {};
|
|
7240
|
+
const cli = cliOpts || {};
|
|
7241
|
+
return {
|
|
7242
|
+
jsxTarget: cli.jsxTarget !== void 0 ? cli.jsxTarget : cfg.jsxTarget || "browser",
|
|
7243
|
+
outDir: cli.outDir !== void 0 ? cli.outDir : cfg.outDir || null,
|
|
7244
|
+
sourcemap: cli.sourcemap !== void 0 ? cli.sourcemap : cfg.sourcemap || false,
|
|
7245
|
+
mangle: cli.mangle !== void 0 ? cli.mangle : cfg.mangle !== void 0 ? cfg.mangle : true,
|
|
7246
|
+
ignore: cli.ignore !== void 0 ? cli.ignore : cfg.ignore || [],
|
|
7247
|
+
entry: cli.entry !== void 0 ? cli.entry : cfg.entry || null
|
|
7248
|
+
};
|
|
7249
|
+
}
|
|
7250
|
+
function defineConfig(config) {
|
|
7251
|
+
return config;
|
|
7252
|
+
}
|
|
7253
|
+
module.exports = { loadConfig, mergeConfig, defineConfig };
|
|
7254
|
+
}
|
|
7255
|
+
});
|
|
7256
|
+
|
|
7200
7257
|
// index.js
|
|
7201
7258
|
var require_index = __commonJS({
|
|
7202
7259
|
"index.js"(exports, module) {
|
|
@@ -7206,6 +7263,7 @@ var require_index = __commonJS({
|
|
|
7206
7263
|
var { Lexer } = require_lexer();
|
|
7207
7264
|
var { Parser } = require_parser();
|
|
7208
7265
|
var { bundle } = require_bundler();
|
|
7266
|
+
var { loadConfig, mergeConfig, defineConfig } = require_config();
|
|
7209
7267
|
module.exports = {
|
|
7210
7268
|
transpile,
|
|
7211
7269
|
format,
|
|
@@ -7214,7 +7272,10 @@ var require_index = __commonJS({
|
|
|
7214
7272
|
STDLIB_SYMBOLS,
|
|
7215
7273
|
Lexer,
|
|
7216
7274
|
Parser,
|
|
7217
|
-
bundle
|
|
7275
|
+
bundle,
|
|
7276
|
+
loadConfig,
|
|
7277
|
+
mergeConfig,
|
|
7278
|
+
defineConfig
|
|
7218
7279
|
};
|
|
7219
7280
|
}
|
|
7220
7281
|
});
|