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

@unlocal/elm-optimizations-webpack-plugin

v1.0.0

Published

webpack-elm-optimizations-plugin ================================

Downloads

1

Readme

webpack-elm-optimizations-plugin

Overview

This plugin optimizes Elm compilation output through the use of custom transformations

Right now there is a single optimization implemented, which transforms this:

var same = i === yRefs.length;
while (same && i--)
{
    same = xRefs[i] === yRefs[i];
}

Into this:

var same = i === yRefs.length;
var recheck = [];
while (same && i--)
{
    if (xRefs[i] !== yRefs[i]){
        if (typeof(xRefs[i]) === "object" && !(Array.isArray(xRefs[i])) && xRefs[i]['$'] === undefined){
            recheck.push(i);
        } else {
            same = false;
        }
    }
}
i = recheck.length;
while (same && i--){
    var check = recheck[i];
    for (var key in xRefs[check])
    {
        same = (xRefs[check][key] === yRefs[check][key]);
        if (!same) {break;}
    }
}

Usage

This is a webpack loader plugin, so you'll need an existing Webpack configuration, and you'll need webpack installed.

The plugin itself is written in TypeScript, so you'll also need to compile TypeScript before using the plugin.

So something like:

npm install # Install dependencies
tsc # Compile TypeScript

Your existing webpack configuration likely has a section that looks something like this:

{
    module: {
        rules: [
            {
                test: /\.elm$/,
                use: [
                    {
                        loader: 'elm-webpack-loader',
                        options: {}
                    }
                ]
            }
        ]
    }
}

Add the ElmOptimizationsPlugin as the first entry in order to use the plugin:

{
    module: {
        rules: [
            {
                test: /\.elm$/,
                use: [
                    {
                        loader: "@unlocal/elm-optimizations-webpack-plugin",
                        /** @type ElmOptimizationsPluginOptions */
                        options: {
                            htmlLazy: true,
                        }
                    },
                    {
                        loader: 'elm-webpack-loader',
                        options: {}
                    }
                ]
            }
        ]
    }
}

NOTE: It's very important that ElmOptimizationsPlugin plugin is listed before elm-webpack-loader, because Webpack runs loaders in reverse order of how they are listed. ElmOptimizationsPlugin only works with the output of the Elm compilation, not with Elm sourcecode itself.

Example

You can run a build of the example app in this repo with:

npm run build-dev

And you can have webpack serve the example app in this repo with:

npm run serve-dev

The webpack configuration options are located in the elmSupport function of webpack.config.js.

Publishing

You can verify that npm will receive the right files by first running the npm pack command.

To publish:

  1. First, bump the version number.
  2. Ensure TypeScript compiles successfully.
  3. Run npm run publish