@moneko/core 3.0.0-beta.122 → 3.0.0-beta.124

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,2 @@
1
+ declare const appEntry: string;
2
+ export default appEntry;
@@ -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 t}from"./common.js";import{FRAMEWORK as r,isMicro as e}from"./process-env.js";import{getExportTokens as m}from"./utils.js";let i=p(t.alias["@"],"./index.ts"),s=o(i),_="",u=`const renderApp = (await import('@moneko/${r}/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";`}t.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 bootstrap() {console.log('app bootstraped');}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=`${t.normalizeCss?`import "@moneko/${r}/lib/normalize.css";`:""}${_}${u}`;export default l;
@@ -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{resolve 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])})));
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 resolve: (url: string) => string;
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 e}from"fs";import o from"path";import{transformFileSync as t}from"@swc/core";import{cacheDir as r}from"./process-env.js";import n from"./resolver-sync.js";let c={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return t(e,c).code||"{}"}export function readConf(t,n){let c=o.join(r,`${n}.mjs`);return e(c,tfc(t),"utf-8"),import(c)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(e){return o.resolve(process.cwd(),`./${e}`)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const resolve=e=>n.resolveSync({},process.cwd(),e)||e;export function isObject(e){let o=typeof e;return null!==e&&("object"==o||"function"==o)}export function isFunction(e){if(!isObject(e))return!1;let o=Object.prototype.toString.call(e);return"[object Function]"==o||"[object AsyncFunction]"==o||"[object GeneratorFunction]"==o||"[object Proxy]"==o}
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}
@@ -1 +1 @@
1
- import{accessSync as o,constants as p,existsSync as t}from"fs";import{join as e}from"path";import r from"./app.js";import n from"./common/rem.js";import{CONFIG as a}from"./common.js";import{coverage as m}from"./coverage.js";import{FRAMEWORK as s,isMicro as i}from"./process-env.js";import{resolveProgramPath as l}from"./utils.js";let c=t(e(a.alias["@"],"./index.ts")),u=`const renderApp = (await import('@moneko/${s}/lib/entry.js')).default;`,_="",f=u;c&&(_=`import ${i?"{mount as appMount,unmount as appUnMount} from ":""}"@/index.ts";`),a.rem?.designSize&&(_+=n),i?(_+="if (window.__POWERED_BY_QIANKUN__) {__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;}",f+=`if (!window.__POWERED_BY_QIANKUN__) {renderApp();}let unmountInstance = void 0;export async function mount(props) {${c?"appMount?.(props);":""}unmountInstance = renderApp(props);}export async function unmount(props) {${c?"appUnMount?.(props);":""}unmountInstance();}`):f+="renderApp();";let d={...a.virtualModule,"@app":r,"@app/fallback":"export default null","@app/coverage":m,"@app/entry":`${a.normalizeCss?`import "@moneko/${s}/lib/normalize.css";`:""}${_}${f}`};a.fallbackCompPath&&Object.assign(d,{"@app/fallback":`import Fallback from "${a.fallbackCompPath}";export default Fallback;`});let b={};try{let t=e(l("site"),"./mdx-scope.ts");o(t,p.R_OK),b='import scope from "@/mdx-scope";export default scope;'}catch(o){b={}}Object.assign(d,{"@app/mdx-scope":b});export default d;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.0.0-beta.122",
3
+ "version": "3.0.0-beta.124",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",