Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

#943 - Split bundle via async imports #1123

Merged
merged 26 commits into from
Dec 19, 2017

Conversation

bryphe
Copy link
Member

@bryphe bryphe commented Dec 13, 2017

This is the first part of an improvement in startup time. Today, we need the browser to load the entire large bundle.js before it can start rendering.

This change leverages the async import functionality, along with webpack's ability to chunk along the async boundaries, such that we can kick start some operations and parallelize the loading.

This is a first step, but helps to improve loading.

@bryphe
Copy link
Member Author

bryphe commented Dec 14, 2017

There may be some duplication across bundles - should look at incorporating the CommonChunksPlugin as well.

@akinsho
Copy link
Member

akinsho commented Dec 15, 2017

@bryphe may or may not be relevant to what your trying to do here or potentially a rabbit hole, though seemed worth mentioning a new js bundler called Parcel it simplifies a lot of what webpack does through painful configuration and endless plugins, it supports TS and Less, it also does most relevant to this issue Zero Config code splitting 💯 Hopefully

@bryphe
Copy link
Member Author

bryphe commented Dec 15, 2017

Ah ya, interesting! It does look easy and straightforward.

I'm wondering too if we can just avoid making bundles altogether - just point Electron to the output index.js. This would save us a lot of compile time, and might actually be more efficient in terms of loading. The version of Node that Electron has today unfortunately doesn't support the import method, but once Electron 2 is out, it might be worth profiling w/o any bundler.

@bruchmann
Copy link

There’s also electron-link that might help with improving startup time.

electron-link is a node module that takes a JavaScript file (typically the entry point of an application) and a list of modules that need to be required lazily (see Atom's build scripts for an example). Then, starting from that file, it traverses the entire require graph and replaces all the forbidden require calls in each file with a function that will be called at runtime. The output is a single script containing the code for all the modules reachable from the entry point. This file can be then supplied to mksnapshot to generate a snapshot blob.

@bryphe
Copy link
Member Author

bryphe commented Dec 18, 2017

Thanks for the pointer, @bruchmann ! We're tracking leveraging v8 snapshots in #381 , just added some context there - electron-link looks like it would be very helpful for that.

@bryphe bryphe changed the title [WIP] #943 - Split bundle via async imports #943 - Split bundle via async imports Dec 19, 2017
@bryphe bryphe merged commit 57929c0 into master Dec 19, 2017
@bryphe bryphe deleted the bryphe/943.1/start-split-via-async-imports branch December 19, 2017 04:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants