Giter Club home page Giter Club logo

Comments (10)

jasikpark avatar jasikpark commented on May 14, 2024 1

https://github.com/evanw/esbuild probably has the most robust "install the right native dep or use wasm" approach - maybe that's a method to copy

from ezno.

kaleidawave avatar kaleidawave commented on May 14, 2024 1

haha yeah will probably make public the same time as the checker. once I have a got a few things in place (like this issue) and then find the time to clear up my current checker code then will make that public.

from ezno.

NoriSte avatar NoriSte commented on May 14, 2024

The only problem is that these binaries are platform specific. Currently not sure how to communicate the platform the binary is built for to NPM, so that npx and npm install only install and run the binary for the user's platform.

I skimmed through the Cypress package (that have platform-specific binaries) for 5 mins but I didn't found what's their approach 🤔

from ezno.

kaleidawave avatar kaleidawave commented on May 14, 2024

Yes I have seen a bunch of packages doing it but not sure how they do it. Looking into it there doesn't seem to be a supported way by NPM 😢

One way I think is to download all the binaries and then have a script that calls something like exec(`/binary-${platform}`). But it seems a bit wasteful to download all the binaries?

Maybe you could download the binaries afterwards in a script, not sure?

from ezno.

NoriSte avatar NoriSte commented on May 14, 2024

Maybe you could download the binaries afterwards in a script, not sure?

Uhm you're right, I just realized that installing Cypress (the npm dependency, I mean) itself is quick but when you launch it, it installs more things and takes longer...

from ezno.

kaleidawave avatar kaleidawave commented on May 14, 2024

Hmm looking at the "bin" field docs it seems NPM is missing something like:

{
  "bin": {
    "myapp:platform=windows": "./cli-windows.exe",
    "myapp:platform=unix": "./cli-unix.exe",
  }
}

Would be really nice if something like that was added. It would be the most optimal in terms usability, download and minimal overhead when calling.

Some other options I can currently think of:

  1. Package per platform, with a single specific bin field. Use with npm install ezno-windows, not great :/
  2. Use the #4 (when it is out). The single WASM version should be work on any platform. Not sure whether could use the CLI setup and error reporting inside wasm (pass flags through), don't want to rewrite and maintain the CLI logic in JS.
  3. Some script that downloads a specific binary to a location on first run (which I think is what you have found that Cypress does). May be good if not too difficult and is reliable.

maybe some other methods?

from ezno.

NoriSte avatar NoriSte commented on May 14, 2024

3. Some script that downloads a specific binary to a location on first run (which I think is what you have found that Cypress does). May be good if not too difficult and is reliable.

Especially since it's idempotent and quite versatile (for instance: allows working locally with a Windows machine and running in CI in a Linux one seamlessy)

2. Use the #4 (when it is out). The single WASM version should be work on any platform. Not sure whether could use the CLI setup and error reporting inside wasm (pass flags through), don't want to rewrite and maintain the CLI logic in JS.

I agree it's not worth and too hard to maintain

from ezno.

kaleidawave avatar kaleidawave commented on May 14, 2024

WASM looks the best way to go. Just played around and managed to get argh (the cli argument parsing framework ezno-cli current uses) to work in WASM. Requires injecting a file to pass over arguments but that should be fine.

#[wasm_bindgen(raw_module = "./get_args")]
extern {
    #[wasm_bindgen]
    fn get_args() -> String;
}

#[wasm_bindgen(start)]
fn main() {
    let get_args = get_args();
    let arguments = get_args.split('\0').collect::<Vec<_>>();

    match FromArgs::from_args(&["ezno-cli"], &arguments) {
        Ok(TopLevel { nested }) => {
            todo!()
        }
        Err(err) => {
            log(&err.output);
        }
    } 
}

Can work on this at the same time as #4

from ezno.

jasikpark avatar jasikpark commented on May 14, 2024

ezno-lsp when 👀

from ezno.

kaleidawave avatar kaleidawave commented on May 14, 2024

This is now implemented as well as automated deploys. Package @ https://www.npmjs.com/package/ezno

It uses the WASM version (option 2) which seems the simplest and least effort. Maybe at some point could have an additional --native flag and review option 3.

from ezno.

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.