Comments (12)
That's great to hear! This is a really cool idea, too. As far as only updating specific posts, that would probably need some tweaking in the architecture. But it could be done. Basically, it would involve a few things:
- Keeping the dist folder around in your project
- Not cleaning the dist folder on build
- A special
update
CLI command or option in the config - A special
getRoutesUpdate
callback or something similar to fetch the data for the updated posts and return which routes should be updated.
Some other thoughts:
- The bundle would probably need to be generated again
from react-static.
@mattyfresh something obvious that comes to mind is watchmen: https://facebook.github.io/watchman/
Concepts
You can query a root for file changes since you last checked, or the current state of the tree
You can subscribe to file changes that occur in a root
from react-static.
@D1no Good call! Already digging through their source code. I have a super basic implementation that I threw together that just forks the react-static build
command, does not rm the DIST
directory, and filters for new posts via a JSON file of writtenPaths
that were built on the last build.
const routesToUpdate = config.routes.filter(route => (writtenPaths.indexOf(route.path) === -1))
Then you can just pass that to writeRouteComponentsToFile
which is convenient. This would not work for updating an existing post though, and I'm sure we would want more control like build by certain post-type or some other criterion.
Thanks for the suggestions! This seems like it should be doable.
from react-static.
That works for file based systems. How would you handle a dynamic site querying a CMS like Contentful? It'd be pretty trivial to filter on their api for posts modified since lastBuildDate
, which would then get pushed through getRouteProps
.
from react-static.
Thinking on this further, and thinking along the lines of what Gatsby does building a sort of dependency tree where I can know when related entities change, and therefore rebuild the affected pages. IE you have an Musician
page that renders a list of Songs
, if the structure of Songs
changes, everything that depends on that entity ought to be rebuilt as well.
My coworker found this fairly well articulated here: https://stackoverflow.com/questions/17607287/changes-based-regeneration-by-static-site-generators
This is from 2013! Still seems like a custom solution needs to be created.
from react-static.
from react-static.
Has anyone thought any more on this subject?
from react-static.
I know this isn't necessarily a delta build strategy, but you should look at #96, which I just merged. :)
from react-static.
Awesome! Been side tracked getting TypeScript to play nice in our proposed front end ecosystem (TS, React, React Static, Apollo Client). Took a quick look at the PR and I am excited to take another crack at rendering a large site for our POC.
I did manage to wire up the TypeScript build, but I am still using react-static v2.0.0
. Hooking into webpack was pretty straightforward as mentioned here #8, later this week I could help create an example project if that helps!
Side Note: I obviously haven't ran the updated script yet, but when I was writing my own basic implementation I got bit by using .forEach
(which has to throw a new function on the stack for each iteration). Using a for
or for..of
loop (if it doesn't make things completely confusing) where possible sped up my script considerably.
For reference:
https://coderwall.com/p/kvzbpa/don-t-use-array-foreach-use-for-instead
from react-static.
from react-static.
Definitely interested in this issue. Pushing the onus onto the user to determine which routes need updating feels like a good idea. I made a fork that very naively implements a new update
command that basically does the same thing as build
, but calls getRoutesUpdate
instead of getRoutes
and doesn't delete the dist
folder. I haven't had a chance to really test it out, but it seems like it could work, at least for certain use cases.
One thing I was wondering with this approach is would there need to be some way to pass arguments to the update
command that the user can use to determine which routes need updating (e.g. a timestamp)?
from react-static.
After a lot of discussion on this topic both internally and externally, I think we've decided to take the direction of the library towards "fast immutable" builds. Delta builds introduce a few things that are difficult to prepare for:
- Data dependencies and relationships. Given RS's data agnostic approach, this would be almost impossible.
- Server or git related caching mechanisms. This is not RS's arena or responsibility.
We feel our efforts will be much better invested into producing faster builds for the library.
from react-static.
Related Issues (20)
- Partial SSG/preRender HOT 4
- use localStorage HOT 1
- [Bug] Why `window?.xxx?.xxx` fails on build? HOT 1
- [Bug] react-static bundle --analyze ERROR HOT 3
- [Bug] Build fails for basic template
- [Bug] basePath unable to use HOT 7
- [Bug] Sitemap is generated with template path instead of actual path
- [Bug] React-static renders a blank route for split-second after page load
- [Bug] long time for "Bundle updating"
- When using BrowerRouter in App. The npm run build fails, but npm run start works fine HOT 1
- [Bug] Build fails due to "babel-plugin-universal-import/universalImport" MODULE_NOT_FOUND HOT 2
- redux: "Cannot read property 'store' of null" on build
- [Docs] Internationalized html files (for SEO)? HOT 2
- [Bug] deterministic builds HOT 2
- Support for Yarn 2 HOT 1
- create-react-app build The static resource folder path is incorrect
- [Bug] QueryString not working in production - window.location.search empty
- [Help] Dynamic Routes with statically generated data HOT 2
- Please do not open new issues
- Can't resolve 'react-hot-loader/webpack' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-static.