nksaraf / vinxi

The Full Stack JavaScript SDK

Home Page:https://vinxi.vercel.app

Repository from Github https://github.comnksaraf/vinxiRepository from Github https://github.comnksaraf/vinxi

Vinxi's build command tries to run node.EXE even when using Deno

Ciantic opened this issue · comments

I have example repo here:

https://github.com/Ciantic/deno-solid-test/

Some reason when running it through deno it still tries to run node.exe instances.

Notice the telltale warning:

(Use node.EXE --trace-warnings ... to show where the warning was created)

In following call:

$ deno run -A build 

⚙  Building your app...
vinxi v0.4.3
(node:33840) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node.EXE --trace-warnings ...` to show where the warning was created)
ReferenceError: Deno is not defined
    at file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/@jsr+std__fs@0.221.0/node_modules/@jsr/std__fs/ensure_symlink.js:7:19
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadFile (file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/vinxi@0.4.3/node_modules/vinxi/lib/load-app.js:83:25)
    at async loadApp (file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/vinxi@0.4.3/node_modules/vinxi/lib/load-app.js:137:19)
    at async Object.run (file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/vinxi@0.4.3/node_modules/vinxi/bin/cli.mjs:229:17)
    at async runCommand (file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/citty@0.1.6/node_modules/citty/dist/index.mjs:316:16)
    at async runCommand (file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/citty@0.1.6/node_modules/citty/dist/index.mjs:307:11)
    at async runMain (file:///C:/Source/JavaScript/solid-start-test/deno-solid-test/node_modules/.deno/citty@0.1.6/node_modules/citty/dist/index.mjs:445:7)

(With Bun vinxi works only with --bun that does ugly hack of symlinking node.exe as bun.exe)

Nitro does have deno support with preset deno_server:

https://github.com/unjs/nitro/blob/v2/docs/2.deploy/10.runtimes/deno.md

But Vinxi is not aware of that:

process.env.SERVER_PRESET ??=
args.preset ??
process.env.TARGET ??
process.env.PRESET ??
process.env.SERVER_PRESET ??
process.env.SERVER_TARGET ??
process.env.NITRO_PRESET ??
process.env.NITRO_TARGET ??
"node-server";
switch (process.env.SERVER_PRESET) {
case "node-server":
await import(
pathToFileURL(process.cwd() + "/.output/server/index.mjs").href
);
break;
case "bun":
const { $ } = await import("../runtime/sh.js");
await $`bun run .output/server/index.mjs`;
break;
default:
log(
`Couldn't run an app built with the ${process.env.SERVER_PRESET} preset locally. Deploy the app to a provider that supports it.`,
);
}