Giter Site home page Giter Site logo

Bun Repl about sniprun HOT 4 CLOSED

johnpgr avatar johnpgr commented on May 28, 2024
Bun Repl

from sniprun.

Comments (4)

michaelb avatar michaelb commented on May 28, 2024

I guess that you also want REPL capabilities within sniprun, as," it's possible to run a snippet declaring one variable, and then another one using it" ?

If so, I can implement that, but I'll need some time and luck

If you don't require REPL capabilities, it should be possible to get it running by yourself with the generic interpreter

from sniprun.

johnpgr avatar johnpgr commented on May 28, 2024

Well, ofc REPL capability would be nice, but in the mean time, I tried to use the generic interpreter, but the Typescript_original runs instead.

my config:

config = function()
            require("sniprun").setup({
                interpreter_options = {
                    Generic = {
                        Bun = {
                            supported_filetypes = { "typescript" },
                            extension = ".ts",
                            interpreter = "bun repl",
                            compiler = "",
                        }
                    }
                },
                selected_interpreters = { 'Generic' },
            })
        end,

image

from sniprun.

michaelb avatar michaelb commented on May 28, 2024

There is indeed an error in my current code driving behavior of sniprun when the Generic interpreter is used on a language that already has support. Something not too complex, but since you'll wait anyway I can make a proper TS/JS Bun intepreter... and maybe REPL-capable

from sniprun.

michaelb avatar michaelb commented on May 28, 2024

So..

There is a fix for for the Generic interpreter issue, which should allow you to run the Generic interpreter with this config:

        selected_interpreters = { 'Generic' },
        interpreter_options = {
            Generic = {
                error_truncate="long",
                Bun = {
                    supported_filetypes = { "typescript", "javascript" },
                    extension = ".ts",
                    interpreter = "bun run",
                    compiler = "",
                }
            }
        },

I also made a "full-fledged" bun-based js/ts interpreter, but it doesn't bring much more than the generic config, except for .... a repl mode!

However, bun repl itself is ..... very very janky about its stdin/stdout, most notably, the order is sometimes borked.
(simplified example with an intentionnal error 'le b=1':

echo "let a=1;console.log('start');a;le b=1;console.log('end')" | bun repl
.... blablah
> console.log('start')
> le b=1
× Expected ';', '}' or <eof>
   ╭─[$bun$repl.ts:1:1]
 1 │ le b=1
   · ─┬ ─
   ·  ╰── This is the expression part of an expression statement
   ╰────
> a
> console.log('end')
start
end
1

So I expect low reliability on complex prompts

You can try these changes on the dev branch (you'll need rust and sh ./install.sh 1 to compile locally sniprun), or wait for the 1.3.9 release that will probably happen next week

from sniprun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.