Open Enalmada opened 5 years ago
You need to disable this plugin in development environment, it should be used only on CI. Heap out of memory has nothing to do with this plugin, your system just doesn't have enough memory for build.
You can also disable source maps, this should lower memory usage, just pass { sourceMaps: false }
I appreciate the sanity check. I was only getting error when building and am pretty sure I am using it as intended:
if (!dev) {
config.plugins.push(new TargetsPlugin({
browsers: ["last 2 versions", "chrome >= 41"]
}))
}
max_old_space_size
seems to have something to do with it because it really seems to fix the error....if I remove it I get the error again and vice versa....but perhaps it is random...I will get more data. I have a 16g build machine and think I have plenty of free ram otherwise. I am testing it out on a sample project which I can make available if you are curious.
Referring #3 where @sprguillen solved it by using webpack-bundle-analyzer and restructuting how plugins are being loaded by webpack.
And tbh. I don't like that this plugin uses both babel and rollup to achieve its goal but I cannot find a way for babel-env to output browser-compatible builtins. Instead it outputs es6 which I need to transcompile for browser again..
Or maybe I'll put it another way: there is no way for babel-env to directly output builtins instead of just putting requires in source, like import "core-js/modules/es7.array.includes"
or define(["core-js/modules/es7.array.includes"],function(includes, ...){})
I am getting this on a sample project that is loading some plugins but not sure how to restructure how they are being loaded.
It might just be the way windows node manages heap. Seems like most of the reports I can see while searching about this error seem to be windows. I assume since I am getting this error during build that sourceMaps: false
is not needed (I am assuming that is a dev only thing)? Thanks for confirming that "heap out of memory" has nothing to do with this plugin. I think the bottom line is that if anyone else has this issue...they are probably on windows...and then the solution is this:
cross-env NODE_OPTIONS=--max_old_space_size=4096 next build
Maybe @sprguillen can help to fix this sample project
Can you post your webpack config if you have one @Enalmada? Please
Here is the config for the sample project I am building as a test environment for everything I need in a production setup: https://github.com/Enalmada/next-reason-boilerplate/blob/master/next.config.js#L73-L85
If you have any ideas of things that could be better I would very much appreciate your feedback!
Thank you @Enalmada
I tried using v2.0.0 with my nextjs sample project and got a javascript error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
--max_old_space_size=4096
seems to fix it. Just wanted to call it out incase it is worth noting in the readme or helps someone searching:cross-env NODE_OPTIONS=--max_old_space_size=4096 next build
Let me know if there is something that could be done to debug further if you think this might be due to something bad rollup is doing on the targets-webpack-plugin side.
Full stacktrace: