You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importfederationfrom"@originjs/vite-plugin-federation";importtopLevelAwaitfrom"vite-plugin-top-level-await";exportdefaultasync({ command, mode })=>{constconfig={build: {minify: "terser",// 是否进行压缩,boolean | 'terser' | 'esbuild',默认使用tersermanifest: false,// 是否产出manifest.jsonsourcemap: false,// 是否产出sourcemap.jsonoutDir: "dist/child/power",// 产出目录rollupOptions: {output: {format: "esm",},},},plugins: [federation({name: "remote-gm-system-web",filename: "remoteEntry.js",exposes: {"./mediaLibDrawer": "./src/components/mediaLibDrawer/index.vue",},shared: {vue: {generate: false,},},}),topLevelAwait({// The export name of top-level await promise for each chunk modulepromiseExportName: "__tla",// The function to generate import names of top-level await promise in each chunk modulepromiseImportName: (i)=>`__tla_${i}`,}),],};returnconfig;};
then run vite build, vite preview
The generated remoteEntry.js is as follows
exportfunction__vite_legacy_guard(){import.meta.url,import("_").catch((()=>1))}System.register(["./preload-helper-legacy-f8638e03.js"],(function(e,t){"use strict";varr;return{setters:[e=>{r=e._}],execute:function(){consts=newSet(["Module","__esModule","default","_export_sfc"]);leto={"./mediaLibDrawer":()=>(i([],!1,"./mediaLibDrawer"),asyncfunction(e){returnr((()=>t.import(e)),void0)}("./__federation_expose_MediaLibDrawer-legacy-8170543b.js").then((e=>Object.keys(e).every((e=>s.has(e)))?()=>e.default:()=>e)))};constn={},i=e("dynamicLoadingCss",((e,r,s)=>{consto=t.meta.url;if(void0===o)returnvoidconsole.warn('The remote style takes effect only when the build.target option in the vite.config.ts file is higher than that of "es2020".');consti=o.substring(0,o.lastIndexOf("remoteEntry.js"));e.forEach((e=>{constt=i+e;if(!(tinn))if(n[t]=!0,r){conste="css__remote-gm-system-web__"+s;null==window[e]&&(window[e]=[]),window[e].push(t)}else{conste=document.head.appendChild(document.createElement("link"));e.href=t,e.rel="stylesheet"}}))}));e("get",(e=>{if(!o[e])thrownewError("Can not find remote module "+e);returno[e]()})),e("init",(e=>{globalThis.__federation_shared__=globalThis.__federation_shared__||{},Object.entries(e).forEach((([e,t])=>{constr=Object.keys(t)[0],s=Object.values(t)[0],o=s.scope||"default";globalThis.__federation_shared__[o]=globalThis.__federation_shared__[o]||{};constn=globalThis.__federation_shared__[o];(n[e]=n[e]||{})[r]=s}))}))}}}));
Dude, where did you get the System js.Didn’t I already set Format as ESM? This code will report an error in the host application
:System is not defined.
then I try to set build.target as esnext, Still the same error
The text was updated successfully, but these errors were encountered:
Versions
my remote app vite.config.js
then run
vite build
,vite preview
The generated remoteEntry.js is as follows
Dude, where did you get the
System js
.Didn’t I already set Format as ESM? This code will report an error in the host application:System is not defined.
then I try to set build.target as
esnext
, Still the same errorThe text was updated successfully, but these errors were encountered: