@moneko/core 4.4.4-beta.0 → 4.4.4
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/plugin/exposes-declararion.mjs +1 -1
- package/lib/plugins.config.mjs +1 -1
- package/lib/process-env.d.mts +1 -0
- package/lib/process-env.mjs +1 -1
- package/lib/vm/mf.d.mts +3 -0
- package/lib/vm/mf.mjs +1 -0
- package/package.json +1 -1
- package/typings/global.d.ts +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,parse as t,resolve as s}from"node:path";import{fileURLToPath as
|
|
1
|
+
import{join as e,parse as t,resolve as o,sep as s}from"node:path";import{fileURLToPath as i}from"node:url";import{Worker as r}from"node:worker_threads";import{fileExists as a,loadFile as n}from"@moneko/utils";import m from"webpack";import{module_federation_schema as p}from"../process-env.mjs";import l from"../utils/create-types.mjs";import{mf_vm as h}from"../vm/mf.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new r(i(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(i){let{exposes:r}=this.option,d=Object.keys(r).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:o(`types/${this.option.name}/${t}.d.ts`),originPath:r[e]}});i.hooks.thisCompilation.tap({name:this.name,stage:i.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},o=>{o.hooks.processAssets.tapPromise(this.name,async()=>{let i=d.map(async o=>{if(a(o.originPath)){let i=t(o.originPath),r=`export * from '${t(i.dir).name}/${i.name}'`;if("public-path"===i.name){let e=await n(o.originPath.replace(/\.mjs$/,".d.mts"));e&&(r=e)}return h.setData(o.name,{type:".tsx",source:()=>`export * from '${t(i.dir).name}/${i.name}'`}),[l(e(this.option.name,o.name),r),l(e(p,this.option.name,o.name).replace(s,":"),r)].join("\n")}return""}),r=await Promise.all(i);r.unshift(this.dts),o.emitAsset("module-federation.d.ts",new m.sources.RawSource(r.join("\n")),{javascriptModule:!1})})})}}
|
package/lib/plugins.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"webpack";import{CompressionPlugin as t}from"./plugin/compression.mjs";import{CopyPlugin as o}from"./plugin/copy.mjs";import{CssModuleDtsPlugin as i}from"./plugin/css-module-dts.mjs";import{HtmlPlugin as r}from"./plugin/html-plugin.mjs";import{ManifestPlugin as n}from"./plugin/manifest/index.mjs";import p from"./plugin/module-federation.mjs";import{VirtualModulePlugin as
|
|
1
|
+
import e from"webpack";import{CompressionPlugin as t}from"./plugin/compression.mjs";import{CopyPlugin as o}from"./plugin/copy.mjs";import{CssModuleDtsPlugin as i}from"./plugin/css-module-dts.mjs";import{HtmlPlugin as r}from"./plugin/html-plugin.mjs";import{ManifestPlugin as n}from"./plugin/manifest/index.mjs";import p from"./plugin/module-federation.mjs";import{VirtualModulePlugin as m}from"./plugin/virtual-module.mjs";import{app_vm as s}from"./vm/app.mjs";import{docs_vm as l}from"./vm/docs.mjs";import{example_vm as a}from"./vm/example.mjs";import{mf_vm as c}from"./vm/mf.mjs";import{scope_vm as h}from"./vm/scope.mjs";import{sw_vm as f}from"./vm/sw.mjs";import{virtual_vm as u}from"./vm/virtual.mjs";import{CONFIG as g}from"./config.mjs";import{app_schema as d,docs_schema as w,example_schema as j,isLibrary as v,module_federation_schema as b,packageJson as y,scope_schema as x,service_worker_schema as P,virtual_schema as O}from"./process-env.mjs";let k="object"==typeof g.compression?g.compression:{},R=[...p,new m(c,b),new m(s,d),new m(f,P),v&&new m(l,w),v&&new m(a,j),v&&new m(h,x),g.virtualModule&&new m(u,O),new o(g.copy),new e.EnvironmentPlugin(g.env),new e.DefinePlugin({"process.env":JSON.stringify(g.env)}),new e.IgnorePlugin({resourceRegExp:/\.d\.tsx?$/,contextRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),new i,...g.plugins].filter(Boolean);if(g.compression&&R.push(new t({algorithm:g.devServer.https?"brotli":"gzip",test:/\.(js|css|html|svg|ttf|woff|woff2|png|jpg|jpeg)$/,...k})),g.manifest&&R.push(new n(g.manifest)),g.htmlPluginOption){let e={charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no","mobile-web-app-capable":"yes",renderer:"webkit",description:y.description,keywords:Array.isArray(y.keywords)?y.keywords.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};g.seo&&(e.relCanonical={rel:"canonical",href:`https://${g.seo.domain}${g.basename}`}),g.htmlPluginOption.meta&&Object.assign(e,g.htmlPluginOption.meta),R.push(new r({...g.htmlPluginOption,meta:e}))}if(g.fixBrowserRouter){let e=g.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=g.fixBrowserRouter.pathSegmentsToKeep??e;R.push(new r({filename:g.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${o};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}))}g.sourceMap&&R.push(new e.SourceMapDevToolPlugin(g.sourceMap));export default R;
|
package/lib/process-env.d.mts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const docs_schema = 'docs';
|
|
|
19
19
|
export declare const example_schema = 'example';
|
|
20
20
|
export declare const scope_schema = 'scope';
|
|
21
21
|
export declare const service_worker_schema = 'sw';
|
|
22
|
+
export declare const module_federation_schema = 'mf';
|
|
22
23
|
/** 项目主要文件夹 */ export declare const mainDirectory: 'site' | 'src';
|
|
23
24
|
export declare const jsxImportSource: string;
|
|
24
25
|
export declare const framework: 'react' | 'solid-js';
|
package/lib/process-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{CUSTOMCONFIG as s}from"./commom/paths.mjs";import{readJson as t}from"./commom/read-json.mjs";import{convertToCamelCase as c,digest as
|
|
1
|
+
import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{CUSTOMCONFIG as s}from"./commom/paths.mjs";import{readJson as t}from"./commom/read-json.mjs";import{convertToCamelCase as c,digest as m}from"./utils/index.mjs";export const packageJson=t(`${o.cwd()}/package.json`);delete packageJson.scripts;export const IS_WINDOW="win32"===o.platform;export const APPTYPE=o.env.APPTYPE;export const FRAMEWORK=o.env.FRAMEWORK??"react";export const NODE_ENV=o.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===o.env.SSR;export const app_schema="app";export const virtual_schema="vm";export const docs_schema="docs";export const example_schema="example";export const scope_schema="scope";export const service_worker_schema="sw";export const module_federation_schema="mf";export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=framework?t(`${framework}/package.json`).version:19;export const frameworkVersion=parseFloat(frameworkVersionStr);export const PACKAGENAME=packageJson.name;export const projectNameCamelCase=c(PACKAGENAME);export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&e("solid"===FRAMEWORK?"solid-refresh":"react-refresh"));export const isCI=r();export const CACHE_NAME=m(`${PACKAGENAME}${s}${NODE_ENV}${o.argv[2]}`);
|
package/lib/vm/mf.d.mts
ADDED
package/lib/vm/mf.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import m from"../commom/reactive-object.mjs";export const mf_vm=new m({});
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -583,14 +583,18 @@ declare interface HttpUriOptions {
|
|
|
583
583
|
}
|
|
584
584
|
|
|
585
585
|
type ModuleFederationPluginOption = ConstructorParameters<typeof container.ModuleFederationPlugin>[number];
|
|
586
|
-
|
|
586
|
+
|
|
587
|
+
type RequiredModuleFederationPluginOption = Required<ModuleFederationPluginOption>;
|
|
588
|
+
type LibraryOption = RequiredModuleFederationPluginOption['library'];
|
|
589
|
+
interface LibraryOptions extends LibraryOption {
|
|
590
|
+
type: 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system';
|
|
591
|
+
}
|
|
592
|
+
export declare interface ModuleFederationOption extends Omit<ModuleFederationPluginOption, 'remotes' | 'exposes' | 'library'> {
|
|
587
593
|
/** 模块名称,唯一性,不能重名 */
|
|
588
594
|
name: string;
|
|
589
595
|
/** 打包的模块文件名 默认: remote_entry.js */
|
|
590
596
|
filename?: string;
|
|
591
|
-
library?:
|
|
592
|
-
type: 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system';
|
|
593
|
-
};
|
|
597
|
+
library?: LibraryOptions;
|
|
594
598
|
/** 表示作为 Host 时, 去消费哪些 Remote */
|
|
595
599
|
remotes?: {
|
|
596
600
|
/** 远程模块名称 */
|