11ty / eleventy

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

"reject is not defined" error: actual error hidden #2749

Closed glitchassassin closed 1 year ago

glitchassassin commented 1 year ago

Operating system

Ubuntu devcontainer

Eleventy

2.0.0-canary.29

Describe the bug

I added a rollup shortcode, but didn't have the eleventy-plugin-rollup plugin installed yet.

The resulting eleventy build threw the error "reject is not defined" at TemplateLayout.js:211:

https://github.com/11ty/eleventy/blob/master/src/TemplateLayout.js#L211

I tested changing this line to throw e; locally, which correctly reported the error "unknown block tag: rollup (via Template render error)"

Looks like this was just an oversight in this commit, which moved the promise code out of getCompiledLayoutFunctions into getCachedCompiledLayoutFunction:

https://github.com/11ty/eleventy/commit/8e2f974b9f21b480d2f201bd5e2bd24008e1e959

Reproduction steps

  1. Add an invalid shortcode, e.g. {% rollup "src/js/search.js" %} (if rollup plugin is not installed)
  2. Run the build

Expected behavior

Should report correct error

Reproduction URL

No response

Screenshots

No response

Snapstromegon commented 1 year ago

Hi @glitchassassin Good catch, I think your fix is the right way to go forward and a PR would be helpful. Do you want to create one? Otherwise I would do it.

glitchassassin commented 1 year ago

Done: https://github.com/11ty/eleventy/pull/2751

zachleat commented 1 year ago

Awesome, milestoned this to 2.0—thank you!