-
Notifications
You must be signed in to change notification settings - Fork 59
Global override lazy
in test environment to prevent chunking
#22
Comments
lazy
in test environmentlazy
in test environment to prevent chunking
This would also be really helpful to work around the inability to hot-reload async components at the present time: |
@rosskevin Please feel free to send PR for further discussion 😛 |
Hi ! I run into this trouble too. More specifically using Angular 2 Universal for which I wanted the server part not to be chunked (angular/angular-cli#7187) I just find a workaround using webpack
(https://github.com/webpack/docs/wiki/optimization#chunks) I hope it can help ! |
In my case, bundle-loader (as used in React Router v4 code splitting demo) was breaking react hot reloading in development. I was unable to resolve the issue with LimitChunkCountPlugin. What did work however, was NormalModuleReplacementPlugin to take a path like this: import loadDashboard from 'bundle?lazy!./components/Dashboard' and in development, turn it into: import loadDashboard from './components/Dashboard' Then you can wrap calls to function loadBundle (loaderFn, callback) {
if (process.NODE_ENV == 'development') {
// component is available immediately, since it didn't go through bundle-loader
callback(loaderFn);
return;
}
// component gets loaded through bundle-loader
loaderFn(function(mod) {
callback(mod.default ? mod.default : mod);
});
} and call it like: loadBundle(loadDashboard, function (Dashboard) {
// Dashboard component available for use!
}); |
I'm using lazy loading for code splitting with great success!
The problem comes during testing:
If it's a test environment, I'd like to be able to globally disable lazy loading. Due to the nature of static ES6 imports, I cannot parameterize the import.
Is this something that would seem useful as a PR?
Are there other ways of solving this (while leaving my import as-is.)? NOTE: I don't want to configure an implicit bundle-loader based on path, I want the explicit import.
The text was updated successfully, but these errors were encountered: