-
-
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
Compile stuck at optimize chunk assets #537
Comments
Could try to run uglifyjs on the output files? Maybe it's an uglifyjs bug... |
I've done what you suggested, I first build with webpack with no optimization and then executed this script to compress using uglifyjs (v2) and got no issues:
Maybe I'm using different arguments options from those used in UglifyJsPlugin? If I couldn't fix this, can I switch to this script to compress my build? Should I configure uglifyjs in a specific way? |
hmm... Could you give me access to the repo or prepare a testcase so I can debug it? |
I could pass you the bunch of files... On Wed, Oct 15, 2014 at 11:25 AM, Tobias Koppers [email protected]
|
How can I send you privately the repo/files? |
I hit a similar problem. It seems that the UglifyJSPlugin can't handle a compressed return value from uglify.Compressor, specifically the I added console logging like this around there:
And in my output I can see it does indeed get stuck there:
Workaround for me for now was to init the uglify plugin with The codebase in question is a quite large ReactJS/Reflux application. |
If you have any ideas which Uglify compress options I should try to weed out what specific feature thet |
I've just come across the same problem with a large project with 26 entry points. If I disable source maps it works but hangs with source maps enabled. My current hypothesis is that because webpack keeps all the sourcemaps in memory as it is compiling it results in node hitting the 1.4Gb limit in v8. I'm not familiar with how the internals work but can the maps not be flushed to the files on disk instead of keeping them in memory? |
I've managed to solve the issue by externalising some of the big libraries (React and jQuery). That seems to have reduced the memory usage considerably and I can now compress the bundles with source maps. |
Probably it's sufficient to flag libraries with noParse |
@sokra so I've created a fairly contrived example repo that manages to reproduce the problem here: https://github.com/jkimbo/webpack-memory-issue It has 20 entry points each of which requires fairly large libraries and then it runs it through the uglify plugin with sourcemaps. I realise it is in no way optimised but hopefully it can help debug this issue. |
I am seeing a similar issue as well. |
I have the same problem without UglifyJS (continuous development build). The problem occurs after a couple of rebuilds and I believe I have an idea of where it leaks memory. In my case, the count of ModuleNotFoundError objects created is growing at an extremely high pace. That error is thrown because of moment.js so I excluded it from parsing (noParse) and as a result the heap size stays stable (instead of growing further). If I read the dump in node-inspector correctly, it might be in the cache object of the Compilation module. That's as much as I could find out so far. |
You can try to disable the cache with |
Having the same. |
Ended up downgrading webpack-dev-server to 1.7.0 and webpack to 1.7.3 to make it work. |
Regarding the original issue: new UglifyJsPlugin({
sourceMap: false
}) instead of |
Have the same issue here, without UglifyJsPlugin. anyway. Thanks for the webpack! incredible pice of art. |
Same issue, |
I don't think it's UglifyJS or memory; my webpack config suddenly started hanging at only module 67, when it was successfully building over 400 modules before. Ironically it still works with webpack dev server and various plugins; but my config that's hanging has no plugins. |
Here's my config that hung it.
|
@jhnns unfortunately |
@sokra I was thinking, if only I could make Webpack print out the modules one by one as it encounters them while building, then I could see which one it's hanging on, and maybe that would give me a clue what to investigate next. |
Another note, my compilation gets stuck before the optimizing chunk assets part. Who knows, there might be several unrelated issues here. |
I have exactly the same issue, and also at the exact same percentage (80%). Dev builds work fine. |
@Monokai As far as I've seen it always says 80% for optimizing chunk assets. |
@jedwards1211 @Monokai I faced the same problem. The main thing on my side is a bug in the libsass transpiler. Following workaround solves the problem for me: Some context: |
@Tzaphkiel - Does the big dependency you added to your project have any pre-minified files? If so, that is likely the cause, as @sunlei33 recently mentioned about the UglifyJS issue. If not, try using the workarounds for increasing the number of threads and allocated memory for the node process running webpack, as I summarized above. I have encountered the exact same issues. |
@dougcalobrisi - Ok, thx, that might be it, the project I'm trying to include is alloy-editor which contains ckeditor, etc. and has indeed minimized files. Is there a plan to fix this ? I saw something about UglifyJS having a fix in master but nothing released in npm yet... the dep. would still have to be adapted in webpack dependency no ? My workaround for the moment is simply to turn off compress in the plugin definition for UglifyJS... |
@Tzaphkiel - You could clone the current master repo for UglifyJS and then use npm link to create a globally installed version of the current master of UglifyJS, then delete the current UglifyJS dep in node_modules/ of your project and then install the linked version. I haven't actually tried this, it's just off the top of my head, but should work. Something like this:
At that point your project should have the uglifyjs dependency in your project's node_modules symlinked to the globally installed version of the current master branch of UglifyJS. You'll want to unlink it once they have pushed a new release to npm. Let me know if that works or not for you. As I said I haven't actually tested it, so no guarantees. Likely very helpful for others if it works, though. |
Just happened to me. And I tested it again after removing |
make this happens. Disable watch solved problem for me. |
@dougcalobrisi How can I know webpack's default memory and thread pool that Node provides ? And how much should I set will be best ? |
@FrendEr - I believe the default heap allocation is 1.76gb for a 64bit environment. You could check it using As for the default thread pool size, I believe that is coming from libuv which has a default of 4 threads. |
@dougcalobrisi thanks! I use |
@sunlei33 [email protected] has merge the issue#1024 and publish, but it has no effect on build optimization |
I found the code in |
Had this same issue, building was taking 10mins+ and as a few people have noted, i took out my minified dependencies and it now builds in ~10s :D. |
Had the same general issue as @theatlasroom and went the same direction to try and troubleshoot which oddly enough solved the issue. |
Increasing swap worked for me! |
@rturk can you elaborate? |
@unformatt I also found out that I didn't have any swap space enabled on my digital ocean centos machine, which was causing the out-of-memory killer to kill my install script. Increasing swap fixed that problem for me. It still hangs for a bit at 78-80% tho. |
@sokra Could you comment on why you closed this? Has a fix from uglify been pulled in to fix the problem with already-compiled files? |
removing the --progress option worked for me |
In some cases and digging, i've fixed mine by insuring that the if (Mix.extract) {
module.exports.plugins.push(
new webpack.optimize.CommonsChunkPlugin({
names: Mix.entryBuilder.extractions.concat([
path.join(Mix.js.base, 'manifest').replace(/\\/g, '/')
]).filter(function (item, pos, self) {
return self.indexOf(item) == pos;
}),
// minChunks: ({resource}) => /node_modules/.test(resource)
minChunks: Infinity
})
);
} Edit: Sorry, After I updated my npm libraries, I started having errors somewhere in Hope it helps. |
webpack asset optimization continuously loops on 'ng serve'. I was expecting it would do once, then start my app at localhost:4200 Any Ideas? Did npm update, and got all latest node_modules. Here is my // package.json { Chouhan:mockii_node rakeshchouhan$ ng serve To disable this warning use "ng set --global warnings.packageDeprecation=false". Your global Angular CLI version (1.0.0-beta.28.3) is greater than your local To disable this warning use "ng set --global warnings.versionMismatch=false". |
@chouhan - Questions regarding the angular-cli belong in whatever medium the have designated for support requests. |
@d3viant0ne - I did not get you. Are you expecting me to rewrite the question in a proper format? I am looking for a solution to the above issue posted. |
I'm not expecting you to rewrite the question, I am saying you are posting it in the wrong place. Your question is related to the There is a ton of code on top of the cli's default webpack configuration that could be related to the output you are getting and considering you can't directly modify the cli's webpack configuration, this is an issue that will need to be handled by that team in whatever forum they have designated for support requests. That said, first off I would get off of the Secondly, don't mismatch the global cli version with the application cli version particularly with the beta builds. There are numerous resolved issues pre-final release caused by version mismatches. Beyond those two things, you need to ask your question in the proper forum. i.e. the angular-cli repository. |
I've started having problems to compile my build when
--optimize-minimize
is enabled.I see that I've reached +/-205 build modules, and then the compilation gets stuck at
80% optimize chunk assets
for a very long time (+40minutes).If I wait enough, it ends up node failing with "fatal error: js allocation failed - process out of memory"
I guess it has to do with the uglifyjs plugin as I said this only happens when using
--optimize-minime
flag (When compiling through my grunt task, this also fails).The text was updated successfully, but these errors were encountered: