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

Change default `node_modules` ignores #2436

Closed zachleat closed 2 years ago

zachleat commented 2 years ago

The eleventy-base-blog build fails after you add a Netlify plugin. Here’s some build log output from the eleventy-base-blog project but would likely be the similar for any Eleventy 0.x, 1.x, or 2.x project:

0:20:59 AM: [11ty] Problem writing Eleventy templates: (more in DEBUG output)
10:20:59 AM: [11ty] 1. Having trouble rendering njk template ./.netlify/plugins/node_modules/accepts/README.md (via TemplateContentRenderError)
10:20:59 AM: [11ty] 2. "sh" is not a valid Prism.js language for eleventy-plugin-syntaxhighlight (via Error)
10:20:59 AM: [11ty]
10:20:59 AM: [11ty] Original error stack trace: Error: "sh" is not a valid Prism.js language for eleventy-plugin-syntaxhighlight
10:20:59 AM: [11ty]     at module.exports (/opt/build/repo/node_modules/@11ty/eleventy-plugin-syntaxhighlight/src/PrismLoader.js:20:11)
10:20:59 AM: [11ty]     at Object.highlight (/opt/build/repo/node_modules/@11ty/eleventy-plugin-syntaxhighlight/src/markdownSyntaxHighlightOptions.js:25:35)
10:20:59 AM: [11ty]     at Object.default_rules.fence (/opt/build/repo/node_modules/markdown-it/lib/renderer.js:53:27)
10:20:59 AM: [11ty]     at Renderer.render (/opt/build/repo/node_modules/markdown-it/lib/renderer.js:332:38)
10:20:59 AM: [11ty]     at MarkdownIt.render (/opt/build/repo/node_modules/markdown-it/lib/index.js:544:24)
10:20:59 AM: [11ty]     at /opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Markdown.js:74:38
10:20:59 AM: [11ty]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
10:20:59 AM: [11ty]     at async Template._render (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateContent.js:432:22)
10:20:59 AM: [11ty]     at async Template.getTemplateMapContent (/opt/build/repo/node_modules/@11ty/eleventy/src/Template.js:1077:19)
10:20:59 AM: [11ty]     at async TemplateMap.populateContentDataInMap (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateMap.js:461:39)
10:20:59 AM: [11ty] Copied 4 files / Wrote 0 files in 0.69 seconds (v1.0.1)

Note that it attempts to process content in .netlify/plugins/node_modules/

Workaround

Workaround is to add .netlify to either the .gitignore, .eleventyignore, or in the configuration API method: https://www.11ty.dev/docs/ignores/#configuration-api

Defaults change discussion

Taking it one step further, my personal thought is that it might be better to change the Eleventy default ignore from node_modules/** to **/node_modules/**. Or in addition to? (note the delete snippet recommendation on https://www.11ty.dev/docs/ignores/#node_modules)

Thoughts?

Reported by @samkap!

zachleat commented 2 years ago

Fixed by #2492.

Shipping with Eleventy 2.0.0-canary.15