Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property '__esModule' of undefined when /* webpackPrefetch: true */ #795

Closed
agawley opened this issue Jun 21, 2021 · 4 comments

Comments

@agawley
Copy link

agawley commented Jun 21, 2021

馃悰 Bug Report

I am using serverless to deploy a React app. When I use loadable for code splitting everything is fine until I try to prefretch resources. Adding /* webpackPrefetch: true */ 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

Expected behavior

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!)

Link to repl or repo (highly encouraged)

https://github.com/agawley/loadable-repro

Please provide a minimal repository on GitHub.

https://github.com/agawley/loadable-repro

Issues without a reproduction link are likely to stall.

Run npx envinfo --system --binaries --npmPackages @loadable/component,@loadable/server,@loadable/webpack-plugin,@loadable/babel-plugin --markdown --clipboard

Paste the results here:

## 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 
 - @loadable/webpack-plugin: ^5.15.0 => 5.15.0 
@open-collective-bot
Copy link

Hey @agawley 馃憢,
Thank you for opening an issue. We'll get back to you as soon as we can.
Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers.
If you use Loadable at work, you can also ask your company to sponsor us 鉂わ笍.

@agawley
Copy link
Author

agawley commented Jun 24, 2021

Hiya. Does anyone have any ideas on this? Another couple of days of debugging hasn't helped. I'm pretty sure this is going to be something whacky to do with my having two different webpack configs, but I can't for the life of me figure out what. Thanks!

@theKashey
Copy link
Collaborator

I've also experienced some problems with prefetch, to the level that I cannot use them, but not even close to your case.

@agawley
Copy link
Author

agawley commented Jul 2, 2021

Got an answer from webpack. It's a bug in webpack (webpack/webpack#12993). PR is here (webpack/webpack#13431)

@agawley agawley closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants