@empjs/cli 3.1.0-rc.8 → 3.1.0-rc.9
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/dist/index.cjs +16 -16
- package/dist/index.d.cts +2 -129
- package/dist/index.d.ts +2 -129
- package/dist/index.js +16 -16
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)};cyan=e=>{console.log(`${
|
|
3
|
-
`)};magenta=e=>{console.log(`${
|
|
4
|
-
`)};green=e=>{console.log(`${
|
|
5
|
-
`)};yellow=e=>{console.log(`${
|
|
6
|
-
`)};red=e=>{console.log(`${
|
|
7
|
-
`)};sysError=e=>{console.log(`${
|
|
8
|
-
`)};link=e=>
|
|
9
|
-
`)}},
|
|
10
|
-
`)),this.sf.isOpenBrower&&
|
|
11
|
-
`);return he(i)},K=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,As(),{name:void 0}).apply(e)}}});var Q,bt=h(()=>{"use strict";a();y();we();Oe();Q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await _.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(K),this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var vt,Pe,Ct,wt=h(()=>{"use strict";a();vt=l(require("fs"),1);I();it();C();z();ut();gt();bt();Pe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new q;empShareLib=new W;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new Q(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(O.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,n={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(n,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{t==="all"?(s[`import.meta.env.${r}`]=JSON.stringify(e[r]),s[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?s[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?s[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(s[`${r}`]=JSON.stringify(e[r]))}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return g({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){p.time("[store][empConfig]SyncEmpOptions");let e=await st();if(!e||!vt.default.existsSync(e))return;let t=await tt(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},p.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Ct=new Pe});var xt,ke,St,Et=h(()=>{"use strict";a();xt=l(require("fs-extra"),1),ke=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await xt.default.exists(e)){let s={tsConfig:e};this.store.merge({resolve:s})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},St=new ke});var Me,Ot,Pt=h(()=>{"use strict";a();Me=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,s={},{sass:r}=this.store.empConfig.css||{sass:{}};r.mode==="modern"&&(s.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),s.api=r.api?r.api:"legacy",s.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(s.sassOptions=r.sassOptions)),typeof r.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(s.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:s}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,s={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:s},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Ot=new Me});var w,kt,$e,Mt,$t=h(()=>{"use strict";a();w=l(require("path"),1),kt=l(require("html-webpack-plugin"),1);I();C();Oe();$e=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e.tags=e.tags||{},e}setChunk(e){return e.replace(w.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.default.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(w.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),n=[s];this.entriesConfig[r]={entry:{[r]:n},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=n}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(kt.default,[e]),this.store.empConfig.empShareLib&&(e.files=g(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`${this.store.chainName.plugin.html.empSharePrefix}${t}`).use(X,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`${this.store.chainName.plugin.html.importMapPrefix}${t}`).use(V,[this.store.empConfig.empShareLib.importMap,t])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){p.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=w.default.join(this.store.appSrc,e),s=w.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,M.glob)([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${w.default.sep}`,"")),r.map(n=>{let c=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...c},w.default.join(t,n))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]SetDefaultEntry");let e=w.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,M.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let s=w.default.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}p.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},Mt=new $e});var je,Le,jt,Lt=h(()=>{"use strict";a();je=l(require("path"),1);C();Le=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return this.store.empConfig.build.polyfill}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:g(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfillInclude)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",je.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=je.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:s}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},[t.sourceMap]:{test:/\.[tj]sx?$/,enforce:"pre",use:{[s.sourceMap]:{loader:require.resolve("source-map-loader")}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},jt=new Le});var De,Dt,T,Re,Rt,Tt=h(()=>{"use strict";a();De=l(require("fs"),1),Dt=require("@module-federation/enhanced/rspack"),T=l(require("@rspack/core"),1),Re=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare(),this.minify(),this.redoctor()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(T.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");De.default.existsSync(e)&&De.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(T.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(T.default.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=Dt.ModuleFederationPlugin;this.store.chain.plugin(this.store.chainName.plugin.empShare).use(t,[this.store.empConfig.empShareLib.pluginConfig])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(T.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(T.default.LightningCssMinimizerRspackPlugin,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}},Rt=new Re});var Te,At,Ft=h(()=>{"use strict";a();Et();Pt();$t();Lt();Tt();Te=class{store;async setup(e){this.store=e;let t=[St.setup(this.store),jt.setup(this.store),Rt.setup(this.store),Mt.setup(this.store),Ot.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},At=new Te});var Nt,x,It,zt,Ae,o,y=h(()=>{"use strict";a();Nt=l(require("fs/promises"),1),x=l(require("path"),1),It=l(require("util"),1);E();C();wt();Ft();zt=l(require("webpack-chain"),1);Se();Ae=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.default.resolve(__dirname,__filename).replace(`${x.default.sep}dist${x.default.sep}index.js`,"");empSource=x.default.resolve(this.empRoot,"dist");resolve=e=>x.default.isAbsolute(e)?e:x.default.resolve(this.root,e);empResolve=e=>x.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=G;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=me;deepAssign=g;getLanIp=N;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=Ct,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new zt.default,await At.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),p.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let s=require(this.empResolve("package.json")),r=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.resource.dir=x.default.join(this.empRoot,"resource"),this.resource.cert=x.default.join(this.resource.dir,"emp.cert"),this.resource.key=x.default.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=x.default.join(this.root,this.debug.showRsconfig);Nt.default.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?g(e,this.debug.showRsconfig):e;console.log(p.link("[Compile Config]")),console.log(It.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}},o=new Ae});function Us(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,c)=>{let d=t[c],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(j.bold(s))}async function Ut(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>zs(u.name)).map(Hs);s.sort((u,F)=>u.size-F.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+P.default.sep+u.name).length));Us(n,r);let c=0,d=0;s.forEach(u=>{let{sizeLabel:F}=u,{name:ls,folder:cs,gzipSizeLabel:ms}=u,Be=(cs+P.default.sep+ls).length,Je=F.length;if(c+=u.size,d+=u.gzippedSize,Je<r){let re=" ".repeat(r-Je);F+=re}let _e=L(u.folder+P.default.sep)+Bs(u.name);if(Be<n){let re=" ".repeat(n-Be);_e+=re}p.info(` ${_e} ${L(F)} ${ms}`)});let v=`${j.bold("Total size:")} ${Z(c)}`,A=`${j.bold("Gzipped size:")} ${Z(d)}`;p.info(`
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
`),
|
|
15
|
-
`)}function
|
|
1
|
+
"use strict";var ts=Object.create;var U=Object.defineProperty;var ss=Object.getOwnPropertyDescriptor;var is=Object.getOwnPropertyNames;var rs=Object.getPrototypeOf,os=Object.prototype.hasOwnProperty;var m=(i,e)=>()=>(i&&(e=i(i=0)),e);var D=(i,e)=>{for(var t in e)U(i,t,{get:e[t],enumerable:!0})},ze=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of is(e))!os.call(i,r)&&r!==t&&U(i,r,{get:()=>e[r],enumerable:!(s=ss(e,r))||s.enumerable});return i};var l=(i,e,t)=>(t=i!=null?ts(rs(i)):{},ze(e||!i||!i.__esModule?U(t,"default",{value:i,enumerable:!0}):t,i)),ns=i=>ze(U({},"__esModule",{value:!0}),i);var n=m(()=>{"use strict"});var d,as,x,ps,ls,cs,ee,B,ms,fs,j,te,hs,se,R,h,L=m(()=>{"use strict";n();d=l(require("chalk"),1),as=d.default.hex("#1abc9c"),x=d.default.hex("#16a085"),ps=d.default.hex("#2ecc71"),ls=d.default.hex("#27ae60"),cs=d.default.hex("#e74c3c"),ee=d.default.hex("#c0392b"),B=d.default.hex("#f1c40f"),ms=d.default.hex("#f39c12"),fs=d.default.hex("#3498db"),j=d.default.hex("#2980b9"),te=d.default.hex("#ecf0f1"),hs=d.default.hex("#fd79a8"),se=d.default.hex("#e84393"),R=d.default.hex("#7f8c8d"),h={lightGreen:as,green:x,lightCyan:ps,cyan:ls,lightRed:cs,red:ee,yellow:B,orange:ms,lightBlue:fs,blue:j,white:te,lightMagenta:hs,magenta:se,gray:R}});var ie,a,S=m(()=>{"use strict";n();L();ie=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
|
|
2
|
+
`)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
|
|
3
|
+
`)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
|
|
4
|
+
`)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
|
|
5
|
+
`)};yellow=e=>{console.log(`${h.yellow(this.brandName)}${h.orange(` ${e} `)}
|
|
6
|
+
`)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
|
|
7
|
+
`)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
|
|
8
|
+
`)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
|
|
9
|
+
`)}},a=new ie});var pe={};D(pe,{clearConsole:()=>oe,deepAssign:()=>y,ensureArray:()=>us,getLanIp:()=>M,getPkgVersion:()=>re,importJsVm:()=>ae,jsonFilter:()=>gs,timeFormat:()=>I,vCompare:()=>ne});function oe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(i,...e){for(let t of e)for(let s in t){let r=t[s],p=i[s];if(Object(r)==r&&Object(p)===p){i[s]=y(p,r);continue}i[s]=t[s]}return i}var Ge,Ue,Be,Ie,M,re,us,gs,ne,I,ae,C=m(()=>{"use strict";n();Ge=require("address"),Ue=l(require("chalk"),1),Be=require("default-gateway"),Ie=l(require("fs-extra"),1),M=()=>{let{int:i}=(0,Be.gateway4sync)();return(0,Ge.ip)(i||"")||"127.0.0.1"},re=i=>{try{let{version:e}=Ie.default.readJSONSync(i);return e}catch{return}};us=i=>Array.isArray(i)?i:[i],gs=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),ne=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),p=0;for(let f=0;f<r;f++){let g=t.length>f?t[f]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),N=s.length>f?s[f]:0,u=isNaN(Number(N))?N.charCodeAt():Number(N);if(O<u){p=-1;break}else if(O>u){p=1;break}}return p},I=i=>{i=i/1e3;let e=s=>Ue.default.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},ae=i=>`data:text/javascript,${i}`});var le={};D(le,{chalk:()=>He.default,color:()=>h,glob:()=>$.glob,logger:()=>a,utils:()=>pe});var He,$,z=m(()=>{"use strict";n();He=l(require("chalk"),1),$=require("glob");L();C();S()});var Je,_e,We,ds,qe,Ve,ys,Xe=m(()=>{"use strict";n();Je=l(require("fs"),1),_e=l(require("path"),1),We=l(require("jiti"),1);v();S();ds=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],qe=(0,We.default)(__filename,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Ve=async()=>ys(),ys=()=>{a.time("[store]GetEmpConfigPath");let i;for(let e of ds){let t=_e.default.resolve(o.root,e);if(Je.default.existsSync(t)){i=t;break}}return a.timeEnd("[store]GetEmpConfigPath"),i}});async function H(i,e="localhost"){if(i!==vs&&(i<Qe||i>ce))throw new Error(`Port number must lie between ${Qe} and ${ce}`);let t=i,s=bs(),r;e&&!s.has(e)?r=new Set([e]):r=s;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=ce;)try{return await Cs(t,r)}catch(f){if(!p.has(f.code))throw f;t+=1}throw new Error("No available ports found")}var Ke,Ye,Qe,ce,vs,bs,ws,Cs,me=m(()=>{"use strict";n();Ke=l(require("net"),1),Ye=l(require("os"),1),Qe=1024,ce=65535,vs=443,bs=()=>{let i=Ye.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},ws=(i,e)=>new Promise((t,s)=>{let r=Ke.default.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:p}=r.address();r.close(()=>{t(p)})})}),Cs=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await ws(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});var fe,Ze,he,A,ue=m(()=>{"use strict";n();fe=l(require("url"),1),Ze=l(require("chalk"),1);L();C();he=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:R("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",s;if(t){s="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp=M;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return fe.default.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return fe.default.format({protocol:t,hostname:e,port:Ze.default.bold(s),pathname:r})}},A=new he});var tt,st,it,et,xs,Ss,rt,ot=m(()=>{"use strict";n();tt=require("child_process"),st=require("util");v();S();it=(0,st.promisify)(tt.exec),et=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],xs=async()=>{let i=process.env.BROWSER;if(!i||!et.includes(i)){let{stdout:e}=await it("ps cax");i=et.find(t=>e.includes(t))}return i},Ss=async i=>{if(process.platform==="darwin")try{let t=await xs();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await it(s,{cwd:o.resource.dir}),!0}}catch(t){a.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return a.error("Failed to open start URL."),a.error(t),!1}},rt=Ss});var ge,J,de=m(()=>{"use strict";n();me();ue();C();v();ge=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=o.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!o.empOptions.autoDevBase&&o.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=o.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=A.getLanIp(),r=this.isHttps?"https":"http",p=o.empOptions.server?.port||8e3;p=await H(p,s),o.empOptions.base=`${r}://${s}:${p}/`,o.empOptions.server=y({port:p,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${p}/ws`}},o.empOptions.server)}},J=new ge});var ye,E,G=m(()=>{"use strict";n();ye=l(require("fs/promises"),1);L();me();ue();S();ot();C();v();de();E=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};static httpsType="default";async adaptServer(){this.sf.publicPath=o.rsConfig.output?.publicPath==="auto"?"/":o.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!o.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=o.empConfig.server.host?o.empConfig.server.host:this.sf.host,this.sf.port=o.empConfig.server.port,await this.serverPort(),A.setup(this.sf),this.sf.publicPath&&(this.sf.publicPath.indexOf("http://")>-1||this.sf.publicPath.indexOf("https://")>-1)?(this.sf.url=this.sf.publicPath,this.sf.publicHasHttp=!0,this.sf.urls.localUrlForTerminal=A.prettyPrintUrl("localhost")):(this.sf.urls=A.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(a.info(`${x("\u279C")} Local: ${a.link(e.localUrlForTerminal)}`),a.info(`${x("\u279C")} Network: ${a.link(this.sf.publicPath)}`)):(a.info(`${x("\u279C")} Local: ${a.link(e.localUrlForTerminal)}`),a.info(`${x("\u279C")} Network: ${a.link(e.lanUrlForTerminal)}
|
|
10
|
+
`)),this.sf.isOpenBrower&&rt(this.sf.url)}async setup(e,t){a.time(`[${e}]Setup`),await o.setup(e,t),o.debug.clearLog&&oe(),a.title(`${e}`),await this.adaptServer(),a.time(`[${e}]Run`),await this.run(),a.timeEnd(`[${e}]Run`),this.afterRun(),a.timeEnd(`[${e}]Setup`)}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{server:e,https:t,http2:s}=o.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0||s===!0}getcert(){return Promise.all([ye.default.readFile(o.resource.key),ye.default.readFile(o.resource.cert)])}async serverPort(){if(J.isADB)return;let{port:e,host:t}=this.sf,s=await H(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var _,nt=m(()=>{"use strict";n();C();v();_=class{constructor(){}getPolyfillEntry(){let e=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
|
|
11
|
+
`);return ae(e)}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,this.getPolyfillEntry(),{name:void 0}).apply(e)}}});var W,at=m(()=>{"use strict";n();v();de();nt();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await J.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(_),this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var pt,ve,lt,ct=m(()=>{"use strict";n();pt=l(require("fs"),1);z();Xe();C();G();at();ve=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(e,t)}isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(E.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{t==="all"?(s[`import.meta.env.${r}`]=JSON.stringify(e[r]),s[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?s[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?s[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(s[`${r}`]=JSON.stringify(e[r]))}),s}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){a.time("[store][empConfig]SyncEmpOptions");let e=await Ve();if(!e||!pt.default.existsSync(e))return;let t=await qe(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},a.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},lt=new ve});var mt,be,ft,ht=m(()=>{"use strict";n();mt=l(require("fs-extra"),1),be=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await mt.default.exists(e)){let s={tsConfig:e};this.store.merge({resolve:s})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},ft=new be});var we,ut,gt=m(()=>{"use strict";n();we=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,s={},{sass:r}=this.store.empConfig.css||{sass:{}};r.mode==="modern"&&(s.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),s.api=r.api?r.api:"legacy",s.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(s.sassOptions=r.sassOptions)),typeof r.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(s.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:s}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,s={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:s},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},ut=new we});var b,dt,Es,Ce,yt,vt=m(()=>{"use strict";n();b=l(require("path"),1),dt=require("@rspack/core");z();Es=dt.rspack.HtmlRspackPlugin,Ce=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e}setChunk(e){return e.replace(b.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${b.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(b.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),p=[s];this.entriesConfig[r]={entry:{[r]:p},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(Es,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){a.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=b.default.join(this.store.appSrc,e),s=b.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,$.glob)([s],{windowsPathsNoEscape:!0});r=r.map(p=>p.replace(`${t}${b.default.sep}`,"")),r.map(p=>{let f=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...f},b.default.join(t,p))}),a.timeEnd("setAutoPage")}async setDefaultEntry(){a.time("[store][empConfig]SetDefaultEntry");let e=b.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,$.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let s=b.default.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}a.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},yt=new Ce});var xe,Se,bt,wt=m(()=>{"use strict";n();xe=l(require("path"),1);C();Se=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return this.store.empConfig.build.polyfill}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:y(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfillInclude)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",xe.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=re(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=xe.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:s}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},[t.sourceMap]:{test:/\.[tj]sx?$/,enforce:"pre",use:{[s.sourceMap]:{loader:require.resolve("source-map-loader")}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},bt=new Se});var Ee,F,Oe,Ct,xt=m(()=>{"use strict";n();Ee=l(require("fs"),1),F=l(require("@rspack/core"),1),Oe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(F.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Ee.default.existsSync(e)&&Ee.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(F.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(F.default.ProgressPlugin,[{prefix:"EMP"}])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(F.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(F.default.LightningCssMinimizerRspackPlugin,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}},Ct=new Oe});var Pe,St,Et=m(()=>{"use strict";n();ht();gt();vt();wt();xt();Pe=class{store;async setup(e){this.store=e;let t=[ft.setup(this.store),bt.setup(this.store),Ct.setup(this.store),yt.setup(this.store),ut.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},St=new Pe});var Ot,Pt=m(()=>{"use strict";n();Ot={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var kt,w,$t,Dt,ke,o,v=m(()=>{"use strict";n();kt=l(require("fs/promises"),1),w=l(require("path"),1),$t=l(require("util"),1);S();C();ct();Et();Dt=l(require("webpack-chain"),1);Pt();ke=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=w.default.resolve(__dirname,__filename).replace(`${w.default.sep}dist${w.default.sep}index.js`,"");empSource=w.default.resolve(this.empRoot,"dist");resolve=e=>w.default.isAbsolute(e)?e:w.default.resolve(this.root,e);empResolve=e=>w.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Ot;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=ne;deepAssign=y;getLanIp=M;entries={};debug;async setup(e,t){a.time("[store]Setup"),await this.initVars(e,t),this.empConfig=lt,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Dt.default,await St.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),a.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let s=require(this.empResolve("package.json")),r=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.resource.dir=w.default.join(this.empRoot,"resource"),this.resource.cert=w.default.join(this.resource.dir,"emp.cert"),this.resource.key=w.default.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),a.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=w.default.join(this.root,this.debug.showRsconfig);kt.default.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(a.link("[Compile Config]")),console.log($t.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}},o=new ke});function Rs(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,p,f)=>{let g=t[f],O=p;return g&&(O=p.length<g?p+" ".repeat(g-p.length):p),`${r+O} `}," ");console.log(j.bold(s))}async function Lt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>$s(u.name)).map(js);s.sort((u,T)=>u.size-T.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),p=Math.max(...s.map(u=>(u.folder+P.default.sep+u.name).length));Rs(p,r);let f=0,g=0;s.forEach(u=>{let{sizeLabel:T}=u,{name:Yt,folder:Zt,gzipSizeLabel:es}=u,Ne=(Zt+P.default.sep+Yt).length,Te=T.length;if(f+=u.size,g+=u.gzippedSize,Te<r){let Z=" ".repeat(r-Te);T+=Z}let Me=R(u.folder+P.default.sep)+Ls(u.name);if(Ne<p){let Z=" ".repeat(p-Ne);Me+=Z}a.info(` ${Me} ${R(T)} ${es}`)});let O=`${j.bold("Total size:")} ${q(f)}`,N=`${j.bold("Gzipped size:")} ${q(g)}`;a.info(`
|
|
12
|
+
${O}
|
|
13
|
+
${N}
|
|
14
|
+
`),a.info(`${x("\u2713")} Ready in ${I(Number(e.time))}
|
|
15
|
+
`)}function V(i=0){a.info(`${x("\u2713")} Ready in ${I(Number(i))}`)}var jt,P,Rt,Os,Ps,ks,$s,Ds,js,q,Ls,X=m(()=>{"use strict";n();jt=l(require("fs"),1),P=l(require("path"),1),Rt=require("gzip-size");L();v();S();C();Os=/\.html$/,Ps=/\.(?:js|mjs|cjs|jsx)$/,ks=/\.css$/,$s=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Ds=i=>i>300*1e3?ee:i>100*1e3?B:te,js=i=>{let e=i.name.split("?")[0],t=q(i.size),s=P.default.basename(e),r=P.default.join(P.default.basename(o.empConfig.build.outDir),P.default.dirname(e)),p=jt.default.readFileSync(P.default.join(o.empConfig.build.outDir,e)),f=p.length,g=(0,Rt.gzipSizeSync)(p),O=Ds(g)(q(g));return{size:f,folder:r,name:s,gzippedSize:g,sizeLabel:t,gzipSizeLabel:O}};q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ls=i=>Ps.test(i)?B(i):ks.test(i)?x(i):Os.test(i)?j(i):se(i)});var Nt={};D(Nt,{default:()=>As});var At,Ft,$e,As,Tt=m(()=>{"use strict";n();At=require("@rspack/core"),Ft=require("@rspack/dev-server");X();S();C();G();v();$e=class extends E{get rspackDevConfig(){return y(o.rsConfig,{stats:{all:o.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}})}async devServerConfig(){let e=Object.assign({},o.rsConfig.devServer);if(this.isHttps&&(e.https===!0&&delete e.https,!e.server)){let[t,s]=await this.getcert();e.server={type:"https",options:{key:t,cert:s}}}return e}async run(){let e=(0,At.rspack)(this.rspackDevConfig);if(!o.rsConfig.devServer){a.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Ft.RspackDevServer(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=p=>{let f=p?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});V(f.time)};o.debug.showPerformance&&e.hooks.afterDone.tap("done",r),s.middleware?.waitUntilValid(p=>{o.debug.showPerformance||r(p),o.empConfig.lifeCycle.afterDevServe&&o.empConfig.lifeCycle.afterDevServe()})}},As=new $e});var Mt,zt,Gt,Ut,Q,Bt=m(()=>{"use strict";n();Mt=l(require("https"),1),zt=l(require("compression"),1),Gt=l(require("cors"),1),Ut=l(require("express"),1);G();Q=class extends E{app;async init(){let e=(0,Ut.default)();e.use((0,zt.default)()),e.use((0,Gt.default)()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();Mt.default.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:e,cert:t},this.app).listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}else this.app.listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var De={};D(De,{ServeScript:()=>K,default:()=>Fs});var It,Ht,Jt,_t,K,Fs,je=m(()=>{"use strict";n();It=l(require("fs"),1),Ht=l(require("fs/promises"),1),Jt=l(require("path"),1),_t=l(require("express"),1);X();S();v();Bt();K=class extends Q{timing=0;async run(){if(this.timing=Date.now(),!It.default.existsSync(o.outDir))return a.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(_t.default.static(e));let t=await Ht.default.readFile(Jt.default.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){V(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},Fs=new K});var qt={};D(qt,{default:()=>Ns});var Wt,Re,Ns,Vt=m(()=>{"use strict";n();Wt=require("@rspack/core");X();S();G();v();Re=class extends E{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(je(),De));await e.setup("serve",o.cliOptions)}async run(){await o.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!o.cliOptions.watch,this.isuseServe=!!o.cliOptions.serve,this.rspackConfig=o.rsConfig,this.isWatchMode&&this.watchMode(),(0,Wt.rspack)(this.rspackConfig,async(e,t)=>{if(e!==null){a.error(e.stack||e),e.message&&a.error(e.message);return}if(!t){a.red("Stats is Undefined.");return}t.hasErrors()&&(a.error(t.toString({all:!1,colors:!0,errors:!0})),a.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(a.yellow("Compiled with warnings."),a.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Lt(t),this.startServe(),await o.empConfig.lifeCycle.afterBulid()})}},Ns=new Re});var Us={};D(Us,{defineConfig:()=>Gs,dts:()=>Qt,empHelper:()=>le,rspack:()=>Kt.rspack,runScript:()=>Le,store:()=>o});module.exports=ns(Us);n();var Kt=require("@rspack/core");n();var Xt=l(require("process"),1),k=require("commander");v();function Le(){k.program.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),k.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Tt(),Nt));await e.setup("dev",i)}),k.program.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Vt(),qt));await e.setup("build",i)}),k.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async i=>{let{default:e}=await Promise.resolve().then(()=>(je(),De));await e.setup("serve",i)}),k.program.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(i=>{}),k.program.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(i=>{}),k.program.parse(Xt.default.argv)}n();var Ae=l(require("fs/promises"),1),Y=l(require("path"),1);z();v();var Ts=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Ms=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,zs=/import\(['"]([^;\n]+?)['"]\)/,Fe=class{list=[];outDir=o.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await(0,$.glob)([`${o.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=o.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await Ae.default.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Ts,r=>{let p=r.match(Ms);if(p||(p=r.match(zs)),p&&p[1]){let f=p[1];if(!f.startsWith("."))return r;let g=Y.default.resolve(Y.default.dirname(e),f).replace(this.outDir,this.aliasName);return r.replace(p[1],g)}return r});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
|
|
16
16
|
${t}}\r
|
|
17
|
-
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await
|
|
17
|
+
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await Ae.default.writeFile(Y.default.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Qt=new Fe;v();z();function Gs(i){return i}0&&(module.exports={defineConfig,dts,empHelper,rspack,runScript,store});
|
|
18
18
|
if (module.exports.default) module.exports = module.exports.default;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
import { InspectOptions } from 'node:util';
|
|
2
2
|
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
3
3
|
import * as _rspack_core from '@rspack/core';
|
|
4
|
-
import {
|
|
4
|
+
import { Output, Configuration, RspackOptions, Externals, Resolve, DevServer, SwcJsMinimizerRspackPluginOptions, LightningCssMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
|
|
5
5
|
export { rspack } from '@rspack/core';
|
|
6
6
|
import { Options } from 'sass-embedded';
|
|
7
|
-
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
8
7
|
import WPChain from 'webpack-chain';
|
|
9
|
-
export { default as HtmlWebpackPlugin } from 'html-webpack-plugin';
|
|
10
8
|
import * as chalk from 'chalk';
|
|
11
9
|
import chalk__default from 'chalk';
|
|
12
10
|
import { glob } from 'glob';
|
|
13
11
|
|
|
14
|
-
type externalAssetsType = {
|
|
15
|
-
js: string[];
|
|
16
|
-
css: string[];
|
|
17
|
-
};
|
|
18
|
-
type ModuleFederationPluginOptions = ConstructorParameters<typeof ModuleFederationPlugin>[0];
|
|
19
|
-
type ImportMapType = {
|
|
20
|
-
imports: {
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
declare class EMPShareLib {
|
|
25
|
-
externals: Configuration['externals'] | any;
|
|
26
|
-
externalAssets: externalAssetsType;
|
|
27
|
-
private exp;
|
|
28
|
-
config: EMPShareType;
|
|
29
|
-
importMap: ImportMapType;
|
|
30
|
-
isEmpshare: boolean;
|
|
31
|
-
setup(): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* 是否取用 importMap
|
|
34
|
-
*/
|
|
35
|
-
get useImportMap(): boolean | undefined;
|
|
36
|
-
get pluginConfig(): ModuleFederationPluginOptions;
|
|
37
|
-
prepareEsm(): void;
|
|
38
|
-
setShareLib(): Promise<void>;
|
|
39
|
-
private setExternalAssets;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type LifeCycleOptions = Partial<LifeCycle>;
|
|
43
13
|
declare class LifeCycle {
|
|
44
14
|
op: LifeCycleOptions;
|
|
@@ -126,24 +96,6 @@ declare namespace utils {
|
|
|
126
96
|
export { utils_clearConsole as clearConsole, utils_deepAssign as deepAssign, utils_ensureArray as ensureArray, utils_getLanIp as getLanIp, utils_getPkgVersion as getPkgVersion, utils_importJsVm as importJsVm, utils_jsonFilter as jsonFilter, utils_timeFormat as timeFormat, utils_vCompare as vCompare };
|
|
127
97
|
}
|
|
128
98
|
|
|
129
|
-
declare class EmpShareFastMode {
|
|
130
|
-
fastMode: Required<EMPShareFastModeType>;
|
|
131
|
-
externalMF: {
|
|
132
|
-
'@module-federation/runtime': string;
|
|
133
|
-
'@module-federation/sdk': string;
|
|
134
|
-
};
|
|
135
|
-
externalReact: {
|
|
136
|
-
react: string;
|
|
137
|
-
'react-dom': string;
|
|
138
|
-
'react-router-dom': string;
|
|
139
|
-
};
|
|
140
|
-
externals: any;
|
|
141
|
-
getRuntimeLib(runtimeHost: string): string;
|
|
142
|
-
setup(): void;
|
|
143
|
-
injectLib(): void;
|
|
144
|
-
setExternals(): void;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
99
|
declare class EmpConfig {
|
|
148
100
|
private store;
|
|
149
101
|
/**
|
|
@@ -166,8 +118,6 @@ declare class EmpConfig {
|
|
|
166
118
|
base: string;
|
|
167
119
|
target: RsTarget;
|
|
168
120
|
private assign;
|
|
169
|
-
empShareFastMode: EmpShareFastMode;
|
|
170
|
-
empShareLib: EMPShareLib;
|
|
171
121
|
/**
|
|
172
122
|
* 是否启动 esm 模块
|
|
173
123
|
* @default true
|
|
@@ -184,14 +134,13 @@ declare class EmpConfig {
|
|
|
184
134
|
get html(): HtmlType;
|
|
185
135
|
get entries(): EntriesType;
|
|
186
136
|
get server(): ServerType;
|
|
187
|
-
get empShare(): EMPShareType;
|
|
188
137
|
get css(): Required<EmpOptions['css']>;
|
|
189
138
|
get output(): Output;
|
|
190
139
|
get define(): {
|
|
191
140
|
[k: string]: string;
|
|
192
141
|
};
|
|
193
142
|
private setDefine;
|
|
194
|
-
get externals():
|
|
143
|
+
get externals(): {};
|
|
195
144
|
get resolve(): _rspack_core.ResolveOptions;
|
|
196
145
|
syncEmpOptions(): Promise<void>;
|
|
197
146
|
get moduleTransformRule(): any;
|
|
@@ -287,15 +236,8 @@ declare class GlobalStore {
|
|
|
287
236
|
define: string;
|
|
288
237
|
copy: string;
|
|
289
238
|
progress: string;
|
|
290
|
-
empShare: string;
|
|
291
239
|
html: {
|
|
292
240
|
prefix: string;
|
|
293
|
-
empSharePrefix: string;
|
|
294
|
-
importMapPrefix: string;
|
|
295
|
-
hooks: {
|
|
296
|
-
empShareLib: string;
|
|
297
|
-
importMap: string;
|
|
298
|
-
};
|
|
299
241
|
};
|
|
300
242
|
rsdoctor: string;
|
|
301
243
|
};
|
|
@@ -508,30 +450,6 @@ interface HtmlType extends HtmlRspackPluginOptions {
|
|
|
508
450
|
* @default src/favicon.ico
|
|
509
451
|
*/
|
|
510
452
|
favicon?: string;
|
|
511
|
-
/**
|
|
512
|
-
* 网站语言
|
|
513
|
-
*/
|
|
514
|
-
lang?: string;
|
|
515
|
-
/**
|
|
516
|
-
* externals 文件插入到html
|
|
517
|
-
*/
|
|
518
|
-
files?: {
|
|
519
|
-
/**
|
|
520
|
-
* 插入 css
|
|
521
|
-
*/
|
|
522
|
-
css?: string[];
|
|
523
|
-
/**
|
|
524
|
-
* 插入 js
|
|
525
|
-
*/
|
|
526
|
-
js?: string[];
|
|
527
|
-
};
|
|
528
|
-
/**
|
|
529
|
-
* 自定义 头部脚步内容 headTags[] bodyTags[]
|
|
530
|
-
*/
|
|
531
|
-
tags?: {
|
|
532
|
-
headTags?: any[];
|
|
533
|
-
bodyTags?: any[];
|
|
534
|
-
};
|
|
535
453
|
}
|
|
536
454
|
type EntriesType = {
|
|
537
455
|
[entryFilename: string]: HtmlType;
|
|
@@ -551,50 +469,6 @@ type CssSassOptionsType = {
|
|
|
551
469
|
mode?: 'default' | 'modern' | 'legacy';
|
|
552
470
|
implementation?: object | string;
|
|
553
471
|
};
|
|
554
|
-
type EMPShareFastModeType = {
|
|
555
|
-
/**
|
|
556
|
-
* 共享库目录 优先读取 runtimeLib
|
|
557
|
-
*/
|
|
558
|
-
runtimeHost?: string;
|
|
559
|
-
/**
|
|
560
|
-
* 共享库全路径
|
|
561
|
-
*/
|
|
562
|
-
runtimeLib?: string;
|
|
563
|
-
/**
|
|
564
|
-
* 额外的库添加
|
|
565
|
-
*/
|
|
566
|
-
externals?: any;
|
|
567
|
-
/**
|
|
568
|
-
* 当为 UMD时 暴露到 window 的全局变量
|
|
569
|
-
*/
|
|
570
|
-
globalVal?: string;
|
|
571
|
-
/**
|
|
572
|
-
* 默认支持React
|
|
573
|
-
*/
|
|
574
|
-
framework?: 'react' | '';
|
|
575
|
-
};
|
|
576
|
-
type EMPShareType = ModuleFederationPluginOptions & {
|
|
577
|
-
/**
|
|
578
|
-
* emp 基于库共享模块
|
|
579
|
-
*/
|
|
580
|
-
shareLib?: EMPshareLibItemType;
|
|
581
|
-
/**
|
|
582
|
-
* TODO
|
|
583
|
-
* 是否使用 importMap
|
|
584
|
-
*/
|
|
585
|
-
useImportMap?: boolean;
|
|
586
|
-
/**
|
|
587
|
-
* 快速模式
|
|
588
|
-
*/
|
|
589
|
-
fastMode?: EMPShareFastModeType;
|
|
590
|
-
};
|
|
591
|
-
type EMPshareLibItemType = {
|
|
592
|
-
[module: string]: {
|
|
593
|
-
entry: string;
|
|
594
|
-
global?: string;
|
|
595
|
-
type?: 'js' | 'css';
|
|
596
|
-
} | string | string[];
|
|
597
|
-
};
|
|
598
472
|
type RsTarget = Configuration['target'];
|
|
599
473
|
type AutoPagesType = {
|
|
600
474
|
/**
|
|
@@ -642,7 +516,6 @@ type EmpOptions = {
|
|
|
642
516
|
server?: ServerType;
|
|
643
517
|
debug?: DebugType;
|
|
644
518
|
chain?: (chain: WPChain) => void;
|
|
645
|
-
empShare?: EMPShareType;
|
|
646
519
|
/**
|
|
647
520
|
* css 相关设置
|
|
648
521
|
* @argument sass default {mode: 'modern'}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
import { InspectOptions } from 'node:util';
|
|
2
2
|
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
3
3
|
import * as _rspack_core from '@rspack/core';
|
|
4
|
-
import {
|
|
4
|
+
import { Output, Configuration, RspackOptions, Externals, Resolve, DevServer, SwcJsMinimizerRspackPluginOptions, LightningCssMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
|
|
5
5
|
export { rspack } from '@rspack/core';
|
|
6
6
|
import { Options } from 'sass-embedded';
|
|
7
|
-
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
8
7
|
import WPChain from 'webpack-chain';
|
|
9
|
-
export { default as HtmlWebpackPlugin } from 'html-webpack-plugin';
|
|
10
8
|
import * as chalk from 'chalk';
|
|
11
9
|
import chalk__default from 'chalk';
|
|
12
10
|
import { glob } from 'glob';
|
|
13
11
|
|
|
14
|
-
type externalAssetsType = {
|
|
15
|
-
js: string[];
|
|
16
|
-
css: string[];
|
|
17
|
-
};
|
|
18
|
-
type ModuleFederationPluginOptions = ConstructorParameters<typeof ModuleFederationPlugin>[0];
|
|
19
|
-
type ImportMapType = {
|
|
20
|
-
imports: {
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
declare class EMPShareLib {
|
|
25
|
-
externals: Configuration['externals'] | any;
|
|
26
|
-
externalAssets: externalAssetsType;
|
|
27
|
-
private exp;
|
|
28
|
-
config: EMPShareType;
|
|
29
|
-
importMap: ImportMapType;
|
|
30
|
-
isEmpshare: boolean;
|
|
31
|
-
setup(): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* 是否取用 importMap
|
|
34
|
-
*/
|
|
35
|
-
get useImportMap(): boolean | undefined;
|
|
36
|
-
get pluginConfig(): ModuleFederationPluginOptions;
|
|
37
|
-
prepareEsm(): void;
|
|
38
|
-
setShareLib(): Promise<void>;
|
|
39
|
-
private setExternalAssets;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type LifeCycleOptions = Partial<LifeCycle>;
|
|
43
13
|
declare class LifeCycle {
|
|
44
14
|
op: LifeCycleOptions;
|
|
@@ -126,24 +96,6 @@ declare namespace utils {
|
|
|
126
96
|
export { utils_clearConsole as clearConsole, utils_deepAssign as deepAssign, utils_ensureArray as ensureArray, utils_getLanIp as getLanIp, utils_getPkgVersion as getPkgVersion, utils_importJsVm as importJsVm, utils_jsonFilter as jsonFilter, utils_timeFormat as timeFormat, utils_vCompare as vCompare };
|
|
127
97
|
}
|
|
128
98
|
|
|
129
|
-
declare class EmpShareFastMode {
|
|
130
|
-
fastMode: Required<EMPShareFastModeType>;
|
|
131
|
-
externalMF: {
|
|
132
|
-
'@module-federation/runtime': string;
|
|
133
|
-
'@module-federation/sdk': string;
|
|
134
|
-
};
|
|
135
|
-
externalReact: {
|
|
136
|
-
react: string;
|
|
137
|
-
'react-dom': string;
|
|
138
|
-
'react-router-dom': string;
|
|
139
|
-
};
|
|
140
|
-
externals: any;
|
|
141
|
-
getRuntimeLib(runtimeHost: string): string;
|
|
142
|
-
setup(): void;
|
|
143
|
-
injectLib(): void;
|
|
144
|
-
setExternals(): void;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
99
|
declare class EmpConfig {
|
|
148
100
|
private store;
|
|
149
101
|
/**
|
|
@@ -166,8 +118,6 @@ declare class EmpConfig {
|
|
|
166
118
|
base: string;
|
|
167
119
|
target: RsTarget;
|
|
168
120
|
private assign;
|
|
169
|
-
empShareFastMode: EmpShareFastMode;
|
|
170
|
-
empShareLib: EMPShareLib;
|
|
171
121
|
/**
|
|
172
122
|
* 是否启动 esm 模块
|
|
173
123
|
* @default true
|
|
@@ -184,14 +134,13 @@ declare class EmpConfig {
|
|
|
184
134
|
get html(): HtmlType;
|
|
185
135
|
get entries(): EntriesType;
|
|
186
136
|
get server(): ServerType;
|
|
187
|
-
get empShare(): EMPShareType;
|
|
188
137
|
get css(): Required<EmpOptions['css']>;
|
|
189
138
|
get output(): Output;
|
|
190
139
|
get define(): {
|
|
191
140
|
[k: string]: string;
|
|
192
141
|
};
|
|
193
142
|
private setDefine;
|
|
194
|
-
get externals():
|
|
143
|
+
get externals(): {};
|
|
195
144
|
get resolve(): _rspack_core.ResolveOptions;
|
|
196
145
|
syncEmpOptions(): Promise<void>;
|
|
197
146
|
get moduleTransformRule(): any;
|
|
@@ -287,15 +236,8 @@ declare class GlobalStore {
|
|
|
287
236
|
define: string;
|
|
288
237
|
copy: string;
|
|
289
238
|
progress: string;
|
|
290
|
-
empShare: string;
|
|
291
239
|
html: {
|
|
292
240
|
prefix: string;
|
|
293
|
-
empSharePrefix: string;
|
|
294
|
-
importMapPrefix: string;
|
|
295
|
-
hooks: {
|
|
296
|
-
empShareLib: string;
|
|
297
|
-
importMap: string;
|
|
298
|
-
};
|
|
299
241
|
};
|
|
300
242
|
rsdoctor: string;
|
|
301
243
|
};
|
|
@@ -508,30 +450,6 @@ interface HtmlType extends HtmlRspackPluginOptions {
|
|
|
508
450
|
* @default src/favicon.ico
|
|
509
451
|
*/
|
|
510
452
|
favicon?: string;
|
|
511
|
-
/**
|
|
512
|
-
* 网站语言
|
|
513
|
-
*/
|
|
514
|
-
lang?: string;
|
|
515
|
-
/**
|
|
516
|
-
* externals 文件插入到html
|
|
517
|
-
*/
|
|
518
|
-
files?: {
|
|
519
|
-
/**
|
|
520
|
-
* 插入 css
|
|
521
|
-
*/
|
|
522
|
-
css?: string[];
|
|
523
|
-
/**
|
|
524
|
-
* 插入 js
|
|
525
|
-
*/
|
|
526
|
-
js?: string[];
|
|
527
|
-
};
|
|
528
|
-
/**
|
|
529
|
-
* 自定义 头部脚步内容 headTags[] bodyTags[]
|
|
530
|
-
*/
|
|
531
|
-
tags?: {
|
|
532
|
-
headTags?: any[];
|
|
533
|
-
bodyTags?: any[];
|
|
534
|
-
};
|
|
535
453
|
}
|
|
536
454
|
type EntriesType = {
|
|
537
455
|
[entryFilename: string]: HtmlType;
|
|
@@ -551,50 +469,6 @@ type CssSassOptionsType = {
|
|
|
551
469
|
mode?: 'default' | 'modern' | 'legacy';
|
|
552
470
|
implementation?: object | string;
|
|
553
471
|
};
|
|
554
|
-
type EMPShareFastModeType = {
|
|
555
|
-
/**
|
|
556
|
-
* 共享库目录 优先读取 runtimeLib
|
|
557
|
-
*/
|
|
558
|
-
runtimeHost?: string;
|
|
559
|
-
/**
|
|
560
|
-
* 共享库全路径
|
|
561
|
-
*/
|
|
562
|
-
runtimeLib?: string;
|
|
563
|
-
/**
|
|
564
|
-
* 额外的库添加
|
|
565
|
-
*/
|
|
566
|
-
externals?: any;
|
|
567
|
-
/**
|
|
568
|
-
* 当为 UMD时 暴露到 window 的全局变量
|
|
569
|
-
*/
|
|
570
|
-
globalVal?: string;
|
|
571
|
-
/**
|
|
572
|
-
* 默认支持React
|
|
573
|
-
*/
|
|
574
|
-
framework?: 'react' | '';
|
|
575
|
-
};
|
|
576
|
-
type EMPShareType = ModuleFederationPluginOptions & {
|
|
577
|
-
/**
|
|
578
|
-
* emp 基于库共享模块
|
|
579
|
-
*/
|
|
580
|
-
shareLib?: EMPshareLibItemType;
|
|
581
|
-
/**
|
|
582
|
-
* TODO
|
|
583
|
-
* 是否使用 importMap
|
|
584
|
-
*/
|
|
585
|
-
useImportMap?: boolean;
|
|
586
|
-
/**
|
|
587
|
-
* 快速模式
|
|
588
|
-
*/
|
|
589
|
-
fastMode?: EMPShareFastModeType;
|
|
590
|
-
};
|
|
591
|
-
type EMPshareLibItemType = {
|
|
592
|
-
[module: string]: {
|
|
593
|
-
entry: string;
|
|
594
|
-
global?: string;
|
|
595
|
-
type?: 'js' | 'css';
|
|
596
|
-
} | string | string[];
|
|
597
|
-
};
|
|
598
472
|
type RsTarget = Configuration['target'];
|
|
599
473
|
type AutoPagesType = {
|
|
600
474
|
/**
|
|
@@ -642,7 +516,6 @@ type EmpOptions = {
|
|
|
642
516
|
server?: ServerType;
|
|
643
517
|
debug?: DebugType;
|
|
644
518
|
chain?: (chain: WPChain) => void;
|
|
645
|
-
empShare?: EMPShareType;
|
|
646
519
|
/**
|
|
647
520
|
* css 相关设置
|
|
648
521
|
* @argument sass default {mode: 'modern'}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
|
|
2
|
-
var
|
|
3
|
-
`)};cyan=e=>{console.log(`${
|
|
4
|
-
`)};magenta=e=>{console.log(`${
|
|
5
|
-
`)};green=e=>{console.log(`${
|
|
6
|
-
`)};yellow=e=>{console.log(`${
|
|
7
|
-
`)};red=e=>{console.log(`${
|
|
8
|
-
`)};sysError=e=>{console.log(`${
|
|
9
|
-
`)};link=e=>
|
|
10
|
-
`)}},
|
|
11
|
-
`)),this.sf.isOpenBrower&&
|
|
12
|
-
`);return me(i)},K=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,ls(),{name:void 0}).apply(e)}}});var Q,tt=h(()=>{"use strict";a();y();be();Ce();Q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await _.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(K),this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});import cs from"fs";var we,st,it=h(()=>{"use strict";a();z();Be();w();I();Ke();Qe();tt();we=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new q;empShareLib=new W;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new Q(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(P.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,n={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(n,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{t==="all"?(s[`import.meta.env.${r}`]=JSON.stringify(e[r]),s[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?s[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?s[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(s[`${r}`]=JSON.stringify(e[r]))}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return g({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){p.time("[store][empConfig]SyncEmpOptions");let e=await He();if(!e||!cs.existsSync(e))return;let t=await Ge(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},p.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},st=new we});import ms from"fs-extra";var xe,rt,ot=h(()=>{"use strict";a();xe=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ms.exists(e)){let s={tsConfig:e};this.store.merge({resolve:s})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},rt=new xe});var Se,nt,at=h(()=>{"use strict";a();Se=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,s={},{sass:r}=this.store.empConfig.css||{sass:{}};r.mode==="modern"&&(s.implementation=r.implementation?r.implementation:C.resolve("sass-embedded"),s.api=r.api?r.api:"legacy",s.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(s.sassOptions=r.sassOptions)),typeof r.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(s.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:C.resolve("sass-loader"),options:s}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,s={loader:C.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:s},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},nt=new Se});import x from"path";import hs from"html-webpack-plugin";var Ee,pt,lt=h(()=>{"use strict";a();z();w();Ce();Ee=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e.tags=e.tags||{},e}setChunk(e){return e.replace(x.extname(e),"").replace(`${this.store.empConfig.appSrc}${x.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(x.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(x.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(x.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),n=[s];this.entriesConfig[r]={entry:{[r]:n},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=n}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(hs,[e]),this.store.empConfig.empShareLib&&(e.files=g(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`${this.store.chainName.plugin.html.empSharePrefix}${t}`).use(X,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`${this.store.chainName.plugin.html.importMapPrefix}${t}`).use(V,[this.store.empConfig.empShareLib.importMap,t])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){p.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=x.join(this.store.appSrc,e),s=x.join(t,"**","*.{ts,tsx,jsx,js}"),r=await D([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${x.sep}`,"")),r.map(n=>{let l=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...l},x.join(t,n))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]SetDefaultEntry");let e=x.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await D([e],{windowsPathsNoEscape:!0});if(t[0]){let s=x.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}p.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},pt=new Ee});import ct from"path";var Oe,mt,ht=h(()=>{"use strict";a();w();Oe=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return this.store.empConfig.build.polyfill}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:g(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfillInclude)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",ct.dirname(C.resolve("@swc/helpers/package.json"))),this.coreJs.path=C.resolve("core-js/package.json");let t=pe(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ct.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:s}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},[t.sourceMap]:{test:/\.[tj]sx?$/,enforce:"pre",use:{[s.sourceMap]:{loader:C.resolve("source-map-loader")}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},mt=new Oe});import ft from"fs";import{ModuleFederationPlugin as fs}from"@module-federation/enhanced/rspack";import H from"@rspack/core";var Pe,ut,gt=h(()=>{"use strict";a();Pe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare(),this.minify(),this.redoctor()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(H.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");ft.existsSync(e)&&ft.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(H.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(H.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=fs;this.store.chain.plugin(this.store.chainName.plugin.empShare).use(t,[this.store.empConfig.empShareLib.pluginConfig])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(H.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(H.LightningCssMinimizerRspackPlugin,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=C("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}},ut=new Pe});var ke,dt,yt=h(()=>{"use strict";a();ot();at();lt();ht();gt();ke=class{store;async setup(e){this.store=e;let t=[rt.setup(this.store),mt.setup(this.store),ut.setup(this.store),pt.setup(this.store),nt.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},dt=new ke});import us from"fs/promises";import S from"path";import gs from"util";import ds from"webpack-chain";var $e,o,y=h(()=>{"use strict";a();O();w();it();yt();ve();$e=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=S.resolve(m,c).replace(`${S.sep}dist${S.sep}index.js`,"");empSource=S.resolve(this.empRoot,"dist");resolve=e=>S.isAbsolute(e)?e:S.resolve(this.root,e);empResolve=e=>S.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=G;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=ce;deepAssign=g;getLanIp=N;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=st,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new ds,await dt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),p.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let s=C(this.empResolve("package.json")),r=C(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.resource.dir=S.join(this.empRoot,"resource"),this.resource.cert=S.join(this.resource.dir,"emp.cert"),this.resource.key=S.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=S.join(this.root,this.debug.showRsconfig);us.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?g(e,this.debug.showRsconfig):e;console.log(p.link("[Compile Config]")),console.log(gs.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}},o=new $e});import ys from"fs";import k from"path";import{gzipSizeSync as bs}from"gzip-size";function Os(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,l)=>{let d=t[l],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(M.bold(s))}async function bt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>xs(u.name)).map(Es);s.sort((u,A)=>u.size-A.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+k.sep+u.name).length));Os(n,r);let l=0,d=0;s.forEach(u=>{let{sizeLabel:A}=u,{name:Pt,folder:kt,gzipSizeLabel:$t}=u,Ae=(kt+k.sep+Pt).length,Fe=A.length;if(l+=u.size,d+=u.gzippedSize,Fe<r){let ie=" ".repeat(r-Fe);A+=ie}let Ne=j(u.folder+k.sep)+Ps(u.name);if(Ae<n){let ie=" ".repeat(n-Ae);Ne+=ie}p.info(` ${Ne} ${j(A)} ${$t}`)});let v=`${M.bold("Total size:")} ${Z(l)}`,R=`${M.bold("Gzipped size:")} ${Z(d)}`;p.info(`
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
`),
|
|
16
|
-
`)}function
|
|
2
|
+
var wt=Object.defineProperty;var b=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var m=(i,e)=>()=>(i&&(e=i(i=0)),e);var N=(i,e)=>{for(var t in e)wt(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as Ct}from"url";import xt from"path";var Re,St,c,l,n=m(()=>{"use strict";Re=()=>Ct(import.meta.url),St=()=>xt.dirname(Re()),c=St(),l=Re()});import d from"chalk";var Et,S,Ot,Pt,kt,Z,U,$t,Dt,D,ee,jt,te,j,h,R=m(()=>{"use strict";n();Et=d.hex("#1abc9c"),S=d.hex("#16a085"),Ot=d.hex("#2ecc71"),Pt=d.hex("#27ae60"),kt=d.hex("#e74c3c"),Z=d.hex("#c0392b"),U=d.hex("#f1c40f"),$t=d.hex("#f39c12"),Dt=d.hex("#3498db"),D=d.hex("#2980b9"),ee=d.hex("#ecf0f1"),jt=d.hex("#fd79a8"),te=d.hex("#e84393"),j=d.hex("#7f8c8d"),h={lightGreen:Et,green:S,lightCyan:Ot,cyan:Pt,lightRed:kt,red:Z,yellow:U,orange:$t,lightBlue:Dt,blue:D,white:ee,lightMagenta:jt,magenta:te,gray:j}});var se,a,E=m(()=>{"use strict";n();R();se=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
|
|
3
|
+
`)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
|
|
4
|
+
`)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
|
|
5
|
+
`)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
|
|
6
|
+
`)};yellow=e=>{console.log(`${h.yellow(this.brandName)}${h.orange(` ${e} `)}
|
|
7
|
+
`)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
|
|
8
|
+
`)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
|
|
9
|
+
`)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
|
|
10
|
+
`)}},a=new se});var ae={};N(ae,{clearConsole:()=>re,deepAssign:()=>y,ensureArray:()=>Tt,getLanIp:()=>M,getPkgVersion:()=>ie,importJsVm:()=>ne,jsonFilter:()=>Nt,timeFormat:()=>I,vCompare:()=>oe});import{ip as Rt}from"address";import Lt from"chalk";import{gateway4sync as At}from"default-gateway";import Ft from"fs-extra";function re(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(i,...e){for(let t of e)for(let s in t){let r=t[s],p=i[s];if(Object(r)==r&&Object(p)===p){i[s]=y(p,r);continue}i[s]=t[s]}return i}var M,ie,Tt,Nt,oe,I,ne,w=m(()=>{"use strict";n();M=()=>{let{int:i}=At();return Rt(i||"")||"127.0.0.1"},ie=i=>{try{let{version:e}=Ft.readJSONSync(i);return e}catch{return}};Tt=i=>Array.isArray(i)?i:[i],Nt=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),oe=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),p=0;for(let f=0;f<r;f++){let g=t.length>f?t[f]:0,P=isNaN(Number(g))?g.charCodeAt():Number(g),F=s.length>f?s[f]:0,u=isNaN(Number(F))?F.charCodeAt():Number(F);if(P<u){p=-1;break}else if(P>u){p=1;break}}return p},I=i=>{i=i/1e3;let e=s=>Lt.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},ne=i=>`data:text/javascript,${i}`});var Le={};N(Le,{chalk:()=>Mt,color:()=>h,glob:()=>L,logger:()=>a,utils:()=>ae});import Mt from"chalk";import{glob as L}from"glob";var z=m(()=>{"use strict";n();R();w();E()});import zt from"fs";import Gt from"path";import Bt from"jiti";var Ut,Ae,Fe,It,Te=m(()=>{"use strict";n();v();E();Ut=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],Ae=Bt(l,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Fe=async()=>It(),It=()=>{a.time("[store]GetEmpConfigPath");let i;for(let e of Ut){let t=Gt.resolve(o.root,e);if(zt.existsSync(t)){i=t;break}}return a.timeEnd("[store]GetEmpConfigPath"),i}});import Ht from"net";import Jt from"os";async function H(i,e="localhost"){if(i!==_t&&(i<Ne||i>pe))throw new Error(`Port number must lie between ${Ne} and ${pe}`);let t=i,s=Wt(),r;e&&!s.has(e)?r=new Set([e]):r=s;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=pe;)try{return await Vt(t,r)}catch(f){if(!p.has(f.code))throw f;t+=1}throw new Error("No available ports found")}var Ne,pe,_t,Wt,qt,Vt,le=m(()=>{"use strict";n();Ne=1024,pe=65535,_t=443,Wt=()=>{let i=Jt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},qt=(i,e)=>new Promise((t,s)=>{let r=Ht.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:p}=r.address();r.close(()=>{t(p)})})}),Vt=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await qt(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import Me from"url";import Xt from"chalk";var ce,A,me=m(()=>{"use strict";n();R();w();ce=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:j("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",s;if(t){s="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp=M;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Me.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Me.format({protocol:t,hostname:e,port:Xt.bold(s),pathname:r})}},A=new ce});import{exec as Qt}from"child_process";import{promisify as Kt}from"util";var Ge,ze,Yt,Zt,Be,Ue=m(()=>{"use strict";n();v();E();Ge=Kt(Qt),ze=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Yt=async()=>{let i=process.env.BROWSER;if(!i||!ze.includes(i)){let{stdout:e}=await Ge("ps cax");i=ze.find(t=>e.includes(t))}return i},Zt=async i=>{if(process.platform==="darwin")try{let t=await Yt();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Ge(s,{cwd:o.resource.dir}),!0}}catch(t){a.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return a.error("Failed to open start URL."),a.error(t),!1}},Be=Zt});var fe,J,he=m(()=>{"use strict";n();le();me();w();v();fe=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=o.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!o.empOptions.autoDevBase&&o.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=o.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=A.getLanIp(),r=this.isHttps?"https":"http",p=o.empOptions.server?.port||8e3;p=await H(p,s),o.empOptions.base=`${r}://${s}:${p}/`,o.empOptions.server=y({port:p,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${p}/ws`}},o.empOptions.server)}},J=new fe});import Ie from"fs/promises";var O,G=m(()=>{"use strict";n();R();le();me();E();Ue();w();v();he();O=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};static httpsType="default";async adaptServer(){this.sf.publicPath=o.rsConfig.output?.publicPath==="auto"?"/":o.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!o.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=o.empConfig.server.host?o.empConfig.server.host:this.sf.host,this.sf.port=o.empConfig.server.port,await this.serverPort(),A.setup(this.sf),this.sf.publicPath&&(this.sf.publicPath.indexOf("http://")>-1||this.sf.publicPath.indexOf("https://")>-1)?(this.sf.url=this.sf.publicPath,this.sf.publicHasHttp=!0,this.sf.urls.localUrlForTerminal=A.prettyPrintUrl("localhost")):(this.sf.urls=A.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(a.info(`${S("\u279C")} Local: ${a.link(e.localUrlForTerminal)}`),a.info(`${S("\u279C")} Network: ${a.link(this.sf.publicPath)}`)):(a.info(`${S("\u279C")} Local: ${a.link(e.localUrlForTerminal)}`),a.info(`${S("\u279C")} Network: ${a.link(e.lanUrlForTerminal)}
|
|
11
|
+
`)),this.sf.isOpenBrower&&Be(this.sf.url)}async setup(e,t){a.time(`[${e}]Setup`),await o.setup(e,t),o.debug.clearLog&&re(),a.title(`${e}`),await this.adaptServer(),a.time(`[${e}]Run`),await this.run(),a.timeEnd(`[${e}]Run`),this.afterRun(),a.timeEnd(`[${e}]Setup`)}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{server:e,https:t,http2:s}=o.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0||s===!0}getcert(){return Promise.all([Ie.readFile(o.resource.key),Ie.readFile(o.resource.cert)])}async serverPort(){if(J.isADB)return;let{port:e,host:t}=this.sf,s=await H(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var _,He=m(()=>{"use strict";n();w();v();_=class{constructor(){}getPolyfillEntry(){let e=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
|
|
12
|
+
`);return ne(e)}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,this.getPolyfillEntry(),{name:void 0}).apply(e)}}});var W,Je=m(()=>{"use strict";n();v();he();He();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await J.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(_),this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});import es from"fs";var ue,_e,We=m(()=>{"use strict";n();z();Te();w();G();Je();ue=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(e,t)}isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(O.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{t==="all"?(s[`import.meta.env.${r}`]=JSON.stringify(e[r]),s[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?s[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?s[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(s[`${r}`]=JSON.stringify(e[r]))}),s}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){a.time("[store][empConfig]SyncEmpOptions");let e=await Fe();if(!e||!es.existsSync(e))return;let t=await Ae(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},a.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},_e=new ue});import ts from"fs-extra";var ge,qe,Ve=m(()=>{"use strict";n();ge=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ts.exists(e)){let s={tsConfig:e};this.store.merge({resolve:s})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},qe=new ge});var de,Xe,Qe=m(()=>{"use strict";n();de=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,s={},{sass:r}=this.store.empConfig.css||{sass:{}};r.mode==="modern"&&(s.implementation=r.implementation?r.implementation:b.resolve("sass-embedded"),s.api=r.api?r.api:"legacy",s.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(s.sassOptions=r.sassOptions)),typeof r.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(s.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:b.resolve("sass-loader"),options:s}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,s={loader:b.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:s},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Xe=new de});import C from"path";import{rspack as ss}from"@rspack/core";var is,ye,Ke,Ye=m(()=>{"use strict";n();z();is=ss.HtmlRspackPlugin,ye=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e}setChunk(e){return e.replace(C.extname(e),"").replace(`${this.store.empConfig.appSrc}${C.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(C.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(C.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(C.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),p=[s];this.entriesConfig[r]={entry:{[r]:p},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(is,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){a.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=C.join(this.store.appSrc,e),s=C.join(t,"**","*.{ts,tsx,jsx,js}"),r=await L([s],{windowsPathsNoEscape:!0});r=r.map(p=>p.replace(`${t}${C.sep}`,"")),r.map(p=>{let f=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...f},C.join(t,p))}),a.timeEnd("setAutoPage")}async setDefaultEntry(){a.time("[store][empConfig]SetDefaultEntry");let e=C.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await L([e],{windowsPathsNoEscape:!0});if(t[0]){let s=C.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}a.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},Ke=new ye});import Ze from"path";var ve,et,tt=m(()=>{"use strict";n();w();ve=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return this.store.empConfig.build.polyfill}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:y(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfillInclude)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",Ze.dirname(b.resolve("@swc/helpers/package.json"))),this.coreJs.path=b.resolve("core-js/package.json");let t=ie(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Ze.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:s}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},[t.sourceMap]:{test:/\.[tj]sx?$/,enforce:"pre",use:{[s.sourceMap]:{loader:b.resolve("source-map-loader")}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},et=new ve});import st from"fs";import B from"@rspack/core";var be,it,rt=m(()=>{"use strict";n();be=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(B.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");st.existsSync(e)&&st.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(B.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(B.ProgressPlugin,[{prefix:"EMP"}])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(B.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(B.LightningCssMinimizerRspackPlugin,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=b("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}},it=new be});var we,ot,nt=m(()=>{"use strict";n();Ve();Qe();Ye();tt();rt();we=class{store;async setup(e){this.store=e;let t=[qe.setup(this.store),et.setup(this.store),it.setup(this.store),Ke.setup(this.store),Xe.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ot=new we});var at,pt=m(()=>{"use strict";n();at={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor"},minimizer:{minJs:"minJs",minCss:"minCss"}}});import rs from"fs/promises";import x from"path";import os from"util";import ns from"webpack-chain";var Ce,o,v=m(()=>{"use strict";n();E();w();We();nt();pt();Ce=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.resolve(c,l).replace(`${x.sep}dist${x.sep}index.js`,"");empSource=x.resolve(this.empRoot,"dist");resolve=e=>x.isAbsolute(e)?e:x.resolve(this.root,e);empResolve=e=>x.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=at;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=oe;deepAssign=y;getLanIp=M;entries={};debug;async setup(e,t){a.time("[store]Setup"),await this.initVars(e,t),this.empConfig=_e,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new ns,await ot.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),a.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let s=b(this.empResolve("package.json")),r=b(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.resource.dir=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),a.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=x.join(this.root,this.debug.showRsconfig);rs.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(a.link("[Compile Config]")),console.log(os.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}},o=new Ce});import as from"fs";import k from"path";import{gzipSizeSync as ps}from"gzip-size";function gs(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,p,f)=>{let g=t[f],P=p;return g&&(P=p.length<g?p+" ".repeat(g-p.length):p),`${r+P} `}," ");console.log(D.bold(s))}async function lt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>fs(u.name)).map(us);s.sort((u,T)=>u.size-T.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),p=Math.max(...s.map(u=>(u.folder+k.sep+u.name).length));gs(p,r);let f=0,g=0;s.forEach(u=>{let{sizeLabel:T}=u,{name:yt,folder:vt,gzipSizeLabel:bt}=u,$e=(vt+k.sep+yt).length,De=T.length;if(f+=u.size,g+=u.gzippedSize,De<r){let Y=" ".repeat(r-De);T+=Y}let je=j(u.folder+k.sep)+ds(u.name);if($e<p){let Y=" ".repeat(p-$e);je+=Y}a.info(` ${je} ${j(T)} ${bt}`)});let P=`${D.bold("Total size:")} ${q(f)}`,F=`${D.bold("Gzipped size:")} ${q(g)}`;a.info(`
|
|
13
|
+
${P}
|
|
14
|
+
${F}
|
|
15
|
+
`),a.info(`${S("\u2713")} Ready in ${I(Number(e.time))}
|
|
16
|
+
`)}function V(i=0){a.info(`${S("\u2713")} Ready in ${I(Number(i))}`)}var ls,cs,ms,fs,hs,us,q,ds,X=m(()=>{"use strict";n();R();v();E();w();ls=/\.html$/,cs=/\.(?:js|mjs|cjs|jsx)$/,ms=/\.css$/,fs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),hs=i=>i>300*1e3?Z:i>100*1e3?U:ee,us=i=>{let e=i.name.split("?")[0],t=q(i.size),s=k.basename(e),r=k.join(k.basename(o.empConfig.build.outDir),k.dirname(e)),p=as.readFileSync(k.join(o.empConfig.build.outDir,e)),f=p.length,g=ps(p),P=hs(g)(q(g));return{size:f,folder:r,name:s,gzippedSize:g,sizeLabel:t,gzipSizeLabel:P}};q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},ds=i=>cs.test(i)?U(i):ms.test(i)?S(i):ls.test(i)?D(i):te(i)});var ct={};N(ct,{default:()=>bs});import{rspack as ys}from"@rspack/core";import{RspackDevServer as vs}from"@rspack/dev-server";var xe,bs,mt=m(()=>{"use strict";n();X();E();w();G();v();xe=class extends O{get rspackDevConfig(){return y(o.rsConfig,{stats:{all:o.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}})}async devServerConfig(){let e=Object.assign({},o.rsConfig.devServer);if(this.isHttps&&(e.https===!0&&delete e.https,!e.server)){let[t,s]=await this.getcert();e.server={type:"https",options:{key:t,cert:s}}}return e}async run(){let e=ys(this.rspackDevConfig);if(!o.rsConfig.devServer){a.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new vs(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=p=>{let f=p?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});V(f.time)};o.debug.showPerformance&&e.hooks.afterDone.tap("done",r),s.middleware?.waitUntilValid(p=>{o.debug.showPerformance||r(p),o.empConfig.lifeCycle.afterDevServe&&o.empConfig.lifeCycle.afterDevServe()})}},bs=new xe});import ws from"https";import Cs from"compression";import xs from"cors";import Ss from"express";var Q,ft=m(()=>{"use strict";n();G();Q=class extends O{app;async init(){let e=Ss();e.use(Cs()),e.use(xs()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();ws.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:e,cert:t},this.app).listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}else this.app.listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var Se={};N(Se,{ServeScript:()=>K,default:()=>$s});import Es from"fs";import Os from"fs/promises";import Ps from"path";import ks from"express";var K,$s,Ee=m(()=>{"use strict";n();X();E();v();ft();K=class extends Q{timing=0;async run(){if(this.timing=Date.now(),!Es.existsSync(o.outDir))return a.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(ks.static(e));let t=await Os.readFile(Ps.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){V(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},$s=new K});var ht={};N(ht,{default:()=>js});import{rspack as Ds}from"@rspack/core";var Oe,js,ut=m(()=>{"use strict";n();X();E();G();v();Oe=class extends O{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(Ee(),Se));await e.setup("serve",o.cliOptions)}async run(){await o.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!o.cliOptions.watch,this.isuseServe=!!o.cliOptions.serve,this.rspackConfig=o.rsConfig,this.isWatchMode&&this.watchMode(),Ds(this.rspackConfig,async(e,t)=>{if(e!==null){a.error(e.stack||e),e.message&&a.error(e.message);return}if(!t){a.red("Stats is Undefined.");return}t.hasErrors()&&(a.error(t.toString({all:!1,colors:!0,errors:!0})),a.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(a.yellow("Compiled with warnings."),a.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await lt(t),this.startServe(),await o.empConfig.lifeCycle.afterBulid()})}},js=new Oe});n();import{rspack as Jo}from"@rspack/core";n();v();import Rs from"process";import{program as $}from"commander";function gt(){$.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),$.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(mt(),ct));await e.setup("dev",i)}),$.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(ut(),ht));await e.setup("build",i)}),$.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Ee(),Se));await e.setup("serve",i)}),$.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(i=>{}),$.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(i=>{}),$.parse(Rs.argv)}n();z();v();import dt from"fs/promises";import Pe from"path";var Ls=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,As=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Fs=/import\(['"]([^;\n]+?)['"]\)/,ke=class{list=[];outDir=o.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await L([`${o.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=o.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await dt.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Ls,r=>{let p=r.match(As);if(p||(p=r.match(Fs)),p&&p[1]){let f=p[1];if(!f.startsWith("."))return r;let g=Pe.resolve(Pe.dirname(e),f).replace(this.outDir,this.aliasName);return r.replace(p[1],g)}return r});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
|
|
17
17
|
${t}}\r
|
|
18
|
-
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await
|
|
18
|
+
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await dt.writeFile(Pe.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Ts=new ke;v();z();function Vo(i){return i}export{Vo as defineConfig,Ts as dts,Le as empHelper,Jo as rspack,gt as runScript,o as store};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/cli",
|
|
3
|
-
"version": "3.1.0-rc.
|
|
3
|
+
"version": "3.1.0-rc.9",
|
|
4
4
|
"description": "emp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -67,10 +67,9 @@
|
|
|
67
67
|
"tsup": "^8.1.0"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@rspack/
|
|
73
|
-
"@rspack/dev-server": "^1.0.3",
|
|
70
|
+
"@rsdoctor/rspack-plugin": "^0.4.2",
|
|
71
|
+
"@rspack/core": "1.0.4",
|
|
72
|
+
"@rspack/dev-server": "1.0.4",
|
|
74
73
|
"@swc/helpers": "^0.5.13",
|
|
75
74
|
"address": "^2.0.2",
|
|
76
75
|
"chalk": "^5.3.0",
|
|
@@ -92,7 +91,8 @@
|
|
|
92
91
|
"source-map-loader": "^5.0.0",
|
|
93
92
|
"typescript-plugin-css-modules": "^5.1.0",
|
|
94
93
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
95
|
-
"webpack-chain": "^6.5.1"
|
|
94
|
+
"webpack-chain": "^6.5.1",
|
|
95
|
+
"@empjs/share": "0.0.1"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
98
|
"dev": "tsup --watch --env.ENV dev",
|