-
-
Notifications
You must be signed in to change notification settings - Fork 495
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 dependencies declared in configuration #1312
Comments
Following up on this discussion from Discord : https://discordapp.com/channels/741017160297611315/741017160297611319/757230379202773002 The issue at hand on Discord is in a JS template, but I think it is the exact same issue mentioned here. eleventy/src/Util/DeleteRequireCache.js Lines 8 to 11 in 330191c
I could get a PR together, just checking for a green light and if such a fix is not already in the pipeline. |
@AurelienStebe Did you develop a solution or workaround for this? I'm having a few issues with changes to required JS files not triggering a refresh (or in some cases requiring that I restart the server). I'm seeing it with files required in the config, and files required in layouts. |
No, this was just a drive-by bug fix. I had the exact same issue in my own project the week before, so I knew the solution. It should really just need a few lines of code : before deleting the module itself from the require cache, just loop on its children and call the function recursively. Unfortunately, it needs to be fixed in this very file in Eleventy, I don't think you can do much from outside (apart from deleting the whole cache maybe, but that's about the same as restarting the process). This should make sure that dependencies of dependencies are re-read from disk in "live" mode, however I don't know if they are all "watched" correctly (but there is I thought work was being done on the "--watch" mode and incremental builds, so I didn't move forward at the time. |
Yeah I just hit the same problem. Any dependencies of an I tried the recursive cache deletion of children suggested above but it doesn't seem to help. I've never really played with Node's cache before so I probably messed it up 😓 The easiest workaround I've found is to just inline all my components and helpers into the layout file for now, so I don't have to |
@zachleat is this in the pipeline or worth me getting a PR together? |
Same here. Couldn't get it to work either. @oliverjam could you post your code and I'll give it a run? |
For those using js templates, one workaround is to manually require your js files and not calling shortcode with You loose access to data pages but hot reloading is working. Weird : dependencies in layout files are not reloading. |
I had a similar issue where the page would hot reload but any changes made to includes were not being made in the rendered copy (unless I restarted eleventy via the command line). I was able to resolve the issue by making sure chokidar was installed and
|
Hi, are there any solutions on this bug right now? |
This change adds a "PathNormalizer" with tests which converts all paths to be unix compatible (replace "\" with "/"). That way auto reloading dependencies of the config also works on windows. Sadly nested dependencies still always lag exactly one update behind, so if you have the following dependency graph: - .eleventy.js depends on - middle.js depends on - nested.js and you update nested, you see the following: - do update 1 -> no result - do update 2 -> see update 1 - do update 3 -> see update 2 During a short lookaround, I was unable to resolve this issue. Signed-off-by: Raphael Höser <[email protected]>
Just popping in here to say I'm running into the same issue on WSL2 with JS dependencies inside of my Editing to say that manually requiring my JS layout files in the JS templates that call them seems to have fixed the issue as far as I can tell. |
…dency-monitoring #1312 Improve situation for dependency monitoring
Shipping #2479 with 2.0.0-canary.18—would love a retest after the next canary ships! (and thank you to @Snapstromegon!) |
Closing as the PR was shipped! |
Hey @zachleat, I'm noticing this issue all over again on I have the following directory structure:
Where Updating I'm assuming #1435 is related. Edit: looks like you can get around this by declaring
|
@substrae can you test the latest on GitHub? I’m guessing #2903 is the culprit |
You betcha! I'll take a peek after work today. 🚀 |
@zachleat Hmm, installing fresh from Edit: for reference, the compiled HTML doesn't contain the change either. Edit 2: my temporary solution from above also still works here, where moving the |
@substrae: Thank you for this! 🤗 I am messing around with Preact and TypeScript for templating and couldn't figure out what was going on. This is what I have and I'm happy with it: // base.11ty.tsx
import { h, Fragment } from "preact";
import { render as r } from "preact-render-to-string";
import type { EleventyData } from "../types/eleventy";
import { Shell } from "../components";
export function render(data: EleventyData) {
const { Post } = require("./post");
const { Photo } = require("./photo");
return r(
<Shell data={data}>
{data.category === "photos" ? (
<Photo data={data} />
) : (
<Post data={data} />
)}
</Shell>
);
} And here's the // post.tsx
import { h } from "preact";
import { parse } from "preact-parser";
import { PostData } from "../types/data";
import { postDate } from "../helpers";
import { Tags } from "../components";
export const Post = ({ data }: { data: PostData }) => (
<article>
<header>
<h1>
<a href={data.url}>{data.title}</a>
</h1>
</header>
{parse(data.content)}
<footer>
<Tags tags={data.tags} />
<time>{postDate(data.date, "dd MMMM yy")}</time>
</footer>
</article>
); |
Same issue with Preact and Typescript. Have to dynamic import/ require in the renderer for it to rebuild, when the imported components change. |
same issue again |
Still having this issue as well, and unfortunately I've run into a context where I can't move the
|
hey @zachleat , first of all, thank you and your team for such amazing tool! I'd like to share, that I also experience the problem with my eleventy config not refreshing the browser with most recent changes in I have the following files structure:
then I require my dependency and register as shortcode so when any changes were made in on the other hand, when I manually save using |
@kubarenatioN can you file a new issue with a reduced test case? I attempted to reproduce with your instructions and found that editing Thanks! |
Filed via @AnandChowdhary
#701 (comment)
The text was updated successfully, but these errors were encountered: