-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
__webpack_require__ is too slow #2219
Comments
Take a look at the source of this function. It's pretty short, but if you see a way to optimize it, I would love to hear it. |
Maybe there's a way to make Before: var View = require('lib/view');
var SmallPlayButton = require('views/small-play-button');
var LargePlayButton = require('views/large-play-button');
var Experiments = require('lib/experiments')
var PlayButton = View.extend({
render: function() {
if (Experiments.showSmallPlaybutton()) {
SmallPlayButton.render();
} else {
LargePlayButton.render();
}
}
}); After: var PlayButton = require('lib/view').extend({
render: function() {
if (require('lib/experiments').showSmallPlaybutton()) {
require('views/small-play-button').render();
} else {
require('views/large-play-button').render();
}
}
}); |
Yes, this is exactly what I wanted to do but in this case I'd have to rewrite entire application... |
@deser You can try to play around with https://github.com/facebook/jscodeshift. This project seems to really facilitate the process of source code transformation. Once you have this make-webpack-require-calls-lazy transformation implemented, it should not be that difficult to integrate it into webpack pipeline. If you're not familiar with JSCodeShift, you might find this article quite helpful. |
Thanks for great idea! |
@deser Any success about it? We have the same issue. |
@dxbykov |
Initially I also tried to find a way to do it using standard Webpack configuration options, but it appeared that Webpack didn't support it, probably because it takes care of bundling modules only. But, provided that you're using Babel to transform JavaScript, it's possible to use We recently applied this approach in SoundCloud web app and it resulted in a fairly noticeable start-up time improvement. |
I think it makes sense to close this issue |
Great! Many thanks, @akovalev :) |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Hey, Guys. Any further updates here? |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Closing due to inactivity. Please test with latest version and feel free to create new issue with minimum reproducible test repo if you have still regressions. Thanks! |
Is there option for evaluating dependencies in lazy way?
Now initialization of my application takes much time. I profiled a bit and saw that webpack_require takes 300ms by itself
How can I improve perfomance of webpack require?
The text was updated successfully, but these errors were encountered: