elm-tooling-cli icon indicating copy to clipboard operation
elm-tooling-cli copied to clipboard

Feat request: support 0-dependency node js executables

Open mpizenberg opened this issue 3 years ago • 0 comments

Currently elm-tooling-cli is awesome to install pre-built executables but cannot be used to install other elm tools such as elm-test or elm-review because they require npm + dependencies. But there is at least one tool called vercel/ncc (and maybe others) able to take an npm executable and to compile it down into a single JS file or a few files (like a main + assets + workers) with all its dependencies brought in such that you can execute the main index.js file with:

node path/to/index.js

I've mentioned this already in the past, but I'm opening an issue for real now since elm-test is about to become free of the elm-json dependency, meaning it could be added solo in a elm-tooling.json and work even if elm-json is not there.

Concretely, the testing I've done is the following:

  1. ncc build --minify lib/elm-test.js generates a dist/ directory with a few files, including a main dist/index.js, and a total size of 692Kb
  2. Prepend the shebang line #!/usr/bin/env node to the file dist/index.js and make it executable
  3. Add a link to that dist/index.js file in a PATH directory, and call it elm-test-ncc
  4. Call elm-test-ncc from anywhere I'd call elm-test

The strategy above would only work for linux and mac, but I'm confident we could make something equivalent in windows. When compressed, that dist/ directory is 203kb. The small size of the compressed archive also means that installing elm-test via elm-tooling would be super fast.

Using ncc would not be required to fit the requirements, just being 0 dependency so that a simple node call is enough to execute the program.

mpizenberg avatar Mar 29 '22 15:03 mpizenberg