-
-
Notifications
You must be signed in to change notification settings - Fork 381
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Won't work if I use webpack to compiled code for server side #181
Comments
Hello @abramstyle, thanks for your issue. I submitted a PR, I use |
Hi @neoziro , I changed the code, It works fine now. Thanks. |
Hey @neoziro, I found a better way to solve this problem. Just add @loadable/server to webpack config file like this: {
// other configs...
externals: {
'@loadable/server': 'commonjs @loadable/server'
}
} Then webpack would not to compile the code from package '@loadable/server'. Sorry to waste your time looking for a solution, May be the PR should be closed now. |
I think I will merge the PR, it is better if it works out of the box. |
OK, understood. I will close this issue now. |
@abramstyle OK, merged and released anyway |
🐛 Bug Report
I compiled my code for server side rendering using webpack. Webpack converted require into
__webpack_require__
so the code is broken because the statsFile is dynamic require.I found a solution to make it work, just change the require to
__non_webpack_require__
in the file utils https://github.com/smooth-code/loadable-components/blob/1e073267ffa3f7d12351651a7357ca8707df801a/packages/server/src/util.js#L9So may be we can check if the code in the webpack environment then decide use require or
__non_webpack_require__
.To Reproduce
Expected behavior
Code run as normal
Link to repl or repo (highly encouraged)
Run
npx envinfo --system --binaries --npmPackages @loadable/component,@loadable/server,@loadable/webpack-plugin,@loadable/babel-plugin --markdown --clipboard
Paste the results here:
The text was updated successfully, but these errors were encountered: