@moneko/core 3.0.0-beta.121 → 3.0.0-beta.123
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.
- package/lib/app-entry.d.ts +2 -0
- package/lib/app-entry.js +1 -0
- package/lib/module-federation.js +1 -1
- package/lib/utils.d.ts +6 -1
- package/lib/utils.js +1 -1
- package/lib/virtual-modules.js +1 -1
- package/package.json +1 -1
package/lib/app-entry.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as o}from"fs";import{join as p}from"path";import n from"./common/rem.js";import{CONFIG as r}from"./common.js";import{FRAMEWORK as t,isMicro as e}from"./process-env.js";import{getExportTokens as m}from"./utils.js";let i=p(r.alias["@"],"./index.ts"),s=o(i),_="",u=`const renderApp = (await import('@moneko/${t}/lib/entry.js')).default;`,a=[];if(s){let o="";e&&(a=m(i).filter(Boolean)).length&&(o=`{${a.map(o=>`${o} as app${o}`).join(",")}} from `),_=`import ${o}"@/index.ts";`}r.rem?.designSize&&(_+=n),e?(_+="if (window.__POWERED_BY_QIANKUN__) {__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;}",u+=`if (!window.__POWERED_BY_QIANKUN__) {renderApp();}let unmountApp = void 0;export async function mount(props) {${a.includes("mount")?"appmount(props);":""}unmountApp = renderApp(props);}export async function unmount(props) {${a.includes("unmount")?"appunmount(props);":""}unmountApp();}`):u+="renderApp();";let l=`${r.normalizeCss?`import "@moneko/${t}/lib/normalize.css";`:""}${_}${u}`;export default l;
|
package/lib/module-federation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{
|
|
1
|
+
import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{realResolve as l}from"./utils.js";let a=r.NormalModuleReplacementPlugin,i={},m={},n={};export const moduleFederation=o.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,l=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)i[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?m[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(m[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:n,exposes:m})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new a(/(.*)/,e=>{i[e.request]&&(e.request=i[e.request])})));
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/** 获取导出标识
|
|
2
|
+
* @param {string} path 文件地址
|
|
3
|
+
* @returns {string[]} 包含的标识
|
|
4
|
+
*/
|
|
5
|
+
export declare function getExportTokens(path: string): string[];
|
|
1
6
|
export declare function tfc(filepath: string): string;
|
|
2
7
|
export declare function readConf(src: string, name: string): Promise<any>;
|
|
3
8
|
export declare function toUpperCaseString(string: string): string;
|
|
@@ -17,7 +22,7 @@ export declare const resolveNodeModulesPath: <T extends string>(src: T) => `${`n
|
|
|
17
22
|
* @param {string} url 路径
|
|
18
23
|
* @returns {string} 模块真实入口路径
|
|
19
24
|
*/
|
|
20
|
-
export declare const
|
|
25
|
+
export declare const realResolve: (url: string) => string;
|
|
21
26
|
export declare function isObject(target: unknown): target is object;
|
|
22
27
|
export declare function isFunction(target: unknown): target is (...args: unknown[]) => unknown;
|
|
23
28
|
export {};
|
package/lib/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{readFileSync as e,writeFileSync as t}from"fs";import{join as o,resolve as r}from"path";import{transformFileSync as n}from"@swc/core";import{cacheDir as c}from"./process-env.js";import s from"./resolver-sync.js";let p=/export\s+(?:async\s+)?(?:function|const)\s+(\w+)/g;export function getExportTokens(t){let o;let r=e(t,{encoding:"utf-8"}),n=[];for(;o=p.exec(r);)n.includes(o[1])||n.push(o[1]);return n}let u={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return n(e,u).code||"{}"}export function readConf(e,r){let n=o(c,`${r}.mjs`);return t(n,tfc(e),"utf-8"),import(n)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(e){return r(process.cwd(),`./${e}`)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const realResolve=e=>s.resolveSync({},process.cwd(),e)||e;export function isObject(e){let t=typeof e;return null!==e&&("object"==t||"function"==t)}export function isFunction(e){if(!isObject(e))return!1;let t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t||"[object GeneratorFunction]"==t||"[object Proxy]"==t}
|
package/lib/virtual-modules.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as
|
|
1
|
+
import{accessSync as p,constants as o}from"fs";import{join as a}from"path";import t from"./app-entry.js";import r from"./app.js";import{CONFIG as e}from"./common.js";import{coverage as m}from"./coverage.js";import{resolveProgramPath as l}from"./utils.js";let c={...e.virtualModule,"@app":r,"@app/fallback":"export default null","@app/coverage":m,"@app/entry":t};e.fallbackCompPath&&Object.assign(c,{"@app/fallback":`import Fallback from "${e.fallbackCompPath}";export default Fallback;`});let f={};try{let t=a(l("site"),"./mdx-scope.ts");p(t,o.R_OK),f='import scope from "@/mdx-scope";export default scope;'}catch(p){f={}}Object.assign(c,{"@app/mdx-scope":f});export default c;
|