From d4deb36f087f3e5d269f34acdf73154db1901399 Mon Sep 17 00:00:00 2001 From: SirStendec Date: Mon, 27 Aug 2018 17:22:06 -0400 Subject: [PATCH] 4.0.0-rc12.14 * Fixed: Twitch changed the internal structure of their dynamically loaded component system, preventing FrankerFaceZ from being able to force a new chunk to load to grab the internals of webpack. --- src/main.js | 2 +- src/sites/twitch-twilight/switchboard.js | 51 +++++++++++++++++------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/main.js b/src/main.js index 543b6b8e..520d8836 100644 --- a/src/main.js +++ b/src/main.js @@ -100,7 +100,7 @@ class FrankerFaceZ extends Module { FrankerFaceZ.Logger = Logger; const VER = FrankerFaceZ.version_info = { - major: 4, minor: 0, revision: 0, extra: '-rc12.13', + major: 4, minor: 0, revision: 0, extra: '-rc12.14', commit: __git_commit__, build: __webpack_hash__, toString: () => diff --git a/src/sites/twitch-twilight/switchboard.js b/src/sites/twitch-twilight/switchboard.js index 35c62807..3a7b5016 100644 --- a/src/sites/twitch-twilight/switchboard.js +++ b/src/sites/twitch-twilight/switchboard.js @@ -65,24 +65,47 @@ export default class Switchboard extends Module { this.log.info('Found Non-Matching Route', route.props.path); + const component_class = route.props.component; + let component; - try { - component = new route.props.component; - } catch(err) { - this.log.error('Error instantiating component for forced chunk loading.', err); - component = null; - } + if ( component_class.Preload ) { + try { + component = component_class.Preload(); + } catch(err) { + this.log.error('Error instantiating preloader for forced chunk loading.', err); + component = null; + } - if ( ! component || ! component.props || ! component.props.children || ! component.props.children.props || ! component.props.children.props.loader ) - continue; + if ( ! component || ! component.props || ! component.props.loader ) + continue; - try { - component.props.children.props.loader().then(() => { - this.log.info('Successfully forced a chunk to load using route', route.props.path) - }); - } catch(err) { - this.log.warn('Unexpected result trying to use component loader to force loading of another chunk.'); + try { + component.props.loader().then(() => { + this.log.info('Successfully forced a chunk to load using route', route.props.path) + }); + } catch(err) { + this.log.warn('Unexpected result trying to use component pre-loader to force loading of another chunk.'); + } + + } else { + try { + component = new route.props.component; + } catch(err) { + this.log.error('Error instantiating component for forced chunk loading.', err); + component = null; + } + + if ( ! component || ! component.props || ! component.props.children || ! component.props.children.props || ! component.props.children.props.loader ) + continue; + + try { + component.props.children.props.loader().then(() => { + this.log.info('Successfully forced a chunk to load using route', route.props.path) + }); + } catch(err) { + this.log.warn('Unexpected result trying to use component loader to force loading of another chunk.'); + } } break;