{"id":16101951,"url":"https://github.com/klazuka/elm-hot","last_synced_at":"2025-04-09T13:10:03.115Z","repository":{"id":32917334,"uuid":"139368274","full_name":"klazuka/elm-hot","owner":"klazuka","description":"Hot module reloading for Elm","archived":false,"fork":false,"pushed_at":"2023-01-23T18:01:03.000Z","size":416,"stargazers_count":74,"open_issues_count":16,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T12:08:00.007Z","etag":null,"topics":["elm","hmr","hot-module-replacement","hot-reload"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klazuka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-01T22:54:54.000Z","updated_at":"2024-03-12T18:36:54.000Z","dependencies_parsed_at":"2023-02-10T05:15:14.661Z","dependency_job_id":null,"html_url":"https://github.com/klazuka/elm-hot","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klazuka%2Felm-hot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klazuka%2Felm-hot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klazuka%2Felm-hot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klazuka%2Felm-hot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klazuka","download_url":"https://codeload.github.com/klazuka/elm-hot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045245,"owners_count":21038554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elm","hmr","hot-module-replacement","hot-reload"],"created_at":"2024-10-09T18:51:47.160Z","updated_at":"2025-04-09T13:10:03.092Z","avatar_url":"https://github.com/klazuka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![elm-hot](https://github.com/klazuka/elm-hot/workflows/elm-hot/badge.svg)\n\n# elm-hot\n\nThis package provides the core infrastructure needed for doing hot code swapping in Elm. It supports Elm 0.19 only.\n\n**This low-level package is intended for authors of Elm application servers.**\n\nIf you're looking for something that's easier to use, and you're willing to use Webpack, see [elm-hot-webpack-loader](https://github.com/klazuka/elm-hot-webpack-loader), which is built using this package. Another option is Parcel which has [built-in support for Elm](https://parceljs.org/elm.html) and this package.\n\nThe goal of this package is to provide a reusable core that can be used to provide hot code swapping support in a variety of environments--not just Webpack.\n\n\n## Changelog\n\n### 1.1.6\n- more lenient search for Browser.Navigation.Key in the generated JS\n- updated dependencies\n\n### 1.1.5\n- update dependencies\n\n### 1.1.4\n- fixed a bug where HMR failed because `Browser.Navigation.Key` changed location\n- fixed a crash when the app's `Model` contains `Json.Encode.null`\n\n### 1.1.3\n- fixed a crash when using Elm debugger and elm/browser 1.0.2\n\n### 1.1.2\n- fixed a bug where HMR would not work for very small (\"toy\") Elm projects\n\n### 1.1.1\n- added support for Elm 0.19.1\n\n### 1.0.1\n- bug fixes\n\n### 1.0.0\n- improved Browser.application support (Browser.Navigation.Key can be stored anywhere in your model now) \n\n### 0.9.1\n- separated the Webpack loader out into its own package\n- exposed core API\n\n### 0.9.0\n- first release\n\n\n### Installing `elm-hot` core API\n\n```bash\n$ npm install --save elm-hot\n```\n\n---------------------------------------------\n\n### Core API\n\n\n**`function inject(str)`**\n\nInjects the hot code swapping functionality into a compiled Elm app.\n\n- takes the Javascript code emitted by the Elm compiler as an input string\n- returns a string containing the injected code ready to be `eval`-ed in the browser.   \n\n\n### Example of how the core API could be used \n\n```javascript\nconst elmHot = require('elm-hot');\nconst {compileToStringSync} = require('node-elm-compiler');\nconst injectedCode = elmHot.inject(compileToStringSync([\"src/Main.elm\"], {}));\n```\n\nIn order to provide something similar to `webpack-dev-server` with hot module reloading, an application server could be developed to do the following:\n\n- serve a modified version of the app developer's `index.html` to receive push events from the server\n- watch `.elm` files on disk for changes\n- whenever a source file changes, push an event to the client notifying it that it should fetch new code from the server\n- when the client receives the event:\n    - fetch the new code (the server will re-compile the Elm code and use `elm-hot` to inject the hot-code-swapping logic)\n    - the client deletes the old `Elm` object and calls `eval()` on the new code from the server\n    \nI have implemented something similar to this for the integration tests. See [test/server.js]() and [test/client.js]() for inspiration.\n\nThe above description is probably a bit too vague, so if you would like more details, create an issue.\n\n-------------------------------------------\n\n\n### Attribution\n\nElm hot code swapping is based on the work of Flux Xu's [elm-hot-loader](https://github.com/fluxxu/elm-hot-loader).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklazuka%2Felm-hot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklazuka%2Felm-hot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklazuka%2Felm-hot/lists"}