1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-04 11:44:00 +00:00

More webpack 4 code. Make sure to asynchronously await the availability of our webpack hook everywhere that we use it that it's reasonable to wait.

This adds a new module called switchboard that abuses the root React Router instance to forcibly load a chunk, letting us grab `require()` quickly rather than waiting potentially forever for another chunk to be loaded due to user action, etc.
This commit is contained in:
SirStendec 2018-05-18 17:48:10 -04:00
parent 194f93414d
commit 86c5fee033
13 changed files with 128 additions and 24 deletions

View file

@ -23,7 +23,7 @@ export default class WebMunch extends Module {
this._module_names = {};
this._mod_cache = {};
this.v4 = false;
this.v4 = null;
this.hookLoader();
this.hookRequire();
@ -47,7 +47,9 @@ export default class WebMunch extends Module {
if ( typeof window.webpackJsonp === 'function' ) {
// v3
this.v4 = false;
this._original_loader = window.webpackJsonp;
try {
window.webpackJsonp = this.webpackJsonpv3.bind(this);
} catch(err) {
@ -249,7 +251,7 @@ export default class WebMunch extends Module {
const loader = require.e && require.e.toString();
let modules;
if ( loader && loader.indexOf('Loading chunk') !== -1 ) {
const data = /({0:.*?})/.exec(loader);
const data = this.v4 ? /assets\/"\+\(({1:.*?})/.exec(loader) : /({0:.*?})/.exec(loader);
if ( data )
try {
modules = JSON.parse(data[1].replace(/(\d+):/g, '"$1":'))