rip-lang 3.13.4 → 3.13.6
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/bin/rip +8 -5
- package/package.json +1 -1
- package/rip-loader.js +24 -8
package/bin/rip
CHANGED
|
@@ -136,7 +136,8 @@ async function main() {
|
|
|
136
136
|
const servePath = join(__dirname, '../scripts/serve.js');
|
|
137
137
|
const serverProcess = spawn('bun', [servePath], {
|
|
138
138
|
stdio: ['inherit', 'pipe', 'inherit'],
|
|
139
|
-
detached: false
|
|
139
|
+
detached: false,
|
|
140
|
+
env: process.env
|
|
140
141
|
});
|
|
141
142
|
|
|
142
143
|
let actualPort = null;
|
|
@@ -174,7 +175,8 @@ async function main() {
|
|
|
174
175
|
// Spawn REPL with --experimental-vm-modules flag for proper ES module support
|
|
175
176
|
const replModule = join(__dirname, '../src/repl.js');
|
|
176
177
|
const replProcess = spawn('bun', ['--experimental-vm-modules', '-e', `import('${replModule}').then(m => m.startREPL())`], {
|
|
177
|
-
stdio: 'inherit'
|
|
178
|
+
stdio: 'inherit',
|
|
179
|
+
env: process.env
|
|
178
180
|
});
|
|
179
181
|
replProcess.on('exit', (code) => process.exit(code || 0));
|
|
180
182
|
return;
|
|
@@ -216,7 +218,8 @@ async function main() {
|
|
|
216
218
|
|
|
217
219
|
if (inputFile.endsWith('.rip')) {
|
|
218
220
|
const result = spawnSync('bun', ['--preload', loaderPath, inputFile, ...scriptArgs], {
|
|
219
|
-
stdio: 'inherit'
|
|
221
|
+
stdio: 'inherit',
|
|
222
|
+
env: process.env
|
|
220
223
|
});
|
|
221
224
|
process.exit(result.status ?? 1);
|
|
222
225
|
} else {
|
|
@@ -228,7 +231,7 @@ async function main() {
|
|
|
228
231
|
let exitCode = 0;
|
|
229
232
|
try {
|
|
230
233
|
writeFileSync(tmp, result.code);
|
|
231
|
-
const r = spawnSync('bun', ['--preload', loaderPath, tmp, ...scriptArgs], { stdio: 'inherit' });
|
|
234
|
+
const r = spawnSync('bun', ['--preload', loaderPath, tmp, ...scriptArgs], { stdio: 'inherit', env: process.env });
|
|
232
235
|
exitCode = r.status ?? 1;
|
|
233
236
|
} catch (error) {
|
|
234
237
|
exitCode = error.status || 1;
|
|
@@ -253,7 +256,7 @@ async function main() {
|
|
|
253
256
|
const binScript = join(repoRoot, 'bin', inputFile);
|
|
254
257
|
|
|
255
258
|
if (existsSync(binScript)) {
|
|
256
|
-
const r = spawnSync(binScript, scriptArgs, { stdio: 'inherit' });
|
|
259
|
+
const r = spawnSync(binScript, scriptArgs, { stdio: 'inherit', env: process.env });
|
|
257
260
|
process.exit(r.status ?? 1);
|
|
258
261
|
}
|
|
259
262
|
} catch {
|
package/package.json
CHANGED
package/rip-loader.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
// Bun loader for .rip files
|
|
2
2
|
|
|
3
3
|
import { plugin } from "bun";
|
|
4
|
-
import { dirname } from "path";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
6
|
import { compileToJS } from "./src/compiler.js";
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
// Resolution paths for @rip-lang/* packages: the loader's own node_modules tree,
|
|
9
|
+
// plus the global bun install as a fallback (covers dev repo running outside workspace).
|
|
10
|
+
const _loaderModules = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
11
|
+
const _globalModules = join(process.env.HOME || '', '.bun', 'install', 'global', 'node_modules');
|
|
12
|
+
const _resolvePaths = [...new Set([_loaderModules, _globalModules])];
|
|
13
|
+
|
|
14
|
+
// Set NODE_PATH so child processes can also resolve @rip-lang/* packages.
|
|
15
|
+
for (const p of _resolvePaths) {
|
|
16
|
+
if (!process.env.NODE_PATH?.split(':').includes(p)) {
|
|
17
|
+
process.env.NODE_PATH = [p, process.env.NODE_PATH].filter(Boolean).join(':');
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
await plugin({
|
|
@@ -22,7 +27,18 @@ await plugin({
|
|
|
22
27
|
build.onLoad({ filter: /\.rip$/ }, async (args) => {
|
|
23
28
|
try {
|
|
24
29
|
const source = readFileSync(args.path, "utf-8");
|
|
25
|
-
|
|
30
|
+
let js = compileToJS(source);
|
|
31
|
+
|
|
32
|
+
// Rewrite @rip-lang/* imports to absolute paths. Bun's worker threads
|
|
33
|
+
// don't respect NODE_PATH, and onResolve doesn't fire for imports in
|
|
34
|
+
// compiled source, so we resolve them here during compilation.
|
|
35
|
+
js = js.replace(/(from\s+|import\s*\()(['"])(@rip-lang\/[^'"]+)\2/g, (match, prefix, quote, specifier) => {
|
|
36
|
+
try {
|
|
37
|
+
return `${prefix}${quote}${require.resolve(specifier, { paths: _resolvePaths })}${quote}`;
|
|
38
|
+
} catch {
|
|
39
|
+
return match;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
26
42
|
|
|
27
43
|
return {
|
|
28
44
|
contents: js,
|