Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with watching JS layouts and dependencies #3602

Open
nathonius opened this issue Dec 25, 2024 · 1 comment
Open

Issues with watching JS layouts and dependencies #3602

nathonius opened this issue Dec 25, 2024 · 1 comment

Comments

@nathonius
Copy link

nathonius commented Dec 25, 2024

Operating system

Windows 11

Eleventy

3.0.0

Describe the bug

Sort of re-opening #1312 after Zach asked for a minimal repro. I'll summarize the issue here; when using a javascript layout file, eleventy rebuilds when the layout file changes, but its output does not - the content of the html in the output directory remains the same.

This may also apply to javascript content, but I'm not using those so I haven't run into the issue. More context on my specific usecase is in the discord: https://discord.com/channels/741017160297611315/1321267999189110849

I realize this may actually be an issue with eleventy-dev-server, but figured I'd start here.

My current workaround is as follows, which is painfully slow (at least until #3335):

    "serve": "concurrently \"npm run watch\" \"npm run sync\"",
    "watch": "tsx watch ./node_modules/@11ty/eleventy/cmd.cjs --config=.eleventy.ts",
    "sync": "browser-sync start --server --ss public --files \"./public/**/*.html\"",

Reproduction steps

  • use a javascript layout file
    • In my repro, I'm using preact
  • Serve
  • See the correct output from the content and layout file
  • Make a change to the layout file
    • See that a change was detected in the file
    • See that eleventy rebuilds
  • The content served to the browser does not change

Expected behavior

  • The rebuild should not reuse the previous layout

Reproduction URL

https://github.com/nathonius/11ty-dev-server-repro

Just serve and make a change to the layout file.

Screenshots

No response

@nathonius
Copy link
Author

nathonius commented Dec 30, 2024

As an addendum, I do believe this is an issue with eleventy itself and not the dev server as switching back to browsersync produces the same result.

Further, (part of) the issue may reside here:

// TODO does this need to work with aliasing? what other JS extensions will have deps?
let commonJsFiles = inputFiles.filter(
(file) => (!isProjectUsingEsm && file.endsWith(".js")) || file.endsWith(".cjs"),
);

let esmFiles = inputFiles.filter(
(file) => (isProjectUsingEsm && file.endsWith(".js")) || file.endsWith(".mjs"),
);

It seems like we're filtering based on file extension; in my case at no point are these .js or .mjs files, they are .ts or .tsx. However, I do not believe this is the core problem - as compiling everything to .js files still results in the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant