Help test the new npm elm package!

Me, @supermario and @evancz (with the help of some more folks) are working on a new version of the elm npm package.

  • Changed: Binaries are downloaded by npm instead of custom code in the elm package. No more dependencies or deprecation warnings!
  • New: Native macOS ARM binary. No more Rosetta!
  • New: Linux ARM binary. Useful for people with such computers, and for Docker on macOS ARM!

Please try it out and let me know how it goes! We’re testing using a temporary npm package until we know everything works.

npm install @lydell/elm

Or replace "elm": "0.19.1-5" in your package.json with "@lydell/elm": "0.19.1-9" and run npm install.

I’m especially interested if you:

  • Use a package manager other than npm.
  • Use a very old Node.js or npm for some reason.
  • Use Linux ARM.
  • Use --ignore-scripts.
  • Are behind a corporate proxy or something like that and configure things like HTTPS_PROXY.
  • Use a “probably not the most common setup” in general.

See the #core-coordination channel on Slack if you want all the details.

37 Likes

I installed it on my M1 iMac. elm make src/Main.elm works great for https://mammudeck.com. Faster, though improving three seconds to one second isn’t a big deal. Main.elm has 20444 lines, 630K bytes, and a lot of dependencies.

4 Likes

Really naive question: how does this relate to / interop with Elm Tooling CLI?

2 Likes
  • This provides two new binaries for it! I’m going to update it later.

  • This makes the elm-tooling CLI less relevant. I intend to open issues for elm-format and elm-json as well later, about copying the npm approach, which would make it even less relevant.

    • Package size: I haven’t measured yet, but I expect the new elm package to be slightly smaller than elm-tooling (which is already tiny).
    • Installation speed: Will probably be basically no difference for uncached installs. Technically elm-tooling might be faster since it needs exactly 1 npm package request, while the elm package would need 1 + number of different binaries (it won’t download them all, but needs to make a metadata request for all of them). But we’re talking milliseconds here.
    • Disk space usage: With elm-tooling you get exactly one of each binary on your computer; with npm you get one per project. You can solve this more generally by using pnpm though.
    • Execution speed: elm-tooling will be slightly faster on Windows. An npm package is forced to execute the “binary” it provides with node (which in turn executes elm in our case), which adds around 100 ms of execution time. elm-tooling can instead use a .cmd file which executes much faster.
    • Security: elm-tooling verifies downloads with SHA256 hashes; npm verifies all packages (including the ones where we distribute elm binaries) with SHA512 hashes.
    • elm-test-rs: Currently has no npm package – elm-tooling is “the way” to install it. However, this new way of installing is pretty lightweight so maybe elm-test-rs will get an npm package now.
    • Ease of use: Probably easier to use the new elm npm package than elm-tooling. But maybe not if you count setting up pnpm (if you choose to use that for disk space savings).
    • Mirrors: elm-tooling is currently hardcoded to download from github.com, while there are npm mirrors you can use if npmjs.com is not available for you.
9 Likes

I’m running a Mac with an M1 Pro chip and am doing elm development inside a VS Code dev container (via Docker) running aarch64 Debian GNU/Linux 11 (bullseye). I installed the package inside the container and it worked great! Thanks!

1 Like

Fantastic news, thanks for this.

Sounds good!

As far as I’m concerned, it doesn’t work with my current setup with either elm 0.19.1-5 or @lydell/elm 0.19.1-9, so nothing new here. My setup is Gulp with Yarn 2, so I guess the gulp-elm plugin that I’m using doesn’t know about Yarn 2. (It only works if elm is absent from my package.json, and the plugin then relies on my global elm install.) Looking forward to switching to elm-watch on this project :smile:

So I tried updating globally: removed global elm with npm, installed global @lydell/elm with npm. I see no change when I build so I guess it’s working!

(In case the fix to my unrelated issue above is obvious to anyone, the error I’m getting is “SyntaxError: Invalid or unexpected token” on the beginning ELF characters. I guess that means it’s trying to read a binary as JavaScript? Sorry, that’s totally irrelevant to the post)

Yep, neither elm nor @lydell/elm work with Yarn 2/3. (It might work if you don’t use PnP or whatever – I’m not that into Yarn 2/3.)

@lydell/elm took a lot of inspiration from esbuild’s npm installer. They have some very elaborate workarounds for Yarn 2/3. Since the current elm package does not work either with Yarn 2/3 I decided to scope that out for some other time. Interesting to hear from a Yarn 2/3 user though!

(What happens is that the package replaces its JS entrypoint with the executable itself as an optimization. Yarn 2/3 does not seem to like that.)

Oh okay, so Yarn (with PnP) is the issue then, not Gulp or the gulp-elm plugin. Might consider going back to npm at some point then :confused: I would argue it’s a pretty big issue that it doesn’t work with yarn, but maybe it’s just yarn’s fault, not anticipating enough potentially breaking use cases. Also it’s not blocking since you can just run the global binary.

Thanks for the info!

Just wanted to clarify for other’s reading that Yarn 1 works fine, it’s Yarn “Berry” (v2+) that are problematic.

Is it Yarn’s fault? Well, read this issue: [Bug] SyntaxError when running a "bin" file that isn't authored in JS · Issue #882 · yarnpkg/berry · GitHub (it mentions Elm a couple of times!)

2 Likes

Wow! This is great news!!! I’m sitting behind a corporate firewall and have not been able to install elm through npm due to then elm binary not being downloaded through internal npm proxy.

I have just tested with "@lydell/elm": "0.19.1-9" and it worked great. Thanks!!! :smiley:

If the same solution could be applied to elm-format and the other elm-tools it would be awesome.

2 Likes

Just did it on my work computer, an Intel Mac, and I can confirm that it actually works pretty seamlessly to install and run the elm binary.

Thank you everyone for testing! Much appreciated.

Follow this PR to get updates about the progress of the upcoming new official elm npm package: Free the npm package from third party dependencies by lydell · Pull Request #2287 · elm/compiler · GitHub

It’ll take a while though because there is a lot to review and December can be a busy month.

7 Likes

I have used my 8 years old MacBook Air macOS Mojave for this purpose successfully.
I have first removed the official version with npm -g uninstall elm and installed globally the temporary version npm install @lydell/elm
(To be sure, only the new elm is running, elm must be deleted also from /usr/local/bin folder.)
All seems to work excellent, at least no new problems appeared so far.
Here are some little examples of my tests with elm reactor and elm-spa.



(See also here!)

Working with great with pnpm on my Ubuntu 22.10 machine. Note that I have the following lines in my .npmrc file:

shamefully-hoist=true
auto-install-peers=true