npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-elm-watch

v1.3.5

Published

Use Vite and Elm with reliable HMR and full-color error messages

Downloads

1,420

Readme

vite-plugin-elm-watch

🚨 Warning: This plugin is still experimental, and doesn't quite work as intended. Publishing here to share progress and work through minor bugs!

Use Vite and Elm with reliable HMR and full-color error messages!

Installation

npm install -D vite-plugin-elm-watch

Usage

// vite.config.js
import { defineConfig } from 'vite'
import elm from 'vite-plugin-elm-watch'

export default defineConfig({
  plugins: [elm()]
})
// In src/main.js
import Main from './src/Main.elm'

let app = Main.init()

Features

  • Import *.elm files directly from JavaScript or TypeScript
  • Reliable HMR powered by elm-watch
  • Full-color, friendly compiler messages in the browser
  • Jump to problem from your browser in one click
  • JS minification step is included
  • React output mode for easy interop with existing components

Screenshots

Vite + Elm working

Vite + Elm working

Vite + Elm working

Options

mode

When using the official Elm CLI, you have access to flags that can add Elm's time-traveling debugger, or optimize your code for production.

This plugin also adds a few additional options for minifying compiled code for production and provides nice defaults in development.

  'auto'     // Uses "debug" in development and "minify" in production
| 'standard' // Doesn't add any Elm compiler flags
| 'debug'    // Adds the `--debug` flag
| 'optimize' // Adds the `--optimize` flag
| 'minify'   // Adds the `--optimize` flag and minifies the JS output

output

  'default'  // Exports standard object with "init" function
| 'react'    // Exports a React component that can be dropped into an existing app

This option allows you to specify what your imported Elm code will return. For React apps, we recommend using the 'react' output so you can easily swap .jsx/.tsx files with .elm and things will just work ™️.

Warning: Still working through HMR bugs before this is production ready!

isBodyPatchEnabled

isBodyPatchEnabled : boolean

In production, you might encounter issues caused by third party JS that modify the <body> element. This only is a problem for folks using Browser.application, which expects control over the entire <body> element.

By enabling isBodyPatchEnabled: true, you'll be able to specify a custom root node. This uses Elm's standard node field when initializing the app:

// src/main.js
import Main from './src/Main.elm'

let app = Main.init({
  node: document.getElementById('elm_root')
})

Note: This will only work if the element has an id attribute.

A known issue is that Elm will clear out attributes for this root element, so id="elm_root" won't be visible after Elm loads.

Known issues

  1. When in a React app, swapping a ".elm" component with a ".tsx" will causes issues with unmounting.
    • React calls removeChild internally on the initial DOM node, before our component can run app.unmount(). This leads to a runtime exception!