@moneko/core 4.0.8-beta.1 → 4.0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,relative as t}from"node:path";import r from"webpack";import o from"../commom/module-resolve.mjs";import s from"../commom/paths.mjs";import{CONFIG as m}from"../config.mjs";import a from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as l}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as
|
|
1
|
+
import{join as e,relative as t}from"node:path";import r from"webpack";import o from"../commom/module-resolve.mjs";import s from"../commom/paths.mjs";import{CONFIG as m}from"../config.mjs";import a from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as l}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as i}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as p}from"./external-remotes.mjs";let n=r.NormalModuleReplacementPlugin,h=r.container.ModuleFederationPlugin,f={},u=[],c=m.moduleFederation?.map(r=>{let m={},p={},n={};if(Array.isArray(r.remotes))for(let e=0,t=r.remotes.length;e<t;e++){let t=r.remotes[e],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(p[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)f[t.library[e]]=`${o}/${t.library[e]}`;a(t.host,t.name)}if(Array.isArray(r.exposes)){r.exposes.length>0&&!r.exposes.find(e=>"public-path"===e)&&r.exposes.push({name:"public-path",path:`./${t(s.programPath,e(s.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,t=r.exposes.length;e<t;e++){let t=r.exposes[e];if("string"==typeof t){let e=t.startsWith(".");m[`./${t}`]=o(e?l(t):t),e&&(n[t]=m[`./${t}`])}else if("[object Object]"===Object.prototype.toString.call(t)){let e=t.path.startsWith(".");m[`./${t.name}`]=o(e?l(t.path):t.path),e&&(n[`./${t.name}`]=m[`./${t.name}`])}}r.exposes?.length&&u.push(new i({exposes:n,name:r.name}))}return new h({filename:"remote_entry.js",...r,remotes:p,exposes:m})});c.length>0&&(c.push(new p),c.push(new n(/(.*)/,e=>{f[e.request]&&(e.request=f[e.request])})),u.forEach(e=>c.push(e))),m.env.injectRemoteReactRefresh=Object.keys(f).includes("react-dom");export default c;
|
package/lib/vm/dts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as e}from"node:path";import{updateFile as t,updateFileSync as o}from"@moneko/utils";import s from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import{readJson as r}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as n,CACHE_NAME as i,FRAMEWORK as d,framework as p,frameworkVersionStr as l,packageJson as f,SSR as v,virtual_schema as u}from"../process-env.mjs";import c from"../utils/create-types.mjs";import{generateDeclaration as j}from"../utils/dts.mjs";import{convertToCamelCase as $,transformModule as y}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",i,"index.d.ts");export const vm_dts=new m({});vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");t(dts_path,e)});export function initDts(t){let m=c(`${a}:env`,j(y(t.env),`${a}:env`));vm_dts.setData(`${a}:env`,m);let _=c(`${a}:info`,j(y({...r(e(s.programPath,"package.json")),projectName:$(f.name),ssr:v,type:n,frameworkVersion:l,framework:p,base:t.basename,routerMode:t.routerMode,prefixCls:t.prefixCls,theme:t.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,_),t.virtualModule&&Object.keys(t.virtualModule).map(e=>{let o=y(t.virtualModule[e]),s=`${u}:${e}`;vm_dts.setData(s,c(s,j(o,s)))});let h=t.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);o(dts_path,Object.values(vm_dts.data).join("\n")),o(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${i}/index.d.ts`,...h.map(e=>`@types/${i}/${e}.d.ts`)]}}))}
|