11ty / eleventy-upgrade-help

Helper plugin when upgrading your Eleventy project to a new major version.
66 stars 3 forks source link

TypeError: Cannot read properties of undefined (reading 'tagName') #5

Closed linusg closed 1 year ago

linusg commented 1 year ago

I'm getting a runtime error when adding the plugin to my eleventy config:

[11ty] Eleventy CLI Fatal Error: (more in DEBUG output)
[11ty] 1. Error processing a plugin (via EleventyPluginError)
[11ty] 2. Cannot read properties of undefined (reading 'tagName') (via TypeError)
[11ty] 
[11ty] Original error stack trace: TypeError: Cannot read properties of undefined (reading 'tagName')
[11ty]     at module.exports (/path/to/project/node_modules/@11ty/eleventy-upgrade-help/src/render-template-no-arg.js:18:44)
[11ty]     at UserConfig._executePlugin (/path/to/project/node_modules/@11ty/eleventy/src/UserConfig.js:388:7)
[11ty]     at UserConfig.addPlugin (/path/to/project/node_modules/@11ty/eleventy/src/UserConfig.js:361:12)
[11ty]     at module.exports (/path/to/project/node_modules/@11ty/eleventy-upgrade-help/.eleventy.js:26:18)
[11ty]     at UserConfig._executePlugin (/path/to/project/node_modules/@11ty/eleventy/src/UserConfig.js:388:7)
[11ty]     at TemplateConfig.processPlugins (/path/to/project/node_modules/@11ty/eleventy/src/TemplateConfig.js:254:25)
[11ty]     at TemplateConfig.mergeConfig (/path/to/project/node_modules/@11ty/eleventy/src/TemplateConfig.js:367:10)
[11ty]     at TemplateConfig.getConfig (/path/to/project/node_modules/@11ty/eleventy/src/TemplateConfig.js:159:26)
[11ty]     at new Eleventy (/path/to/project/node_modules/@11ty/eleventy/src/Eleventy.js:99:39)
[11ty]     at Object.<anonymous> (/path/to/project/node_modules/@11ty/eleventy/cmd.js:60:16)
error Command failed with exit code 1.

That line is:

https://github.com/11ty/eleventy-upgrade-help/blob/4ddc7f19df2ac710926387344d634c94becf11c1/src/render-template-no-arg.js#L17

Adding a console.log(renderishPlugins) before the failing line reveals:

[
  {
    plugin: [Function: EleventyPlugin] {
      File: [AsyncFunction: compileFile],
      String: [AsyncFunction: compile],
      RenderManager: [class RenderManager]
    },
    options: undefined,
    pluginNamespace: ''
  }
]

Installed dependencies:

"@11ty/eleventy": "^2.0.0-beta.1",
"@11ty/eleventy-img": "^2.0.1",
"@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-syntaxhighlight": "^4.2.0",
"@11ty/eleventy-upgrade-help": "^2.0.3",
"clean-css": "^5.3.1",
"eleventy-plugin-seo": "^0.5.2",
"html-minifier": "^4.0.0",
"markdown-it-anchor": "^8.6.6",
"markdown-it-attrs": "^4.1.6",
"markdown-it-link-attributes": "^4.0.1",

Shortened eleventy config:

module.exports = function (eleventyConfig) {
  eleventyConfig.addPassthroughCopy("...");

  eleventyConfig.addPlugin(pluginRSS);
  eleventyConfig.addPlugin(pluginSEO, {
    ...
  });
  eleventyConfig.addPlugin(pluginSyntaxHighlight);
  eleventyConfig.addPlugin(EleventyRenderPlugin);
  eleventyConfig.addPlugin(UpgradeHelper);

  eleventyConfig.setLibrary(
    "md",
    markdownIt({
      html: true,
      linkify: true,
    })
      .use(markdownItAnchor, {
        permalink: markdownItAnchor.permalink.headerLink(),
      })
      .use(markdownItAttrs)
      .use(markdownItLinkAttributes, {
        matcher(href, config) {
          return /^https?:/.test(href);
        },
        attrs: {
          target: "_blank",
          rel: "noreferrer",
        },
      })
  );

  eleventyConfig.addCollection("...", ...);

  eleventyConfig.addTransform("minify", ...);

  return {
    markdownTemplateEngine: "njk",
    dir: {
      input: "site",
      output: "dist",
    },
  };
};
zachleat commented 1 year ago

Lookin’

zachleat commented 1 year ago

Shipped with v2.0.4 (of this plugin)—thank you!