manuelbieh / react-ssr-setup

React Starter Project with Webpack 4, Babel 7, TypeScript, CSS Modules, Server Side Rendering, i18n and some more niceties

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why readFileSync instead of async readFile?

fullofcaffeine opened this issue · comments

Hi!

I'm wondering why you used readFileSync and statSync in the i18n middleware, here:

values: fs.readFileSync(`${localesDir}/${locale}/${ns}.json`, { encoding: 'utf-8' }),

It could probably be changed to use the async versions, or is there a specific reason(s) you chose the sync/blocking versions?

The whole i18n live update thing is still very early stage. I don't remember why I chose the synchronous versions over the async ones, there might have been a reason, but I honestly don't remember it. I will keep it in mind and consider rewriting it using the async versions. Thanks!