Reputation: 31
I am using serverless to deploy a React app with SSR. 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 >
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
The page should load with a 'show/hide' link which reveals the lazy-loaded component SomeText. If you remove the /* webpackPrefetch: true */ comment from app.js you get the expected behaviour (but no prefetching!)
## 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
Upvotes: 0
Views: 3535
Reputation: 31
Got an answer from webpack. It's a bug in webpack. PR to fix (not yet accepted, but works as patch)
Upvotes: 1