Skip to content
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

[Feature]: Increase memory with a flag / Support Node Flags #289

Closed
damianobarbati opened this issue Feb 26, 2018 · 13 comments · Fixed by #1195
Closed

[Feature]: Increase memory with a flag / Support Node Flags #289

damianobarbati opened this issue Feb 26, 2018 · 13 comments · Fixed by #1195

Comments

@damianobarbati
Copy link

damianobarbati commented Feb 26, 2018

Could webpack-cli handle the memory limit increase with a flag?

Right now we have to manually use:
node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js

A simple flag would be very nice instead:
webpack --increase-memory 4096

Or multiple custom node options like:
webpack --node.increase-memory 4096 --node.trace-deprecation --node.experimental-modules

@matheus1lva
Copy link
Member

matheus1lva commented Mar 16, 2018

I'm down to grab this, but i'm not really sure where do i add the flags.
Is this similar to this?

.concat("process.env.NODE_ENV=\"production\"");

@montogeek
Copy link
Member

@playma256 No, it is part of the process args, not process environment variables

@montogeek
Copy link
Member

You could do something like argv["max_old_space_size"] = 4096 somewhere.
I believe this shouldn't be part of webpack, it should be handled by the user.

@matheus1lva
Copy link
Member

matheus1lva commented Mar 16, 2018

I expressed myself in a wrong way, sorry for that.
I understand it's not a process args, but i meant to do this the same way that the production mode is handled.
Anyways. You answered my question!
Thank you @montogeek

I'm grabbing this issue.

@matheus1lva
Copy link
Member

matheus1lva commented Mar 21, 2018

I was having a look how to implement those flags, and i've reached a fork road. I'm not able to override node flag options when a process already started, so i was thinking... spawning a child process passing down v8 flags would be a cumbersome idea or is there a way (i actually dont know any...) to update v8 flags when a process already started?

What do you all think?

Edit
Apparently that is what mocha does, they allow passing v8 flags into the CLI and spawns another process.
Link for reference.

@evenstensberg
Copy link
Member

Getting back to you on this. This might not be possible without invoking node ./path/to/webpack

@matheus1lva
Copy link
Member

is there a way to run a single test only? A single binary test?

@ematipico
Copy link
Contributor

Not at the moment :(

@evenstensberg evenstensberg changed the title Increase memory with a flag [feature request] Feature: Increase memory with a flag May 18, 2018
@evenstensberg
Copy link
Member

This impl can be used with #15 . We keep track of pId and restart a process once it's done ( I think )

@webpack-bot
Copy link

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.

@damianobarbati
Copy link
Author

Can npx used to accomplish the result? i.e: npx -n=' --max_old_space_size=4096'
Not sure how to inspect max memory limit for current process in js.

@evenstensberg
Copy link
Member

Yes if npm supports injection of args. We cannot use this as a fix to us, as the flags needs to be supported by default not by running npx

@webpack-bot
Copy link

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.

@evenstensberg evenstensberg reopened this May 21, 2019
@evenstensberg evenstensberg changed the title Feature: Increase memory with a flag [Feature]: Increase memory with a flag / Support Node Flags Oct 31, 2019
smelukov added a commit to smelukov/webpack-cli that referenced this issue Jan 29, 2020
rishabh3112 pushed a commit that referenced this issue Jan 30, 2020
* feat(cli): allow to pass flags to node.js
closes #1084
closes #289

* chore(cli): fix snapshot

* chore(cli): drop nodejs 8 from ci

* chore(cli): fix test

* feat(cli): add parseArgs helper

* feat(cli): parseArgs now supports --node-args="..." syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants