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] Spawn a process instead of relying on main thread #1084

Closed
evenstensberg opened this issue Sep 28, 2019 · 6 comments · Fixed by #1195 or #1198
Closed

[FEATURE] Spawn a process instead of relying on main thread #1084

evenstensberg opened this issue Sep 28, 2019 · 6 comments · Fixed by #1195 or #1198

Comments

@evenstensberg
Copy link
Member

Is your feature request related to a problem? Please describe.
On next branch and in general webpack, we're using the thread singly to run webpack. This turns out to be a problem both earlier when trying to integrate node flag support #289 and in node v12 when trying to implement a wrapper to support the new modules declarations ( nodejs/modules#389).

Describe the solution you'd like
Implement a child-process communication when spawning webpack in order to re-run CLI when supporting nodev12 with the experimental flag (we can check node version number for a user and append flag, then re-run a fresh process)

Describe alternatives you've considered
N/A

Additional context
This would probably take some time, but is really important to the new CLI.

@anikethsaha
Copy link
Member

Implement a child-process communication when spawning webpack

Can you elaborate this, quite unclear with the flow!
when we are spawning the main thread, we get to use the child thread only right!, so is it like spawning into more threads to re-run the CLI

@ematipico
Copy link
Contributor

@anikethsaha no, we don't create a new process when running the CLI. We do that only when running external commands.

The idea would be to run a new process when running our main code. So if the new user runs:

webpack -c ./webpack.config.js --node-args "memory_size=1024"

Internally, we would re run something like this using a new process:

node --memory_size=1024 ./cli.js -c ./webpack.config.js

I think we could use execa for this need. We already use it for our tests.

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
@ematipico ematipico reopened this Jan 30, 2020
@ematipico
Copy link
Contributor

Reopening. This work is halfway done. We have now to spawn a process for the cli itself.

@smelukov
Copy link
Member

@ematipico can you add more details please?
We exec cli already https://github.com/webpack/webpack-cli/blob/next/lib/bootstrap.js#L64 🤔

@ematipico
Copy link
Contributor

@smelukov yes, when we pass --node-args. We should do it by default.

@smelukov
Copy link
Member

I'll deal with it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants