@@ -155,8 +155,7 @@ public override bool Execute()
155
155
BuildServiceWorkers ( ) ;
156
156
GenerateEmbeddedJs ( ) ;
157
157
GenerateIndexHtml ( ) ;
158
- GenerateConfig ( ) ;
159
- GenerateConfigScript ( ) ;
158
+ GenerateConfigFiles ( ) ;
160
159
RemoveDuplicateAssets ( ) ;
161
160
}
162
161
finally
@@ -533,9 +532,9 @@ static string BuildDependencyPath(string dep, string baseLookup)
533
532
? $ "\" { baseLookup } { Path . GetFileName ( dep ) } \" "
534
533
: $ "\" { baseLookup } { Path . GetFileNameWithoutExtension ( dep ) } \" ";
535
534
536
- private void GenerateConfig ( )
535
+ private void GenerateConfigFiles ( )
537
536
{
538
- var unoConfigJsPath = Path . Combine ( _intermediateAssetsPath , "uno-config.js" ) ;
537
+ GenerateConfigFile ( "uno-config.js" , isModule : true ) ;
539
538
540
539
using ( var w = new StreamWriter ( unoConfigJsPath , false , _utf8Encoding ) )
541
540
{
@@ -635,11 +634,11 @@ private void GenerateConfig()
635
634
}
636
635
}
637
636
638
-
639
-
640
- private void GenerateConfigScript ( )
637
+ private void GenerateConfigFile ( string fileName , bool isModule )
641
638
{
642
- var unoConfigJsPath = Path . Combine ( _intermediateAssetsPath , "uno-config-script.js" ) ;
639
+ var self = isModule ? "" : "self." ;
640
+
641
+ var unoConfigJsPath = Path . Combine ( _intermediateAssetsPath , fileName ) ;
643
642
644
643
using ( var w = new StreamWriter ( unoConfigJsPath , false , _utf8Encoding ) )
645
644
{
@@ -660,7 +659,7 @@ private void GenerateConfigScript()
660
659
. Select ( f => f . GetMetadata ( "Link" )
661
660
. Replace ( "\\ " , "/" )
662
661
. Replace ( "wwwroot/" , "" ) )
663
- . Concat ( [ $ "uno-config-script.js" , "_framework/blazor.boot.json" , "." ] ) ;
662
+ . Concat ( [ fileName , "_framework/blazor.boot.json" , "." ] ) ;
664
663
665
664
var offlineFiles = enablePWA ? string . Join ( ", " , sanitizedOfflineFiles . Select ( f => $ "\" { WebAppBasePath } { f } \" ") ) : "" ;
666
665
@@ -670,27 +669,36 @@ private void GenerateConfigScript()
670
669
671
670
var runtimeOptionsSet = string . Join ( "," , ( RuntimeOptions ? . Split ( ' ' ) ?? [ ] ) . Select ( f => $ "\' { f } \' ") ) ;
672
671
673
- config . AppendLine ( $ "self.config = {{}};") ;
674
- config . AppendLine ( $ "self.config.uno_remote_managedpath = \" _framework\" ;") ;
675
- config . AppendLine ( $ "self.config.uno_app_base = \" { WebAppBasePath } { PackageAssetsFolder } \" ;") ;
676
- config . AppendLine ( $ "self.config.uno_dependencies = [{ dependencies } ];") ;
677
- config . AppendLine ( $ "self.config.uno_runtime_options = [{ runtimeOptionsSet } ];") ;
678
- config . AppendLine ( $ "self.config.enable_pwa = { enablePWA . ToString ( ) . ToLowerInvariant ( ) } ;") ;
679
- config . AppendLine ( $ "self.config.offline_files = ['{ WebAppBasePath } ', { offlineFiles } ];") ;
680
- config . AppendLine ( $ "self.config.uno_shell_mode = \" { _shellMode } \" ;") ;
681
- config . AppendLine ( $ "self.config.uno_debugging_enabled = { ( ! Optimize ) . ToString ( ) . ToLowerInvariant ( ) } ;") ;
682
- config . AppendLine ( $ "self.config.uno_enable_tracing = { EnableTracing . ToString ( ) . ToLowerInvariant ( ) } ;") ;
683
- config . AppendLine ( $ "self.config.uno_load_all_satellite_resources = { LoadAllSatelliteResources . ToString ( ) . ToLowerInvariant ( ) } ;") ;
684
- config . AppendLine ( $ "self.config.emcc_exported_runtime_methods = [{ emccExportedRuntimeMethodsParams } ];") ;
672
+
673
+ if ( isModule )
674
+ {
675
+ config . AppendLine ( $ "let config = {{}};") ;
676
+ }
677
+ else
678
+ {
679
+ config . AppendLine ( $ "{ self } config = {{}};") ;
680
+ }
681
+
682
+ config . AppendLine ( $ "{ self } config.uno_remote_managedpath = \" _framework\" ;") ;
683
+ config . AppendLine ( $ "{ self } config.uno_app_base = \" { WebAppBasePath } { PackageAssetsFolder } \" ;") ;
684
+ config . AppendLine ( $ "{ self } config.uno_dependencies = [{ dependencies } ];") ;
685
+ config . AppendLine ( $ "{ self } config.uno_runtime_options = [{ runtimeOptionsSet } ];") ;
686
+ config . AppendLine ( $ "{ self } config.enable_pwa = { enablePWA . ToString ( ) . ToLowerInvariant ( ) } ;") ;
687
+ config . AppendLine ( $ "{ self } config.offline_files = ['{ WebAppBasePath } ', { offlineFiles } ];") ;
688
+ config . AppendLine ( $ "{ self } config.uno_shell_mode = \" { _shellMode } \" ;") ;
689
+ config . AppendLine ( $ "{ self } config.uno_debugging_enabled = { ( ! Optimize ) . ToString ( ) . ToLowerInvariant ( ) } ;") ;
690
+ config . AppendLine ( $ "{ self } config.uno_enable_tracing = { EnableTracing . ToString ( ) . ToLowerInvariant ( ) } ;") ;
691
+ config . AppendLine ( $ "{ self } config.uno_load_all_satellite_resources = { LoadAllSatelliteResources . ToString ( ) . ToLowerInvariant ( ) } ;") ;
692
+ config . AppendLine ( $ "{ self } config.emcc_exported_runtime_methods = [{ emccExportedRuntimeMethodsParams } ];") ;
685
693
686
694
if ( GenerateAOTProfile )
687
695
{
688
- config . AppendLine ( $ "self. config.generate_aot_profile = true;") ;
696
+ config . AppendLine ( $ "{ self } config.generate_aot_profile = true;") ;
689
697
}
690
698
691
- config . AppendLine ( $ "self. config.environmentVariables = self. config.environmentVariables || {{}};") ;
699
+ config . AppendLine ( $ "{ self } config.environmentVariables = { self } config.environmentVariables || {{}};") ;
692
700
693
- void AddEnvironmentVariable ( string name , string value ) => config . AppendLine ( $ "self. config.environmentVariables[\" { name } \" ] = \" { value } \" ;") ;
701
+ void AddEnvironmentVariable ( string name , string value ) => config . AppendLine ( $ "{ self } config.environmentVariables[\" { name } \" ] = \" { value } \" ;") ;
694
702
695
703
if ( MonoEnvironment != null )
696
704
{
@@ -722,6 +730,11 @@ private void GenerateConfigScript()
722
730
AddEnvironmentVariable ( "UNO_BOOTSTRAP_LOG_PROFILER_OPTIONS" , LogProfilerOptions ) ;
723
731
}
724
732
733
+ if ( isModule )
734
+ {
735
+ config . AppendLine ( "export { config };" ) ;
736
+ }
737
+
725
738
w . Write ( config . ToString ( ) ) ;
726
739
727
740
TaskItem indexMetadata = new (
0 commit comments