简体   繁体   English

类型错误:当 /* webpackPrefetch: true */ 带有可加载组件和无服务器的 SSR 时,无法读取未定义的属性“__esModule”

[英]TypeError: Cannot read property '__esModule' of undefined when /* webpackPrefetch: true */ when SSR with loadable-component and serverless

I am using serverless to deploy a React app with SSR.我正在使用无服务器部署带有 SSR 的 React 应用程序。 When I use loadable-compoennts for code splitting everything is fine until I try to prefretch resources.当我使用可加载组件进行代码拆分时,一切都很好,直到我尝试预取资源。 Adding /* webpackPrefetch: true */ to any loadable method causes a server side crash on importing my < App >将 /* webpackPrefetch: true */ 添加到任何可加载方法会导致服务器端在导入我的 < App > 时崩溃

TypeError: Cannot read property '__esModule' of undefined
    at /Users/alexgawley/code/serverless/tmp/loadable-repro/.webpack/service/src/servers/static.js:29310:34
    at Object.<anonymous> (/Users/alexgawley/code/serverless/tmp/loadable-repro/.webpack/service/src/servers/static.js:29312:12)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /Users/alexgawley/code/serverless/tmp/loadable-repro/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:157:133
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async InProcessRunner.run (/Users/alexgawley/code/serverless/tmp/loadable-repro/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:157:9)
To Reproduce

Steps to reproduce the behavior:重现行为的步骤:

git clone https://github.com/agawley/loadable-repro
npm i
npm run offline

load http://localhost:3000加载 http://localhost:3000

The page should load with a 'show/hide' link which reveals the lazy-loaded component SomeText.该页面应加载一个“显示/隐藏”链接,该链接显示延迟加载的组件 SomeText。 If you remove the /* webpackPrefetch: true */ comment from app.js you get the expected behaviour (but no prefetching!)如果您从 app.js 中删除 /* webpackPrefetch: true */ 注释,您将获得预期的行为(但没有预取!)

## System:
 - OS: macOS 10.15.7
 - CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
 - Memory: 834.46 MB / 16.00 GB
 - Shell: 5.7.1 - /bin/zsh
## Binaries:
 - Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
 - Yarn: 1.22.10 - /usr/local/bin/yarn
 - npm: 7.13.0 - ~/.nvm/versions/node/v12.22.1/bin/npm
## npmPackages:
 - @loadable/babel-plugin: ^5.13.2 => 5.13.2 
 - @loadable/component: ^5.15.0 => 5.15.0 
 - @loadable/server: ^5.15.0 => 5.15.0 

Got an answer from webpack.从 webpack 得到了答案。 It's a bug in webpack .这是webpack 中的一个错误 PR to fix (not yet accepted, but works as patch) PR 修复(尚未接受,但可用作补丁)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 × history.props.push() 得到“TypeError: Cannot read property 'push' of undefined”,即使将组件包装在 withRouter() - × history.props.push() getting “TypeError: Cannot read property 'push' of undefined” even when wrapping component in withRouter() TypeError:解析promise时无法读取未定义的属性&#39;then&#39; - TypeError: Cannot read property 'then' of undefined when I resolved promise 类型错误:在 Vuex 4 和 Vue 3 上服务时无法读取未定义的属性“getter” - TypeError: Cannot read property 'getters' of undefined when serving on Vuex 4 and Vue 3 在 electron 中进行 ipc 调用时,“TypeError: Cannot read property 'on' of undefined” - “TypeError: Cannot read property 'on' of undefined” when making an ipc call in electron TypeError:使用findOneAndRemove()时无法读取未定义的属性&#39;_id&#39; - TypeError: Cannot read property '_id' of undefined when using findOneAndRemove() TypeError:当我使用 npm 时,无法读取未定义的属性“匹配” - TypeError: Cannot read property 'match' of undefined when I use npm 定义变量时,获取 TypeError 无法读取未定义的属性“0” - Getting TypeError Cannot read property '0' of undefined when variable is defined 类型错误:请求确认时无法读取未定义的属性“内容” - TypeError: Cannot read property 'content' of undefined when asking for confirmation 当调用populate TypeError时:无法读取未定义的属性&#39;ref&#39; - When call populate TypeError: Cannot read property 'ref' of undefined 类型错误:喜欢时无法读取未定义的属性“地图” - TypeError: Cannot read property 'map' of undefined when liking
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM