Eleventy: Eleventy does rerender shortcode when modifying imported shortcodes

Created on 27 Mar 2020  路  8Comments  路  Source: 11ty/eleventy

Is your feature request related to a problem? Please describe.
When a shortcode is defined in an external files and being require into .eleventy.js, modifying the shortcode will not reload the site

Reproduce steps:

  • Clone https://github.com/dephiros/11ty-tailwind/ and checkout 11ty-require-reload
  • Do yarn && yarn serve
  • Open the browser, notice TEST and TEST REQUIRE
  • Open .eleventy.js and modify Test shortcode, notice the browser will reload with the new change
  • Open _11ty/Test.js and change some text, notice the terminal is showing reload but the browser does not reflect the change

Describe the solution you'd like
Change in code that is required by .eleventy.js should reflect in the browser

Describe alternatives you've considered
I saw the issues mentioned in https://github.com/11ty/eleventy/issues/325 but it does not fix for me even with watch target. The shortcodes is still cached and require restarting the server

enhancement

Most helpful comment

@chasemccoy, right. Even though shortcodes, filters, and so forth _can_ reside in separate modules that you pass eleventyConfig, ultimately, they are all registered via .eleventy.js. That's why those changes require the hard reload. Separate files or not, you're technically modifying the configuration either way.

All 8 comments

Also seeing this issue and spent waaayyyy too long trying to figure it out.

This is labelled as an enhancement, but I think it might be better considered a bug?

This is labelled as an enhancement, but I think it might be better considered a bug?

I was thinking that after creating the ticket too but not sure how to change it

@zachleat could you help us get this labelled as a bug? (or give some guidance on whether it is a bug or expected behavior)

I cannot speak for @zachleat, but I've come to see this as "expected" behavior. It's akin to modifying the .eleventy.js file itself, which also requires an explicit call to rebuild/serve. If I'm not mistaken, it has more to do with how BrowserSync treats configuration files than it does with Eleventy proper.

@reubenlillie Hmm... I guess it seems different to me than modifying the .eleventy.js file because that file is purely for configuration, whereas shortcodes are actually producing markup (more like a template file in my eyes). I appreciate the context though! If this is expected behavior I can certainly work around it.

@chasemccoy, right. Even though shortcodes, filters, and so forth _can_ reside in separate modules that you pass eleventyConfig, ultimately, they are all registered via .eleventy.js. That's why those changes require the hard reload. Separate files or not, you're technically modifying the configuration either way.

That makes a lot of sense. Thanks @reubenlillie!

Was this page helpful?
0 / 5 - 0 ratings