diff --git a/libs/native-federation/src/utils/updateIndexHtml.ts b/libs/native-federation/src/utils/updateIndexHtml.ts index e6378889..aaa726c0 100644 --- a/libs/native-federation/src/utils/updateIndexHtml.ts +++ b/libs/native-federation/src/utils/updateIndexHtml.ts @@ -55,6 +55,10 @@ export function updateScriptTags( ...nfOptions.esmsInitOptions, }; + // A module-shim main tag makes es-module-shims force shim mode back on, so + // an explicit shimMode: false must emit a real module script. + const mainType = esmsOptions.shimMode === false ? 'module' : 'module-shim'; + const htmlFragment = ` `; @@ -65,7 +69,7 @@ export function updateScriptTags( ); indexContent = indexContent.replace( /]*><\/script>/, - '', + ``, ); indexContent = indexContent.replace(/()/, `$1\n\t\t${htmlFragment}`);