- $chunks[] = ResourceLoader::makeInlineScript(
- ResourceLoader::makeLoaderStateScript( $states ),
+ $stateJson = ResourceLoader::encodeJsonForScript( $states );
+ $script .= <<<JAVASCRIPT
+RLSTATE = {$stateJson};
+JAVASCRIPT;
+ }
+
+ // Inline script: Declare general modules to load on this page.
+ if ( $data['general'] ) {
+ $pageModulesJson = ResourceLoader::encodeJsonForScript( $data['general'] );
+ $script .= <<<JAVASCRIPT
+RLPAGEMODULES = {$pageModulesJson};
+JAVASCRIPT;
+ }
+
+ if ( $this->context->getDebug() ) {
+ $chunks[] = Html::inlineScript( $script, $nonce );
+ } else {
+ $chunks[] = Html::inlineScript(
+ ResourceLoader::filter( 'minify-js', $script, [ 'cache' => false ] ),