Minimum Elm Component with Percel and WebComponents
Koutaro Chikuba
Posted on December 17, 2018
yarn add parcel-bundle node-elm-compiler -D
directories
elements/
foo.js
Foo.elm
run.js
index.html # import run.js
package.json
Write elm-foo component
-- elements/Foo.elm
import Html exposing (div, text)
main = div [] [text "foo"]
// elements/foo.js
import { Elm } from "./Foo.elm";
customElements.define(
"elm-foo",
class extends HTMLElement {
connectedCallback() {
Elm.Main.init({ node: this });
}
}
);
Run
Mount this elm-foo element.
// run.js
import "./elements/foo";
document.body.innerHTML = '<elm-foo></elm-foo>'
💖 💪 🙅 🚩
Koutaro Chikuba
Posted on December 17, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
nlp Understanding the Evolution of Word Representation: Static vs. Dynamic Embeddings
November 28, 2024