observablehq / framework

A static site generator for data apps, dashboards, reports, and more. Observable Framework combines JavaScript on the front-end for interactive graphics with any language on the back-end for data analysis.
https://observablehq.com/framework/
ISC License
2.47k stars 118 forks source link

Watch data loader creation and file renaming #124

Open Fil opened 11 months ago

Fil commented 11 months ago

If you add a new data loader, it should show up live in the preview server. Same if you rename a data loader from data.csv.sh to data.csv.js.

mbostock commented 11 months ago

I think this would require a recursive watch on the source root?

mbostock commented 11 months ago

To be more specific, I think the OP is describing this error case:

  1. You try to load a file that doesn’t exist yet (e.g., foo.csv)
  2. You later add a data loader for that file (e.g., foo.csv.js)

Since neither foo.csv nor foo.csv.js existed at the time the file was referenced, we’re not able to watch the corresponding file. And since we don’t watch the directory, we won’t notice when you subsequently add a foo.csv.js. However, the inverse scenario works fine, when you add foo.csv.js first, and then load foo.csv. And the workaround here is pretty simple — you just reload the page. But it would be nice to fix, and I think we should consider this a bug in file watching/hot module reloading.