11ty / eleventy

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

Possibly incorrect output when _includes is created while the dev server is running (v2.0.0-canary.23) #2723

Closed yurivish closed 1 year ago

yurivish commented 1 year ago

Operating system

macOS Monterey 12.6.2

Eleventy

v2.0.0-canary.23

Describe the bug

Hello! I'm trying out 11ty for a new static site and noticed an odd behavior.

It doesn't reproduce on 1.0, so this might be expected at this point in the development of 2.0. I wasn't sure how close a "canary" build is to release and was excited to try out 2.0, so please feel free to close if this is known or expected.

It seems that directories created while the dev server is running are sometimes treated differently than if they were created before the dev server was started.

I noticed this as I was following along with a "Getting started" tutorial and created the _include folder while the dev server was running.

Reproduction steps

Here's a standalone reproduction on the latest canary build (v2.0.0-canary.23):

$ mkdir bug
$ cd bug
$ pnpm install --save-dev @11ty/eleventy@canary
Already up to date
Progress: resolved 211, reused 211, downloaded 0, added 0, done
Done in 4.3s
$ npx @11ty/eleventy --serve
[11ty] Wrote 0 files in 0.03 seconds (v2.0.0-canary.23)
[11ty] Watching…
[11ty] Server at http://localhost:8080/
[11ty] File added: _includes/post.md
[11ty] Writing _site/_includes/post/index.html from ./_includes/post.md (liquid)
[11ty] Wrote 1 file in 0.05 seconds (v2.0.0-canary.23)
[11ty] Watching…

In another terminal, while the dev server runs:

yurivish@Compy ~ % cd bug
$ mkdir _includes
$ echo "# Title" > _includes/post.md

At this point, the dev server will print

[11ty] File added: _includes/post.md
[11ty] Writing _site/_includes/post/index.html from ./_includes/post.md (liquid)
[11ty] Wrote 1 file in 0.05 seconds (v2.0.0-canary.23)

If I then stop the dev server, delete the output folder, then restart the dev server, it does not regenerate the _site output from before:

$ rm -rf _site
$ npx @11ty/eleventy --serve
[11ty] Wrote 0 files in 0.03 seconds (v2.0.0-canary.23)
[11ty] Watching…
[11ty] Server at http://localhost:8080/

Which I think shows that files created while the dev server is active are not always treated the same as if they already existed.

Expected behavior

The same output should be generated regardless of whether or not the dev server happens to be running as the site is being edited.

✏️ Edit: I also noticed that in another simple set up with a Markdown file and HTML template, using --serve or --watch would update the output when the Markdown file changed but not when the HTML template changed. The update would happen, but changes from the new template would not be applied:

Edit 2: The incremental docs do say "Layouts Coming soon in v2.0.0-canary.21. When you change a layout file, any templates using that layout file are rebuilt." So it does sound like the behavior I'm describing is not intended.

[11ty] File changed: _includes/index.html
[11ty] Writing _site/first-post/index.html from ./first-post.md (liquid)

I also tried this in 1.0 where the same workflow works correctly, so it might be a regression in the current canary version.

Reproduction URL

No response

Screenshots

No response

zachleat commented 1 year ago

Ah, I agree! And did reproduce this—moving to bug status

zachleat commented 1 year ago

Definitely a regression, this will ship with 2.0.0-canary.28

yurivish commented 1 year ago

Thank you!

zachleat commented 1 year ago

v2.0.0-canary.28 is out! Thank you!