@creationix/rex 0.1.2 → 0.1.3
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 +7 -4
- package/rex-cli.js +2 -16
- package/rex-compile.js +2340 -0
- package/rex.js +2319 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creationix/rex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Compiler and parser for the Rex language",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rex",
|
|
@@ -13,14 +13,16 @@
|
|
|
13
13
|
"bin": {
|
|
14
14
|
"rex": "./rex-cli.js"
|
|
15
15
|
},
|
|
16
|
-
"main": "rex.
|
|
16
|
+
"main": "rex.js",
|
|
17
17
|
"types": "./rex.ts",
|
|
18
18
|
"exports": {
|
|
19
|
-
".": "./rex.
|
|
19
|
+
".": "./rex.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"README.md",
|
|
23
23
|
"LICENSE",
|
|
24
|
+
"rex.js",
|
|
25
|
+
"rex-compile.js",
|
|
24
26
|
"rex.ts",
|
|
25
27
|
"rex-compile.ts",
|
|
26
28
|
"rex-cli.js",
|
|
@@ -33,10 +35,11 @@
|
|
|
33
35
|
"scripts": {
|
|
34
36
|
"test": "bun test",
|
|
35
37
|
"build:grammar": "ohm generateBundles --withTypes rex.ohm && node -e \"require('node:fs').copyFileSync('rex.ohm-bundle.js','rex.ohm-bundle.cjs')\"",
|
|
38
|
+
"build:js": "bun build rex.ts --outfile rex.js --format esm --target node && bun build rex-compile.ts --outfile rex-compile.js --format esm --target node",
|
|
36
39
|
"compile": "bun run rex-compile.ts",
|
|
37
40
|
"verify:docs": "bun run verify-doc-examples.ts",
|
|
38
41
|
"pack:dry-run": "npm pack --dry-run",
|
|
39
|
-
"prepublishOnly": "bun run build:grammar && bun test && npm run pack:dry-run"
|
|
42
|
+
"prepublishOnly": "bun run build:grammar && bun test && bun run build:js && npm run pack:dry-run"
|
|
40
43
|
},
|
|
41
44
|
"publishConfig": {
|
|
42
45
|
"access": "public"
|
package/rex-cli.js
CHANGED
|
@@ -5,23 +5,9 @@ import { dirname, join } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
7
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const compileScript = join(here, "rex-compile.
|
|
8
|
+
const compileScript = join(here, "rex-compile.js");
|
|
9
9
|
const passthroughArgs = process.argv.slice(2);
|
|
10
10
|
|
|
11
|
-
if (typeof Bun !== "undefined") {
|
|
12
|
-
await import("./rex-compile.ts");
|
|
13
|
-
process.exit(0);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const [majorText, minorText] = process.versions.node.split(".");
|
|
17
|
-
const major = Number(majorText);
|
|
18
|
-
const minor = Number(minorText);
|
|
19
|
-
|
|
20
|
-
if (!Number.isFinite(major) || !Number.isFinite(minor) || major < 22 || (major === 22 && minor < 18)) {
|
|
21
|
-
console.error("rex: Node.js v22.18+ is required to run TypeScript natively, or use Bun.");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
11
|
const child = spawn(process.execPath, [compileScript, ...passthroughArgs], {
|
|
26
12
|
stdio: "inherit",
|
|
27
13
|
});
|
|
@@ -29,7 +15,7 @@ const child = spawn(process.execPath, [compileScript, ...passthroughArgs], {
|
|
|
29
15
|
child.on("error", (error) => {
|
|
30
16
|
const message = error instanceof Error ? error.message : String(error);
|
|
31
17
|
console.error("rex: failed to launch runtime.");
|
|
32
|
-
console.error("Use Node.js
|
|
18
|
+
console.error("Use Node.js or Bun.");
|
|
33
19
|
console.error(`Details: ${message}`);
|
|
34
20
|
process.exit(1);
|
|
35
21
|
});
|