Testing changes to elm-browser locally

Hi. I’ve found a bug in elm-browser (opened an issue here https://github.com/elm/compiler/issues/1848 and a PR here https://github.com/elm/browser/pull/54#issuecomment-440016912 ) and would like to test it locally to get to the root cause.

How would I do that currently?

Thanks.

One way is forking the compiler to allow building packages with native code, but that is fairly involved.

For packages with native code that have already been published there is a workaround:

  1. Delete the existing .dat files for the package: rm ~/.elm/0.19.0/package/elm/browser/1.0.1/*.dat
  2. Make whatever code changes you want in ~/.elm/0.19.0/package/elm/browser/1.0.1/
  3. In another project that is importing elm/browser delete the elm-stuff folder.
  4. Rebuild

Each time you need to update the code for elm/browser delete the *.dat files and your elm-stuff folder and rebuild and you will see the changes.

1 Like

Nice! Will definitely try this one out. I’ve found isKernel function which hardcodes the author to be elm and changed that to just return True, that’s easy. But then the problem comes from not being able to use a package that’s local to your filesystem (from an app) instead of package infrastructure, that was a major obstacle for me.

There’s also https://github.com/Skinney/elm-git-install which let’s you install a package from any git url

1 Like

It will let you install from git, but you can’t compile kernel code with it, it still has to be from the elm or elm-explorations github organization (https://github.com/elm/compiler/blob/a6568a63f3ffc4defdb608d180b23a0113a89342/compiler/src/Elm/Package.hs#L74)

Doesn’t it only work with Elm <0.19?

This is trivial to patch (in fact this is what I did). How do I install from git? Is there an example?

It looks like elm-git-install supports 0.19 exclusively, if you have a forked version of the compiler it looks like you can add an elm-git.json file that points to the code (https://github.com/Skinney/elm-git-install#how-to-use).

So far the way I’ve done it locally is symlinking my fork into ~/.elm/0.19.0/package/elm/browser/1.0.1/ and then using the same steps from above with deleting the *.dat files and stuff.

@hpate thank you very much! Your instructions with the .dat file worked like a charm. This was especially useful in light of me not being able to make an SSCCE because apparently the bug is only happening when I have tons of my current app’s JS code on top of Elm’s

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.