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

wontache-loader

v0.1.0

Published

WebPack loader for bundling Mustache templates with the Wontache engine

Downloads

2

Readme

latest version on npm author: Julian Gonggrijp license text code hosted on GitLab changelog issue tracker on GitLab pipeline status

wontache-loader

Webpack loader for bundling Mustache templates with the Wontache engine

Supports webpack versions 4 and 5.

Quickstart

Your template (hello.mustache):


Hello, {{name}}!

Your code, which uses the template (index.js):


import hello from './hello.mustache';
console.log(hello({name: 'World'}));

Your webpack.config.js:


module.exports = {
    module: {
        rules: [
            {test: /\.mustache$/, use: 'wontache-loader'}
        ]
    }
};

Options


                use: [{
                    loader: 'wontache-loader',
                    options: {
                        type: 'ESM',
                        precompile: false,
                        delimiters: ['{{', '}}'],
                        wontache: 'mustache',
                    }
                }]

type

String with module typeDefault: 'ESM'

Which type of module to output. Valid values are 'ESM', 'AMD' and 'CommonJS'.

precompile

BooleanDefault: false

This option only controls an optimization. The transformed module will always export a compiled, ready-to-run template function, regardless of whether you pass true or false.

If false, the compilation happens during initial loading of the transformed module. If true, the compilation already happens while webpack is performing the transform, so the transformed module does not need to perform this work anymore.

The optimization is off by default, because it also has a cost: the precompiled version of a template is always larger than the original template text. Leave it off to keep your bundle as small as possible. Try switching it on when you find that there is too much delay during initial loading of the bundle. If you are publishing a library that includes bundled templates, consider giving your users a choice between bundles with and without precompilation.

If you want the transformed module to export the template as a string, instead of as an already compiled function, use raw-loader instead.

delimiters

Array of exactly two nonempty stringsDefault: ['{{', '}}']

Override this to change the delimiters with which your templates will be parsed initially, until encountering Set Delimiter tags.

Your template with alternative delimiters:


Hello, [name]!

Your override in webpack.config.js:


                use: [{
                    loader: 'wontache-loader',
                    options: {
                        delimiters: ['[', ']']
                    }
                }]

wontache

String with valid JavaScript variable nameDefault: 'mustache'

The transformed module imports the Mustache engine from Wontache. The wontache option lets you override the name by which it is imported.

Transformed module, as the loader outputs it by default:


import mustache from 'wontache';
export default mustache(...);

Your override in webpack.config.js:


                use: [{
                    loader: 'wontache-loader',
                    options: {
                        wontache: 'sideburns',
                    }
                }]

Alternative transformed module:


import sideburns from 'wontache';
export default sideburns(...);