11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.32k stars 495 forks source link

'webc' value keeps being added to eleventyConfig's templateFormatsAdded #2642

Closed khalidabuhakmeh closed 2 years ago

khalidabuhakmeh commented 2 years ago

I noticed that the templateFormatsAdded on eleventyConfig keeps growing. I'm not sure if this is intended or a bug. An array with similar values that keeps growing feels like a memory leak.

Screenshot 2022-10-19 at 13 27 48

To reproduce, add the following line in your .eleventy.js file and then keep modifying your .eleventy.js file.

console.log(eleventyConfig.templateFormatsAdded)

Here is my config file.

const pluginWebc = require("@11ty/eleventy-plugin-webc");
const { EleventyRenderPlugin } = require("@11ty/eleventy");

module.exports = function(eleventyConfig) {

    console.log(pluginWebc);

    eleventyConfig.addPlugin(pluginWebc, {
        components: "_includes/webc/*.webc"
    });
    eleventyConfig.addPlugin(EleventyRenderPlugin);

    eleventyConfig.setServerPassthroughCopyBehavior("copy");
    eleventyConfig.setServerOptions({
        domdiff: false
    });

    eleventyConfig.addPassthroughCopy("css" );
    eleventyConfig.addPassthroughCopy("js" );

    eleventyConfig.addShortcode("possum_link", function(slug) {
        return `/possums/${slug}/`
    });

    eleventyConfig.addFilter("next", function(possums, possum) {
        const index = possums.map(e => e.slug).indexOf(possum.slug);
        return index < possums.length
            ? possums[index + 1]
            : null;
    });

    eleventyConfig.addFilter("previous", function(possums, possum) {
        const index = possums.map(e => e.slug).indexOf(possum.slug);
        return index > 0
            ? possums[index - 1]
            : null;
    });

};
zachleat commented 2 years ago

This will ship with 2.0.0-canary.17