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

rollup-plugin-wontache

v0.1.0

Published

Rollup plugin for bundling Mustache templates with the Wontache engine

Downloads

7

Readme

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

rollup-plugin-wontache

Rollup plugin for bundling Mustache templates with the Wontache engine

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 rollup.config.js:


import wontache from 'rollup-plugin-wontache';

export default {
    input: './index.js',
    plugins: [wontache()],
    // ...
};

Options


import wontache from 'rollup-plugin-wontache';

// ...
    wontache({
        include: '**/*.mustache',
        exclude: [],
        precompile: false,
        delimiters: ['{{', '}}'],
        wontache: 'mustache',
    })

include

Glob string, or array of glob stringsDefault: '**/*.mustache'

Transform only modules of which the file name matches the given pattern(s). Patterns are matched against the absolute path on disk. An empty array will include everything.

exclude

Glob string, or array of glob stringsDefault: []

Skip modules of which the file name matches the given pattern(s). Patterns are matched against the absolute path on disk. An empty array will skip nothing.

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 Rollup 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 rollup-plugin-string 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 rollup.config.js:


// somewhere in an input config
    plugins: [
        wontache({
            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 plugin outputs it by default:


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

Your override in rollup.config.js:


// somewhere in an input config
    plugins: [
        wontache({
            wontache: 'sideburns',
        }),
    ],

Alternative transformed module:


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