react server render的坑


如果是使用了nodejs内置的工具,需要在externals中添加额外配置,比如 {http: ‘commonjs http’, fs: ‘commonjs fs’ }





Code-splitting + server rendering

We’ve tried and failed a couple of times. What we learned:

  1. You need synchronous module resolution on the server so you can get those bundles in the initial render.
  2. You need to load all the bundles in the client that were involved in the server render before rendering so that the client render is the same as the server render. (The trickiest part, I think its possible but this is where I gave up.)
  3. You need asynchronous resolution for the rest of the client app’s life.

We determined that google was indexing our sites well enough for our needs without server rendering, so we dropped it in favor of code-splitting + service worker caching. Godspeed those who attempt the server-rendered, code-split apps.


关于 admin

此条目发表在 ecmascript, react 分类目录。将固定链接加入收藏夹。