@moneko/core 4.4.4-beta.7 → 4.4.4-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join as e,parse as t,relative as r,sep as o}from"node:path";import s from"webpack";import m from"../commom/module-resolve.mjs";import a from"../commom/paths.mjs";import{CONFIG as l}from"../config.mjs";import n from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as p}from"../utils/index.mjs";import{mf_vm as i}from"../vm/mf.mjs";import{ModuleFederationExposesDeclarationPlugin as f}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as h}from"./external-remotes.mjs";let u=s.NormalModuleReplacementPlugin,c=s.container.ModuleFederationPlugin,d={},$=[];function x(e,r){let s=e.replaceAll(o,"/").replace(/\.tsx?$/i,""),m=t(r);i.setData(s,{type:".tsx",source:()=>{if(r.startsWith(a.nodeModules)){let e=r.substring(a.nodeModules.length).split("node_modules").pop()?.replaceAll(o,"/").replace(/^\//,"");return`export * from '${e}';`}return r.startsWith(l.alias["@"])?`export * from '@/${t(m.dir).name}/${m.name}'`:"export {};"}})}let y=l.moduleFederation?.map(t=>{let o={},s={},l={};if(Array.isArray(t.remotes))for(let e=0,r=t.remotes.length;e<r;e++){let r=t.remotes[e],o=r.alias||r.name,m=r.filename||"remote_entry.js";if(s[o]=`${r.name}@${r.host}/${m}`,Array.isArray(r.library))for(let e=0,t=r.library.length;e<t;e++)d[r.library[e]]=`${o}/${r.library[e]}`;n(r.host,r.name)}if(Array.isArray(t.exposes)){t.exposes.length>0&&!t.exposes.find(e=>"public-path"===e)&&t.exposes.push({name:"public-path",path:`./${r(a.programPath,e(a.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,r=t.exposes.length;e<r;e++){let r=t.exposes[e];if("string"==typeof r){let e=r.startsWith(".");o[`./${r}`]=m(e?p(r):r),e&&(l[r]=o[`./${r}`],x(`${t.name}/${r}`,l[r]))}else if("[object Object]"===Object.prototype.toString.call(r)){let e=r.path.startsWith(".");o[`./${r.name}`]=m(e?p(r.path):r.path),e&&(l[`./${r.name}`]=o[`./${r.name}`],x(`${t.name}/${r.name}`,l[`./${r.name}`]))}}t.exposes?.length&&$.push(new f({exposes:l,name:t.name}))}return new c({filename:"remote_entry.js",...t,remotes:s,exposes:o})});y.length>0&&(y.push(new h),y.push(new u(/(.*)/,e=>{d[e.request]&&(e.request=d[e.request])})),$.forEach(e=>y.push(e))),l.env.injectRemoteReactRefresh=Object.keys(d).includes("react-dom");export default y;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function fetchModuleFederationDts(host: string, name: string): Promise<
|
|
1
|
+
declare function fetchModuleFederationDts(host: string, name: string): Promise<void>;
|
|
2
2
|
export default fetchModuleFederationDts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{request as t}from"@moneko/request";import{updateFile as
|
|
1
|
+
import{request as t}from"@moneko/request";import{updateFile as o}from"@moneko/utils";import r from"../commom/log.mjs";import{CACHE_NAME as m}from"../process-env.mjs";import{mf_vm as e}from"../vm/mf.mjs";import{extractMfModules as s}from"./dts.mjs";import{node_modules as p}from"./index.mjs";async function i(i,f){try{let r=`${i.startsWith("//")?`http:${i}`:i}/module-federation.d.ts`,a=await t(r,{responseType:"text",rejectUnauthorized:!1});s(a).forEach(t=>{e.has(t)||e.setData(t,{type:".ts",source:()=>`export * from '${t}'`})}),o(p(`@types/${m}/${f}.d.ts`),a)}catch(t){r(t)}}export default i;
|