nomen-lang 0.11.0 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nomen-lang",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "The CLI for the Nomen programming language.",
5
5
  "keywords": [],
6
6
  "license": "ISC",
package/src/args.ts CHANGED
@@ -174,7 +174,7 @@ export function print_help(): void {
174
174
  " --config, -c <path> Path to a config file",
175
175
  " --watch, -w Watch for file changes",
176
176
  " --filter, -f <regex> Only run test files whose path matches this regex",
177
- " --arch, -a <arch> Target architecture: aarch64 | c (default: aarch64)",
177
+ " --arch, -a <arch> Target architecture: aarch64 | c | js (default: aarch64)",
178
178
  " --platform, -p <name> Target platform: macos, ios, linux, android, windows, web",
179
179
  " --lib, -l <path> Path to System library directory (containing package.jsonc)",
180
180
  " --audit Audit the generated program for memory issues",
package/src/index.ts CHANGED
@@ -165,7 +165,7 @@ try {
165
165
  config = JSON.parse(fs.readFileSync(args.config, "utf-8"));
166
166
  }
167
167
  // Overwrite with args
168
- if (args.arch) config.arch = args.arch as "aarch64" | "c";
168
+ if (args.arch) config.arch = args.arch as "aarch64" | "c" | "js";
169
169
  if (args.platform) config.platform = args.platform;
170
170
  if (args.lib) config.lib = args.lib;
171
171
  if (args.audit) config.audit = args.audit;
@@ -382,6 +382,20 @@ function processFile(filename: string, config: Config, mode: Mode, program_args:
382
382
  // Output lives in the project's `build/` — `build/test` for *.test.nm —
383
383
  // unless an explicit --out names the linked binary.
384
384
  const buildDir = build_dir_for(resolved, filename.endsWith(".test.nm"));
385
+
386
+ // The JS backend emits a self-contained ESM module; `run` executes it with
387
+ // Node instead of compiling and linking a native binary.
388
+ if (arch === "js") {
389
+ if (!fs.existsSync(buildDir)) fs.mkdirSync(buildDir, { recursive: true });
390
+ const jsfile = path.join(buildDir, basename + ".mjs");
391
+ fs.writeFileSync(jsfile, result.code);
392
+ console.log(`Created ${jsfile} in ${(performance.now() - startTime).toFixed(2)}ms`);
393
+ if (mode === "run") {
394
+ execFileSync(process.env.NODE ?? "node", [jsfile, ...program_args], { stdio: "inherit" });
395
+ console.log(`Completed in ${(performance.now() - startTime).toFixed(2)}ms`);
396
+ }
397
+ return;
398
+ }
385
399
  if (!fs.existsSync(buildDir)) {
386
400
  fs.mkdirSync(buildDir, { recursive: true });
387
401
  }
@@ -1,5 +1,5 @@
1
1
  export default interface Config {
2
- arch?: "c" | "aarch64";
2
+ arch?: "c" | "aarch64" | "js";
3
3
  platform?: string;
4
4
  lib?: string;
5
5
  audit?: boolean;