React-Router-v4 无法通过 Babel Register 在 Preact 上运行

React-Router-v4 Not Working on Preact via Babel Register

我正在尝试使用 react-router-4 设置一个服务器来响应 react。虽然它在前端(Webpack)上工作得很好。在服务器端使用时,preact-compat 似乎不起作用。我正在使用 babel-register 所以转译代码。

我这里有个分店可以参考: https://github.com/abarcenas29/preact-sandbox-v0/tree/wip/isomorphic-react

到运行: yarn run install yarn run start:prod

转到localhost:3100

使用 Babel 作为依赖项的别名没有意义,因为 Babel 不会 运行 您的依赖项(在 node_modules 中)。请改用模块别名之类的东西。

同一问题的完整答案在 Github:https://github.com/developit/preact-compat/issues/390#issuecomment-304334947