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

page does not refresh when _components/XXX.tsx is modified #590

Open
iacore opened this issue Mar 26, 2024 · 8 comments
Open

page does not refresh when _components/XXX.tsx is modified #590

iacore opened this issue Mar 26, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@iacore
Copy link
Contributor

iacore commented Mar 26, 2024

Version

v2.0.1

Platform

Linux

What steps will reproduce the bug?

  • Enable TSX
  • have a .tsx page reference a component in _components/
  • load the .tsx page in browser
  • edit the component

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

the page should refresh to new content

What do you see instead?

The page is stuck. Manual refresh doesn't work. I have to restart lume to see the new page.

Additional information

No response

@iacore iacore added the bug Something isn't working label Mar 26, 2024
@oscarotero
Copy link
Member

Hi.
Can I see the code of how you're using the component?

In Lume, components are loaded automatically in the comp variable. Example:

export default function ({ comp}: Lume.Data ) {
  return <p><comp.Button /></p>
}

@scarf005
Copy link
Contributor

scarf005 commented Apr 2, 2024

this can be workaround using watch or hmr.

  1. run echo 'import "lume/cli.ts"' > _main.ts on terminal.
  2. change tasks in deno.json to following:
 	"tasks": {
-		"lume": "echo \"import 'lume/cli.ts'\" | deno run -A -",
-		"build": "deno task lume",
-		"serve": "deno task lume -s"
+		"build": "deno run -A _main.ts",
+		"serve": "deno run -A --unstable-hmr _main.ts -s"
 	},

it should work like following:

$ deno task serve
Task serve deno run -A --unstable-hmr _main.ts -s
HMR Process started.
Loading config file file:///home/scarf/repo/etc/esbuild-issue/_config.ts
🔥 /main.js <- /main.tsx
🍾 Site built into ./_site
  1 files generated in 0.01 seconds
  Server started at:
  http://localhost:3000/ (local)
  http://192.168.1.90:3000/ (network)
Changes detected:
- /_config.ts
HMR Replaced changed module file:///home/scarf/repo/etc/esbuild-issue/_config.ts

@iacore
Copy link
Contributor Author

iacore commented Apr 11, 2024

In Lume, components are loaded automatically in the comp variable. Example:

I use import Component from '../Component.tsx'.

I use a lot of functions between files too.

import { generate } from "./all.atom.xml.tsx"

@oscarotero
Copy link
Member

The problem is Deno caches the imported modules and there's no way to invalidate the cache to refresh the modules.

In Lume, this limitation is solved loading the file with a hash (for example, import foo from "./foo.ts#hash123"). Components are loaded in this way so if a file changes, Lume reload the file with a different hash.

Deno added recently a way to do hot module replacement (https://deno.com/blog/v1.38#hot-module-replacement) but it's still unstable and doesn't work well with Lume.

@iacore
Copy link
Contributor Author

iacore commented Apr 13, 2024

Related: denoland/deno#8327

@iacore
Copy link
Contributor Author

iacore commented Jun 8, 2024

this can be workaround using watch or hmr.

1. run `echo 'import "lume/cli.ts"' > _main.ts` on terminal.

2. change tasks in `deno.json` to following:

I totally missed this... now my site is mostly stable I don't have a easy way to test this. Hopefully someone else will find this useful.

@soundstep
Copy link

soundstep commented Aug 27, 2024

This does not work for tsx files. It worked with Lume 1, and upgrading to Lume 2 seems to have broken this.

The terminal output this:

Changes detected:
- /scripts/feature-flags.page.tsx
Changes sent to the browser

But the brother never reloads that page.

Even though I can see:

Screenshot 2024-08-27 at 10 31 01

Command run:

deno task lume -sw

@scarf005
Copy link
Contributor

scarf005 commented Dec 1, 2024

case "js":
// Reload the entire page for JavaScript changes
location.reload();
return;

looks like it's because live reload client doesn't handle extension other than js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants