@moneko/core 4.4.4-beta.4 → 4.4.4-beta.6

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,3 +1,8 @@
1
+ /**
2
+ * 提取 typescript 代码中以 mf: 开头的模块声明
3
+ * @param content - typescript 代码的内容
4
+ * @returns 去除 mf: 前缀后的模块名数组
5
+ */ export declare function extractMfModules(content: string): string[];
1
6
  /**
2
7
  * 根据ts内容生成声明类型
3
8
  * @param {String} source 源码内容
package/lib/utils/dts.mjs CHANGED
@@ -1 +1 @@
1
- import e from"typescript";import t from"../commom/rule.mjs";let i={declaration:!0,emitDeclarationOnly:!0,target:e.ScriptTarget.ESNext,skipLibCheck:!0,checkJs:!1,skipDefaultLibCheck:!0,noResolve:!0,types:[],noEmitOnError:!1,noImplicitAny:!1,noImplicitThis:!1,noImplicitReturns:!1,noUnusedLocals:!1,noUnusedParameters:!1,noFallthroughCasesInSwitch:!1,strictNullChecks:!1,strictFunctionTypes:!1,strictBindCallApply:!1,strictPropertyInitialization:!1,strict:!1};export function generateDeclaration(r,a){let s=(t.js.test(a)?a:`${a}.ts`).replace(/^\.+/,""),n="";return e.createProgram([s],i,{getSourceFile:t=>{if(t===s)return e.createSourceFile(t,r,i.target)},writeFile:(e,t)=>{e.endsWith(".d.ts")&&(n=t)},getDefaultLibFileName:()=>"lib.d.ts",getCurrentDirectory:()=>"",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>"\n",fileExists:()=>!0,readFile:()=>"",directoryExists:()=>!0,getDirectories:()=>[]}).emit(),n}export function getExportKeys(t,i){let r=new Set;for(let a of e.createSourceFile(i,t,e.ScriptTarget.Latest,!0).statements)if(e.isExportDeclaration(a)){if(a.exportClause&&e.isNamedExports(a.exportClause))for(let e of a.exportClause.elements)r.add(e.name.text)}else if(e.isExportAssignment(a))r.add("default");else if((e.isVariableStatement(a)||e.isFunctionDeclaration(a)||e.isClassDeclaration(a))&&a.modifiers?.some(t=>t.kind===e.SyntaxKind.ExportKeyword)){if(e.isFunctionDeclaration(a)||e.isClassDeclaration(a))a.name&&r.add(a.name.text);else if(e.isVariableStatement(a))for(let t of a.declarationList.declarations)e.isIdentifier(t.name)&&r.add(t.name.text)}return Array.from(r)}
1
+ import e from"typescript";import t from"../commom/rule.mjs";let i={declaration:!0,emitDeclarationOnly:!0,target:e.ScriptTarget.ESNext,skipLibCheck:!0,checkJs:!1,skipDefaultLibCheck:!0,noResolve:!0,types:[],noEmitOnError:!1,noImplicitAny:!1,noImplicitThis:!1,noImplicitReturns:!1,noUnusedLocals:!1,noUnusedParameters:!1,noFallthroughCasesInSwitch:!1,strictNullChecks:!1,strictFunctionTypes:!1,strictBindCallApply:!1,strictPropertyInitialization:!1,strict:!1};export function extractMfModules(t){let i=e.createSourceFile("temp.ts",t,e.ScriptTarget.Latest,!0),r=[];return!function t(i){if(e.isModuleDeclaration(i)){let e=i.name.text;if(e.startsWith("mf:")){let t=e.substring(3);r.push(t)}}e.forEachChild(i,t)}(i),r}export function generateDeclaration(r,a){let s=(t.js.test(a)?a:`${a}.ts`).replace(/^\.+/,""),n="";return e.createProgram([s],i,{getSourceFile:t=>{if(t===s)return e.createSourceFile(t,r,i.target)},writeFile:(e,t)=>{e.endsWith(".d.ts")&&(n=t)},getDefaultLibFileName:()=>"lib.d.ts",getCurrentDirectory:()=>"",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>"\n",fileExists:()=>!0,readFile:()=>"",directoryExists:()=>!0,getDirectories:()=>[]}).emit(),n}export function getExportKeys(t,i){let r=new Set;for(let a of e.createSourceFile(i,t,e.ScriptTarget.Latest,!0).statements)if(e.isExportDeclaration(a)){if(a.exportClause&&e.isNamedExports(a.exportClause))for(let e of a.exportClause.elements)r.add(e.name.text)}else if(e.isExportAssignment(a))r.add("default");else if((e.isVariableStatement(a)||e.isFunctionDeclaration(a)||e.isClassDeclaration(a))&&a.modifiers?.some(t=>t.kind===e.SyntaxKind.ExportKeyword)){if(e.isFunctionDeclaration(a)||e.isClassDeclaration(a))a.name&&r.add(a.name.text);else if(e.isVariableStatement(a))for(let t of a.declarationList.declarations)e.isIdentifier(t.name)&&r.add(t.name.text)}return Array.from(r)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.4.4-beta.4",
3
+ "version": "4.4.4-beta.6",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -115,7 +115,8 @@
115
115
  "default": "./lib/lint/stylelint/config.mjs"
116
116
  }
117
117
  },
118
- "./package.json": "./package.json"
118
+ "./package.json": "./package.json",
119
+ "./lib/polyfills/public-path.mjs": "./lib/polyfills/public-path.mjs"
119
120
  },
120
121
  "keywords": [
121
122
  "moneko",
@@ -145,8 +146,8 @@
145
146
  "less-loader": "12.3.0",
146
147
  "lightningcss": "1.30.2",
147
148
  "marked-completed": "1.2.15",
148
- "memfs": "4.51.1",
149
- "swc-loader": "0.2.6",
149
+ "memfs": "4.52.0",
150
+ "swc-loader": "0.2.7",
150
151
  "typescript": "5.9.3",
151
152
  "webpack": "5.104.1",
152
153
  "webpack-hot-middleware": "2.26.1",
@@ -1,3 +0,0 @@
1
- import { type WebpackPluginInstance } from 'webpack';
2
- declare const moduleFederation: WebpackPluginInstance[];
3
- export default moduleFederation;
@@ -1 +0,0 @@
1
- import{join as e,parse as t,relative as r}from"node:path";import o from"webpack";import m from"../commom/module-resolve.mjs";import s from"../commom/paths.mjs";import{CONFIG as a}from"../config.mjs";import i from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as l}from"../utils/index.mjs";import{mf_vm as n}from"../vm/mf.mjs";import{ModuleFederationExposesDeclarationPlugin as p}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as f}from"./external-remotes.mjs";let h=o.NormalModuleReplacementPlugin,c=o.container.ModuleFederationPlugin,u={},d=[];function y(e,r){let o=e.replace(/\.tsx?$/i,""),m=t(r);n.setData(o,{type:".tsx",source:()=>`export * from '${t(m.dir).name}/${m.name}'`})}let j=a.moduleFederation?.map(t=>{let o={},a={},n={};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(a[o]=`${r.name}@${r.host}/${m}`,Array.isArray(r.library))for(let e=0,t=r.library.length;e<t;e++)u[r.library[e]]=`${o}/${r.library[e]}`;i(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(s.programPath,e(s.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?l(r):r),e&&(n[r]=o[`./${r}`],y(r,n[r]))}else if("[object Object]"===Object.prototype.toString.call(r)){let e=r.path.startsWith(".");o[`./${r.name}`]=m(e?l(r.path):r.path),e&&(n[`./${r.name}`]=o[`./${r.name}`],y(`./${r.name}`,n[`./${r.name}`]))}}t.exposes?.length&&d.push(new p({exposes:n,name:t.name}))}return new c({filename:"remote_entry.js",...t,remotes:a,exposes:o})});j.length>0&&(j.push(new f),j.push(new h(/(.*)/,e=>{u[e.request]&&(e.request=u[e.request])})),d.forEach(e=>j.push(e))),a.env.injectRemoteReactRefresh=Object.keys(u).includes("react-dom");export default j;