反应可加载的未定义的json密钥

时间:2018-04-18 11:04:26

标签: reactjs react-router serverside-rendering react-loadable

我试图使用反应加载服务器端渲染。

我的宝贝插件配置

 "plugins": [
      "syntax-dynamic-import",
      "dynamic-import-node",
      "react-loadable/babel",
      [
        "import-inspector",
        {
          "serverSideRequirePath": true,
          "webpackRequireWeakId": true
        }
      ],
      "transform-react-remove-prop-types",
      "transform-react-inline-elements",
      "transform-react-constant-elements"
    ]
渲染期间的

服务器响应,使用:

  console.log(modules);
  const bundles = getBundles(stats, modules);
  console.log(bundles);

得到:

[ 'HomePage' ]
[ undefined ]

我想我的错误来自react-loadable.json,其中有一个键undefined

  "undefined": [
    {
      "id": 7,
      "name": "./node_modules/react-intl/lib/index.es.js",
      "file": "main.a77d1cb1913eab1806a7.js"
    },
    {
      "id": 19,
      "name": "./node_modules/redux/es/index.js",
      "file": "main.a77d1cb1913eab1806a7.js"
    },
    {
      "id": 52,
      "name": "./node_modules/redux-saga/es/internal/sagaHelpers/index.js",
      "file": "main.a77d1cb1913eab1806a7.js"
    }
  ]

但如果我有webpackChunkName并且模块定义如下,我可以弄清楚它是如何变得不确定的:

export default Loadable({
  loader: () => import(/* webpackChunkName: "HomePage" */ './index'),
  loading: () => null,
  modules: ['HomePage'],
});

也许某人有类似的问题或知道任何解决方案?

0 个答案:

没有答案