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

Figure out multiple configs passed to compiler #10

Closed
grabbou opened this issue Mar 23, 2017 · 14 comments
Closed

Figure out multiple configs passed to compiler #10

grabbou opened this issue Mar 23, 2017 · 14 comments
Assignees
Labels

Comments

@grabbou
Copy link
Member

grabbou commented Mar 23, 2017

Currently we create an array of configs, one for each platform. We used to pass that array to webpack compiler, but switched to passing a single one (current platform you are building) for performance reasons.

When Webpack compiler receives an array of configs, it enters multi-config mode and handles them all w/o restarting. That allows us to serve all platform bundles at the same time, just like packager.

Unfortunately, it has a couple of limitations:

  • It builds all configs at once
  • It recompiles all configs at once, even if one bundle didn't change
  • It's sync - android gets build after ios
  • Default devMiddleware waits for all builds to finish, even if you requested ios. That means you wait for 20 seconds even if iOS was ready after 5 seconds
  • All bundles are built w/o waiting for a request (no lazy option)

All the above makes the development time significantly slower for a very specific use-case (having two simulators open at the same time). However, that use-case is important and we need to support it in a better way.

I'll chat with Webpack team to understand how it works currently, if we are correct and how to fix that. Generally speaking, we might need to write our own dev middleware that does these things.

A solution would be to add a feature to bundle lazily as soon as you request platform bundle. That means we wouldn't bundle android until you load Genymotion and request it. However, as I said above, currently turning on lazy option has two issues:

  • It is lazy for all configs - if you request ios, android also gets built
  • When lazy is turned on, watch doesn't work (recompile on file change)

Current solution requires passing --platform flag.

This is very important to sort out now as it's going to be an important workflow detail - whether to pass platform flags or not.

@grabbou grabbou changed the title Figure out Webpack perf & multiple configs Figure out multiple configs passed to compiler Mar 25, 2017
@grabbou grabbou self-assigned this Mar 25, 2017
@grabbou grabbou added this to the Alpha 1.0 milestone Mar 25, 2017
@grabbou
Copy link
Member Author

grabbou commented Mar 27, 2017

Update: new solution is to require --platform flag with either ios, android or all value. When all is set, Webpack enters multi-compiler setup and will serve both platforms.

Ultimately we want to do all always as long as we can provide a satisfactory performance. Upgrade path would be to make platform no longer required and by default, build for all.

@grabbou
Copy link
Member Author

grabbou commented Mar 27, 2017

I'll continue working on that tomorrow. Now moving to other things.

@grabbou
Copy link
Member Author

grabbou commented Mar 27, 2017

Note for tomorrow: we have to remove progressBar plugin from webpack config and attach it manually to the multi-compiler. That way, we can manually create n progress bars that work together.

Currently progress bars are causing glitches as each compiler tries to override the same bar with its progress.

I have it working on my draft branch, need to cherry-pick it.

A nice benefit of that addition is that it nicely illustrates serial nature of webpack compiler.

@zamotany
Copy link
Contributor

I don't think there is a option to fix/make workaround for rebuilding iso and android bundle source files changed, since webpack treats it separatly, so ios compiler this that source code has changed for this bundle, and android compiler also. However if we rewrite dev middleware maybe we can implement solution that will lazily build bundle that is requested and watch it, but not build the other one, but if the other one is requested we stop watching the first one, builds the second and watch it or something similar.

@zamotany
Copy link
Contributor

Also, is something blocking us from having 2 parallel builds in separate threads?

@evenstensberg
Copy link

If I understood this correctly, you want to build recursively and async, not all at once? @grabbou

@grabbou
Copy link
Member Author

grabbou commented Mar 30, 2017

Yup, @ev1stensberg + first build lazy (on request for entry point).

@evenstensberg
Copy link

I'll see if I can squeeze some time to look into the source code, got a ton of work ahead of me, sadly. Maybe @TheLarkInn has some immediate feedback, but I need to see the source code myself before coming up with a fix. One thing you mentioned was that it builds all configs at once. One thing I've seen is that you can use webpack-merge to generate a config, that could be of use for the async functionality or even switch between ios and android builds. If webpack compiles regardless of changes, we've got a thread on webpack-cli on how to avoid this. Hope it helps!

@grabbou
Copy link
Member Author

grabbou commented May 24, 2017

Just wondering if you had any time to look into this recently. Not a top priority but worth keeping in mind as far as planning goes.

@evenstensberg
Copy link

I've got some time in 2-3 weeks, got a hectic period of exams right now. If ok, can look into it then 👍

@grabbou
Copy link
Member Author

grabbou commented May 29, 2017

Sounds good, let me know and I'll be happy to pair on implementing/discussing that

@evenstensberg
Copy link

Just need an email / open DM on Twitter ✌️

@thymikee
Copy link
Member

@jukben @satya164 is this still relevant on next branch?

@zamotany
Copy link
Contributor

No longer relevant.

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

No branches or pull requests

4 participants