@empjs/cli 3.1.5 → 3.1.7
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 +8 -8
- package/dist/index.d.cts +6 -12
- package/dist/index.d.ts +6 -12
- package/dist/index.js +9 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ss=Object.create;var
|
|
1
|
+
"use strict";var ss=Object.create;var U=Object.defineProperty;var is=Object.getOwnPropertyDescriptor;var os=Object.getOwnPropertyNames;var rs=Object.getPrototypeOf,ns=Object.prototype.hasOwnProperty;var m=(i,e)=>()=>(i&&(e=i(i=0)),e);var j=(i,e)=>{for(var t in e)U(i,t,{get:e[t],enumerable:!0})},Ue=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of os(e))!ns.call(i,o)&&o!==t&&U(i,o,{get:()=>e[o],enumerable:!(s=is(e,o))||s.enumerable});return i};var l=(i,e,t)=>(t=i!=null?ss(rs(i)):{},Ue(e||!i||!i.__esModule?U(t,"default",{value:i,enumerable:!0}):t,i)),as=i=>Ue(U({},"__esModule",{value:!0}),i);var n=m(()=>{"use strict"});var d,ps,S,ls,cs,ms,ie,B,fs,hs,D,oe,us,re,T,h,R=m(()=>{"use strict";n();d=l(require("chalk"),1),ps=d.default.hex("#1abc9c"),S=d.default.hex("#16a085"),ls=d.default.hex("#2ecc71"),cs=d.default.hex("#27ae60"),ms=d.default.hex("#e74c3c"),ie=d.default.hex("#c0392b"),B=d.default.hex("#f1c40f"),fs=d.default.hex("#f39c12"),hs=d.default.hex("#3498db"),D=d.default.hex("#2980b9"),oe=d.default.hex("#ecf0f1"),us=d.default.hex("#fd79a8"),re=d.default.hex("#e84393"),T=d.default.hex("#7f8c8d"),h={lightGreen:ps,green:S,lightCyan:ls,cyan:cs,lightRed:ms,red:ie,yellow:B,orange:fs,lightBlue:hs,blue:D,white:oe,lightMagenta:us,magenta:re,gray:T}});var ne,p,E=m(()=>{"use strict";n();R();ne=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
2
|
`)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
|
|
3
3
|
`)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
|
|
4
4
|
`)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
`)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
|
|
7
7
|
`)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
|
|
8
8
|
`)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
|
|
9
|
-
`)}},p=new ne});var me={};j(me,{clearConsole:()=>pe,deepAssign:()=>y,ensureArray:()=>gs,getLanIp:()=>M,getPkgVersion:()=>ae,importJsVm:()=>ce,jsonFilter:()=>ds,timeFormat:()=>
|
|
10
|
-
`)),this.sf.isOpenBrower&&at(this.sf.url)}async setup(e,t){p.time(`[${e}]Setup`),await
|
|
11
|
-
`);return ce(i)}var q,W,I,V=f(()=>{"use strict";a();q=l(require("html-webpack-plugin"),1);C();v();W=class{constructor(){}apply(e){let{webpack:t}=e;o.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Os(),{name:void 0}).apply(e)}},I=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",s=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=s}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{q.default.getHooks(t).alterAssetTagGroups.tapAsync(this.PluginName,(s,r)=>{if(this.chunk&&!s.plugin.userOptions.chunks?.includes(this.chunk))return r(null,s);this.files.map(n=>{let c=n.pos==="body"?s.bodyTags:s.headTags;switch(n.type){case"js":n.src?c.push({tagName:"script",attributes:{src:n.src},voidTag:!1,meta:{plugin:void 0}}):n.content&&c.push({tagName:"script",attributes:{},innerHTML:n.content,voidTag:!1,meta:{plugin:void 0}});break;case"css":n.src?c.push({tagName:"link",attributes:{rel:"stylesheet",href:n.src},voidTag:!1,meta:{plugin:void 0}}):n.content&&c.push({tagName:"script",attributes:{},innerHTML:n.content,voidTag:!1,meta:{plugin:void 0}});break}}),r(null,s)})})}}});var X,lt=f(()=>{"use strict";a();v();be();V();X=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await _.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill.mode==="entry"&&o.chain.plugin("empPolyfill").use(W),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 ct,Ce,mt,ft=f(()=>{"use strict";a();ct=l(require("fs"),1);z();Ye();C();G();lt();Ce=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 X(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:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"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,tags:[]},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,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.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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Ke();if(!e||!ct.default.existsSync(e))return;let t=await Qe(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}},mt=new Ce});var ht,xe,ut,gt=f(()=>{"use strict";a();ht=l(require("fs-extra"),1),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 ht.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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups={coreJs:{test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}}),this.store.chain.merge({optimization:e})}},ut=new xe});var Se,dt,yt=f(()=>{"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:require.resolve("sass-embedded"),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"}}}})}},dt=new Se});var b,Ee,vt,bt=f(()=>{"use strict";a();b=l(require("path"),1);z();V();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),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectHeadTags(e.tags,"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{src:this.store.empConfig.build.polyfill.entryCdn,type:"js"}];this.store.injectHeadTags(e,"injectEMPPolyfill")}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),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(q.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),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=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(n=>n.replace(`${t}${b.default.sep}`,"")),r.map(n=>{let c=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...c},b.default.join(t,n))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.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])}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)}},vt=new Ee});var Oe,Pe,wt,Ct=f(()=>{"use strict";a();Oe=l(require("path"),1);C();Pe=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.mode}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,polyfill:s}=this.store.empConfig.build,{externalHelpers:r}=s;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,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.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",Oe.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ae(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Oe.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(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}}}}}})}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"}}}})}},wt=new Pe});var ke,N,$e,xt,St=f(()=>{"use strict";a();ke=l(require("fs"),1),N=l(require("@rspack/core"),1),$e=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(N.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");ke.default.existsSync(e)&&ke.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(N.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(N.default.ProgressPlugin,[{prefix:"EMP"}])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(N.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(N.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])}},xt=new $e});var je,Et,Ot=f(()=>{"use strict";a();gt();yt();bt();Ct();St();je=class{store;async setup(e){this.store=e;let t=[ut.setup(this.store),wt.setup(this.store),xt.setup(this.store),vt.setup(this.store),dt.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()}},Et=new je});var Pt,kt=f(()=>{"use strict";a();Pt={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 $t,w,jt,Dt,De,o,v=f(()=>{"use strict";a();$t=l(require("fs/promises"),1),w=l(require("path"),1),jt=l(require("util"),1);S();C();ft();Ot();Dt=l(require("webpack-chain"),1);kt();V();De=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=Pt;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=le;deepAssign=y;getLanIp=M;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=mt,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Dt.default,await Et.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=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),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=w.default.join(this.root,this.debug.showRsconfig);$t.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(p.link("[Compile Config]")),console.log(jt.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("-","_")}injectHeadTags(e=[],t="",s=""){this.chain.plugin(`${I}-${t}`).use(I,[e,t,s])}},o=new De});function Rs(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,c)=>{let g=t[c],O=n;return g&&(O=n.length<g?n+" ".repeat(g-n.length):n),`${r+O} `}," ");console.log(D.bold(s))}async function Lt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>js(u.name)).map(Ts);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));Rs(n,r);let c=0,g=0;s.forEach(u=>{let{sizeLabel:F}=u,{name:Zt,folder:es,gzipSizeLabel:ts}=u,ze=(es+P.default.sep+Zt).length,Ge=F.length;if(c+=u.size,g+=u.gzippedSize,Ge<r){let se=" ".repeat(r-Ge);F+=se}let Ie=T(u.folder+P.default.sep)+Ls(u.name);if(ze<n){let se=" ".repeat(n-ze);Ie+=se}p.info(` ${Ie} ${T(F)} ${ts}`)});let O=`${D.bold("Total size:")} ${Q(c)}`,A=`${D.bold("Gzipped size:")} ${Q(g)}`;p.info(`
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
`),p.info(`${
|
|
15
|
-
`)}function K(i=0){p.info(`${
|
|
9
|
+
`)}},p=new ne});var me={};j(me,{clearConsole:()=>pe,deepAssign:()=>y,ensureArray:()=>gs,getLanIp:()=>M,getPkgVersion:()=>ae,importJsVm:()=>ce,jsonFilter:()=>ds,timeFormat:()=>H,vCompare:()=>le});function pe(){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 o=t[s],a=i[s];if(Object(o)==o&&Object(a)===a){i[s]=y(a,o);continue}i[s]=t[s]}return i}var Be,He,Je,_e,M,ae,gs,ds,le,H,ce,C=m(()=>{"use strict";n();Be=require("address"),He=l(require("chalk"),1),Je=require("default-gateway"),_e=l(require("fs-extra"),1),M=()=>{let{int:i}=(0,Je.gateway4sync)();return(0,Be.ip)(i||"")||"127.0.0.1"},ae=i=>{try{let{version:e}=_e.default.readJSONSync(i);return e}catch{return}};gs=i=>Array.isArray(i)?i:[i],ds=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),le=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),o=Math.max(t.length,s.length),a=0;for(let f=0;f<o;f++){let u=t.length>f?t[f]:0,x=isNaN(Number(u))?u.charCodeAt():Number(u),N=s.length>f?s[f]:0,g=isNaN(Number(N))?N.charCodeAt():Number(N);if(x<g){a=-1;break}else if(x>g){a=1;break}}return a},H=i=>{i=i/1e3;let e=s=>He.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`},ce=i=>`data:text/javascript,${i}`});var fe={};j(fe,{chalk:()=>We.default,color:()=>h,glob:()=>$.glob,logger:()=>p,utils:()=>me});var We,$,z=m(()=>{"use strict";n();We=l(require("chalk"),1),$=require("glob");R();C();E()});var qe,Ve,Xe,ys,Qe,Ke,vs,Ye=m(()=>{"use strict";n();qe=l(require("fs"),1),Ve=l(require("path"),1),Xe=l(require("jiti"),1);v();E();ys=["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,Xe.default)(__filename,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Ke=async()=>vs(),vs=()=>{p.time("[store]GetEmpConfigPath");let i;for(let e of ys){let t=Ve.default.resolve(r.root,e);if(qe.default.existsSync(t)){i=t;break}}return p.timeEnd("[store]GetEmpConfigPath"),i}});async function J(i,e="localhost"){if(i!==bs&&(i<Ze||i>he))throw new Error(`Port number must lie between ${Ze} and ${he}`);let t=i,s=ws(),o;e&&!s.has(e)?o=new Set([e]):o=s;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=he;)try{return await xs(t,o)}catch(f){if(!a.has(f.code))throw f;t+=1}throw new Error("No available ports found")}var et,tt,Ze,he,bs,ws,Cs,xs,ue=m(()=>{"use strict";n();et=l(require("net"),1),tt=l(require("os"),1),Ze=1024,he=65535,bs=443,ws=()=>{let i=tt.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},Cs=(i,e)=>new Promise((t,s)=>{let o=et.default.createServer();o.unref(),o.on("error",s),o.listen(i,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),xs=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Cs(i,s)}catch(o){if(!t.has(o.code))throw o}return i}});var ge,st,de,L,ye=m(()=>{"use strict";n();ge=l(require("url"),1),st=l(require("chalk"),1);R();C();de=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:T("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:o}=this.imf;return ge.default.format({protocol:t,hostname:e,port:s,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:o}=this.imf;return ge.default.format({protocol:t,hostname:e,port:st.default.bold(s),pathname:o})}},L=new de});var ot,rt,nt,it,Ss,Es,at,pt=m(()=>{"use strict";n();ot=require("child_process"),rt=require("util");v();E();nt=(0,rt.promisify)(ot.exec),it=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Ss=async()=>{let i=process.env.BROWSER;if(!i||!it.includes(i)){let{stdout:e}=await nt("ps cax");i=it.find(t=>e.includes(t))}return i},Es=async i=>{if(process.platform==="darwin")try{let t=await Ss();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await nt(s,{cwd:r.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},at=Es});var ve,_,be=m(()=>{"use strict";n();ue();ye();C();v();ve=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=r.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!r.empOptions.autoDevBase&&r.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=r.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=L.getLanIp(),o=this.isHttps?"https":"http",a=r.empOptions.server?.port||8e3;a=await J(a,s),r.empOptions.base=`${o}://${s}:${a}/`,r.empOptions.server=y({port:a,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${a}/ws`}},r.empOptions.server)}},_=new ve});var we,O,G=m(()=>{"use strict";n();we=l(require("fs/promises"),1);R();ue();ye();E();pt();C();v();be();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=r.rsConfig.output?.publicPath==="auto"?"/":r.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!r.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=r.empConfig.server.host?r.empConfig.server.host:this.sf.host,this.sf.port=r.empConfig.server.port,await this.serverPort(),L.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=L.prettyPrintUrl("localhost")):(this.sf.urls=L.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(p.info(`${S("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${S("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${S("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${S("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
|
|
10
|
+
`)),this.sf.isOpenBrower&&at(this.sf.url)}async setup(e,t){p.time(`[${e}]Setup`),await r.setup(e,t),r.debug.clearLog&&pe(),p.title(`${e}`),await this.adaptServer(),p.time(`[${e}]Run`),await this.run(),p.timeEnd(`[${e}]Run`),this.afterRun(),p.timeEnd(`[${e}]Setup`)}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{server:e,https:t,http2:s}=r.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0||s===!0}getcert(){return Promise.all([we.default.readFile(r.resource.key),we.default.readFile(r.resource.cert)])}async serverPort(){if(_.isADB)return;let{port:e,host:t}=this.sf,s=await J(e,t);s!==e&&(this.sf.port=s,r.rsConfig.devServer?.port&&(r.rsConfig.devServer.port=s))}}});function Os(){let i=[`import 'core-js/${r.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
11
|
+
`);return ce(i)}var q,W,I,V=m(()=>{"use strict";n();q=l(require("html-webpack-plugin"),1);C();v();W=class{constructor(){}apply(e){let{webpack:t}=e;r.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Os(),{name:void 0}).apply(e)}},I=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",s=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=s}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{q.default.getHooks(t).alterAssetTagGroups.tapAsync(this.PluginName,(s,o)=>{if(this.chunk&&!s.plugin.userOptions.chunks?.includes(this.chunk))return o(null,s);this.files.map(a=>{let{pos:f,...u}=a;(f==="body"?s.bodyTags:s.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o(null,s)})})}}});var X,lt=m(()=>{"use strict";n();v();be();V();X=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await _.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){r.empConfig.build.polyfill.mode==="entry"&&r.chain.plugin("empPolyfill").use(W),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 ct,Ce,mt,ft=m(()=>{"use strict";n();ct=l(require("fs"),1);z();Ye();C();G();lt();Ce=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 X(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:o}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),o&&(this.appEntry=o)}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:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"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,tags:[]},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:o}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(a,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(o=>{t==="all"?(s[`import.meta.env.${o}`]=JSON.stringify(e[o]),s[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?s[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?s[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(s[`${o}`]=JSON.stringify(e[o]))}),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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Ke();if(!e||!ct.default.existsSync(e))return;let t=await Qe(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}},mt=new Ce});var ht,xe,ut,gt=m(()=>{"use strict";n();ht=l(require("fs-extra"),1),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 ht.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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups={coreJs:{test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}}),this.store.chain.merge({optimization:e})}},ut=new xe});var Se,dt,yt=m(()=>{"use strict";n();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:o}=this.store.empConfig.css||{sass:{}};o.mode==="modern"&&(s.implementation=o.implementation?o.implementation:require.resolve("sass-embedded"),s.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(s.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(s.webpackImporter=o.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"}}}})}},dt=new Se});var b,Ee,vt,bt=m(()=>{"use strict";n();b=l(require("path"),1);z();V();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),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}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 o=this.setChunk(e),a=[s];this.entriesConfig[o]={entry:{[o]:a},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(q.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),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=b.default.join(this.store.appSrc,e),s=b.default.join(t,"**","*.{ts,tsx,jsx,js}"),o=await(0,$.glob)([s],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${b.default.sep}`,"")),o.map(a=>{let f=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...f},b.default.join(t,a))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.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])}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)}},vt=new Ee});var Oe,Pe,wt,Ct=m(()=>{"use strict";n();Oe=l(require("path"),1);C();Pe=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.mode}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,polyfill:s}=this.store.empConfig.build,{externalHelpers:o}=s;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,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.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",Oe.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ae(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Oe.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(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}}}}}})}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"}}}})}},wt=new Pe});var ke,A,$e,xt,St=m(()=>{"use strict";n();ke=l(require("fs"),1),A=l(require("@rspack/core"),1),$e=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(A.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");ke.default.existsSync(e)&&ke.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(A.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(A.default.ProgressPlugin,[{prefix:"EMP"}])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(A.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(A.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])}},xt=new $e});var je,Et,Ot=m(()=>{"use strict";n();gt();yt();bt();Ct();St();je=class{store;async setup(e){this.store=e;let t=[ut.setup(this.store),wt.setup(this.store),xt.setup(this.store),vt.setup(this.store),dt.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()}},Et=new je});var Pt,kt=m(()=>{"use strict";n();Pt={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 $t,w,jt,Dt,De,r,v=m(()=>{"use strict";n();$t=l(require("fs/promises"),1),w=l(require("path"),1),jt=l(require("util"),1);E();C();ft();Ot();Dt=l(require("webpack-chain"),1);kt();V();De=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=Pt;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=le;deepAssign=y;getLanIp=M;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=mt,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Dt.default,await Et.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")),o=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...o},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),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=w.default.join(this.root,this.debug.showRsconfig);$t.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(p.link("[Compile Config]")),console.log(jt.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("-","_")}injectTags(e=[],t="",s=""){this.chain.plugin(`${I}-${t}`).use(I,[e,t,s])}},r=new De});function Rs(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((o,a,f)=>{let u=t[f],x=a;return u&&(x=a.length<u?a+" ".repeat(u-a.length):a),`${o+x} `}," ");console.log(D.bold(s))}async function Lt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(g=>js(g.name)).map(Ts);s.sort((g,F)=>g.size-F.size);let o=Math.max(...s.map(g=>g.sizeLabel.length)),a=Math.max(...s.map(g=>(g.folder+P.default.sep+g.name).length));Rs(a,o);let f=0,u=0;s.forEach(g=>{let{sizeLabel:F}=g,{name:Zt,folder:es,gzipSizeLabel:ts}=g,ze=(es+P.default.sep+Zt).length,Ge=F.length;if(f+=g.size,u+=g.gzippedSize,Ge<o){let se=" ".repeat(o-Ge);F+=se}let Ie=T(g.folder+P.default.sep)+Ls(g.name);if(ze<a){let se=" ".repeat(a-ze);Ie+=se}p.info(` ${Ie} ${T(F)} ${ts}`)});let x=`${D.bold("Total size:")} ${Q(f)}`,N=`${D.bold("Gzipped size:")} ${Q(u)}`;p.info(`
|
|
12
|
+
${x}
|
|
13
|
+
${N}
|
|
14
|
+
`),p.info(`${S("\u2713")} Ready in ${H(Number(e.time))}
|
|
15
|
+
`)}function K(i=0){p.info(`${S("\u2713")} Ready in ${H(Number(i))}`)}var Tt,P,Rt,Ps,ks,$s,js,Ds,Ts,Q,Ls,Y=m(()=>{"use strict";n();Tt=l(require("fs"),1),P=l(require("path"),1),Rt=require("gzip-size");R();v();E();C();Ps=/\.html$/,ks=/\.(?:js|mjs|cjs|jsx)$/,$s=/\.css$/,js=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Ds=i=>i>300*1e3?ie:i>100*1e3?B:oe,Ts=i=>{let e=i.name.split("?")[0],t=Q(i.size),s=P.default.basename(e),o=P.default.join(P.default.basename(r.empConfig.build.outDir),P.default.dirname(e)),a=Tt.default.readFileSync(P.default.join(r.empConfig.build.outDir,e)),f=a.length,u=(0,Rt.gzipSizeSync)(a),x=Ds(u)(Q(u));return{size:f,folder:o,name:s,gzippedSize:u,sizeLabel:t,gzipSizeLabel:x}};Q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ls=i=>ks.test(i)?B(i):$s.test(i)?S(i):Ps.test(i)?D(i):re(i)});var Ft={};j(Ft,{default:()=>As});var At,Nt,Te,As,Mt=m(()=>{"use strict";n();At=require("@rspack/core"),Nt=require("@rspack/dev-server");Y();E();C();G();v();Te=class extends O{get rspackDevConfig(){return y(r.rsConfig,{stats:{all:r.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({},r.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(!r.rsConfig.devServer){p.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Nt.RspackDevServer(t,e);this.startOpen(),r.empConfig.lifeCycle.beforeDevServe&&await r.empConfig.lifeCycle.beforeDevServe(),await s.start();let o=a=>{let f=a?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});K(f.time)};r.debug.showPerformance&&e.hooks.afterDone.tap("done",o),s.middleware?.waitUntilValid(a=>{r.debug.showPerformance||o(a),r.empConfig.lifeCycle.afterDevServe&&r.empConfig.lifeCycle.afterDevServe()})}},As=new Te});var zt,Gt,It,Ut,Z,Bt=m(()=>{"use strict";n();zt=l(require("https"),1),Gt=l(require("compression"),1),It=l(require("cors"),1),Ut=l(require("express"),1);G();Z=class extends O{app;async init(){let e=(0,Ut.default)();e.use((0,Gt.default)()),e.use((0,It.default)()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();zt.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 Re={};j(Re,{ServeScript:()=>ee,default:()=>Ns});var Ht,Jt,_t,Wt,ee,Ns,Le=m(()=>{"use strict";n();Ht=l(require("fs"),1),Jt=l(require("fs/promises"),1),_t=l(require("path"),1),Wt=l(require("express"),1);Y();E();v();Bt();ee=class extends Z{timing=0;async run(){if(this.timing=Date.now(),!Ht.default.existsSync(r.outDir))return p.sysError(`emp serve must be executed after emp build,${r.outDir} not exist!`);r.empConfig.lifeCycle.beforeServe&&await r.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=r.resolve(r.rsConfig.output?.path);this.app.use(Wt.default.static(e));let t=await Jt.default.readFile(_t.default.join(e,"index.html"),"utf8");this.app.get("*",(s,o)=>o.send(t))}async onReady(){K(Date.now()-this.timing),r.empConfig.lifeCycle.afterServe&&await r.empConfig.lifeCycle.afterServe()}},Ns=new ee});var Vt={};j(Vt,{default:()=>Fs});var qt,Ae,Fs,Xt=m(()=>{"use strict";n();qt=require("@rspack/core");Y();E();G();v();Ae=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(()=>(Le(),Re));await e.setup("serve",r.cliOptions)}async run(){await r.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!r.cliOptions.watch,this.isuseServe=!!r.cliOptions.serve,this.rspackConfig=r.rsConfig,this.isWatchMode&&this.watchMode(),(0,qt.rspack)(this.rspackConfig,async(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Lt(t),this.startServe(),await r.empConfig.lifeCycle.afterBulid()})}},Fs=new Ae});var Us={};j(Us,{defineConfig:()=>Is,dts:()=>Kt,empHelper:()=>fe,rspack:()=>Yt.rspack,runScript:()=>Ne,store:()=>r});module.exports=as(Us);n();var Yt=require("@rspack/core");n();var Qt=l(require("process"),1),k=require("commander");v();function Ne(){k.program.version(r.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(()=>(Mt(),Ft));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(()=>(Xt(),Vt));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(()=>(Le(),Re));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(Qt.default.argv)}n();var Fe=l(require("fs/promises"),1),te=l(require("path"),1);z();v();var Ms=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,zs=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Gs=/import\(['"]([^;\n]+?)['"]\)/,Me=class{list=[];outDir=r.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)([`${r.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=r.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 Fe.default.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Ms,o=>{let a=o.match(zs);if(a||(a=o.match(Gs)),a&&a[1]){let f=a[1];if(!f.startsWith("."))return o;let u=te.default.resolve(te.default.dirname(e),f).replace(this.outDir,this.aliasName);return o.replace(a[1],u)}return o});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
17
|
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await Fe.default.writeFile(te.default.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Kt=new Me;v();z();function Is(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
|
@@ -3,6 +3,7 @@ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
|
3
3
|
import * as _rspack_core from '@rspack/core';
|
|
4
4
|
import { Output, Configuration, RspackOptions, Externals, Resolve, DevServer, SwcJsMinimizerRspackPluginOptions, LightningCssMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
|
|
5
5
|
export { rspack } from '@rspack/core';
|
|
6
|
+
import { HtmlTagObject } from 'html-webpack-plugin';
|
|
6
7
|
import { Options } from 'sass-embedded';
|
|
7
8
|
import WPChain from 'webpack-chain';
|
|
8
9
|
import * as chalk from 'chalk';
|
|
@@ -298,7 +299,7 @@ declare class GlobalStore {
|
|
|
298
299
|
node: string[];
|
|
299
300
|
};
|
|
300
301
|
get uniqueName(): string;
|
|
301
|
-
|
|
302
|
+
injectTags(o?: InjectTagsType, name?: string, chunk?: string): void;
|
|
302
303
|
}
|
|
303
304
|
declare const _default$3: GlobalStore;
|
|
304
305
|
|
|
@@ -471,7 +472,7 @@ interface HtmlType extends HtmlRspackPluginOptions {
|
|
|
471
472
|
/**
|
|
472
473
|
* externals 文件插入到html
|
|
473
474
|
*/
|
|
474
|
-
tags?:
|
|
475
|
+
tags?: InjectTagsTypeItem[];
|
|
475
476
|
templateParameters?: any;
|
|
476
477
|
}
|
|
477
478
|
type EntriesType = {
|
|
@@ -594,17 +595,10 @@ type EmpOptions = {
|
|
|
594
595
|
*/
|
|
595
596
|
ignoreWarnings?: Configuration['ignoreWarnings'];
|
|
596
597
|
};
|
|
597
|
-
type
|
|
598
|
-
type
|
|
599
|
-
/**
|
|
600
|
-
* js 为 src 请求 content 脚本注入
|
|
601
|
-
* css 为 src 请求 content 脚本注入
|
|
602
|
-
*/
|
|
603
|
-
type: 'js' | 'css';
|
|
604
|
-
src?: string;
|
|
605
|
-
content?: string;
|
|
598
|
+
type InjectTagsType = InjectTagsTypeItem[];
|
|
599
|
+
type InjectTagsTypeItem = {
|
|
606
600
|
pos?: 'head' | 'body';
|
|
607
|
-
}
|
|
601
|
+
} & Partial<HtmlTagObject>;
|
|
608
602
|
|
|
609
603
|
declare function runScript(): void;
|
|
610
604
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
|
3
3
|
import * as _rspack_core from '@rspack/core';
|
|
4
4
|
import { Output, Configuration, RspackOptions, Externals, Resolve, DevServer, SwcJsMinimizerRspackPluginOptions, LightningCssMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
|
|
5
5
|
export { rspack } from '@rspack/core';
|
|
6
|
+
import { HtmlTagObject } from 'html-webpack-plugin';
|
|
6
7
|
import { Options } from 'sass-embedded';
|
|
7
8
|
import WPChain from 'webpack-chain';
|
|
8
9
|
import * as chalk from 'chalk';
|
|
@@ -298,7 +299,7 @@ declare class GlobalStore {
|
|
|
298
299
|
node: string[];
|
|
299
300
|
};
|
|
300
301
|
get uniqueName(): string;
|
|
301
|
-
|
|
302
|
+
injectTags(o?: InjectTagsType, name?: string, chunk?: string): void;
|
|
302
303
|
}
|
|
303
304
|
declare const _default$3: GlobalStore;
|
|
304
305
|
|
|
@@ -471,7 +472,7 @@ interface HtmlType extends HtmlRspackPluginOptions {
|
|
|
471
472
|
/**
|
|
472
473
|
* externals 文件插入到html
|
|
473
474
|
*/
|
|
474
|
-
tags?:
|
|
475
|
+
tags?: InjectTagsTypeItem[];
|
|
475
476
|
templateParameters?: any;
|
|
476
477
|
}
|
|
477
478
|
type EntriesType = {
|
|
@@ -594,17 +595,10 @@ type EmpOptions = {
|
|
|
594
595
|
*/
|
|
595
596
|
ignoreWarnings?: Configuration['ignoreWarnings'];
|
|
596
597
|
};
|
|
597
|
-
type
|
|
598
|
-
type
|
|
599
|
-
/**
|
|
600
|
-
* js 为 src 请求 content 脚本注入
|
|
601
|
-
* css 为 src 请求 content 脚本注入
|
|
602
|
-
*/
|
|
603
|
-
type: 'js' | 'css';
|
|
604
|
-
src?: string;
|
|
605
|
-
content?: string;
|
|
598
|
+
type InjectTagsType = InjectTagsTypeItem[];
|
|
599
|
+
type InjectTagsTypeItem = {
|
|
606
600
|
pos?: 'head' | 'body';
|
|
607
|
-
}
|
|
601
|
+
} & Partial<HtmlTagObject>;
|
|
608
602
|
|
|
609
603
|
declare function runScript(): void;
|
|
610
604
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
|
|
2
|
-
var xt=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
|
|
2
|
+
var xt=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 F=(i,e)=>{for(var t in e)xt(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as St}from"url";import Et from"path";var Ae,Ot,c,l,n=m(()=>{"use strict";Ae=()=>St(import.meta.url),Ot=()=>Et.dirname(Ae()),c=Ot(),l=Ae()});import d from"chalk";var Pt,E,kt,$t,jt,te,U,Dt,Tt,j,se,Rt,ie,D,h,T=m(()=>{"use strict";n();Pt=d.hex("#1abc9c"),E=d.hex("#16a085"),kt=d.hex("#2ecc71"),$t=d.hex("#27ae60"),jt=d.hex("#e74c3c"),te=d.hex("#c0392b"),U=d.hex("#f1c40f"),Dt=d.hex("#f39c12"),Tt=d.hex("#3498db"),j=d.hex("#2980b9"),se=d.hex("#ecf0f1"),Rt=d.hex("#fd79a8"),ie=d.hex("#e84393"),D=d.hex("#7f8c8d"),h={lightGreen:Pt,green:E,lightCyan:kt,cyan:$t,lightRed:jt,red:te,yellow:U,orange:Dt,lightBlue:Tt,blue:j,white:se,lightMagenta:Rt,magenta:ie,gray:D}});var oe,p,O=m(()=>{"use strict";n();T();oe=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
3
|
`)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
|
|
4
4
|
`)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
|
|
5
5
|
`)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
|
|
@@ -7,12 +7,12 @@ var xt=Object.defineProperty;var b=(i=>typeof require<"u"?require:typeof Proxy<"
|
|
|
7
7
|
`)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
|
|
8
8
|
`)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
|
|
9
9
|
`)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
|
|
10
|
-
`)}},p=new oe});var le={};F(le,{clearConsole:()=>ne,deepAssign:()=>y,ensureArray:()=>Mt,getLanIp:()=>M,getPkgVersion:()=>re,importJsVm:()=>pe,jsonFilter:()=>zt,timeFormat:()=>
|
|
11
|
-
`)),this.sf.isOpenBrower&&
|
|
12
|
-
`);return pe(i)}var W,H,q=f(()=>{"use strict";a();w();v();W=class{constructor(){}apply(e){let{webpack:t}=e;r.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ss(),{name:void 0}).apply(e)}},H=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",s=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=s}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{de.getHooks(t).alterAssetTagGroups.tapAsync(this.PluginName,(s,o)=>{if(this.chunk&&!s.plugin.userOptions.chunks?.includes(this.chunk))return o(null,s);this.files.map(n=>{let m=n.pos==="body"?s.bodyTags:s.headTags;switch(n.type){case"js":n.src?m.push({tagName:"script",attributes:{src:n.src},voidTag:!1,meta:{plugin:void 0}}):n.content&&m.push({tagName:"script",attributes:{},innerHTML:n.content,voidTag:!1,meta:{plugin:void 0}});break;case"css":n.src?m.push({tagName:"link",attributes:{rel:"stylesheet",href:n.src},voidTag:!1,meta:{plugin:void 0}}):n.content&&m.push({tagName:"script",attributes:{},innerHTML:n.content,voidTag:!1,meta:{plugin:void 0}});break}}),o(null,s)})})}}});var V,We=f(()=>{"use strict";a();v();ge();q();V=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await _.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){r.empConfig.build.polyfill.mode==="entry"&&r.chain.plugin("empPolyfill").use(W),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 is from"node:fs";var ye,qe,Ve=f(()=>{"use strict";a();z();ze();w();G();We();ye=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 V(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:o}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),o&&(this.appEntry=o)}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:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"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,tags:[]},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:o}=this.store.empConfig.build,n={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${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(o=>{t==="all"?(s[`import.meta.env.${o}`]=JSON.stringify(e[o]),s[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?s[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?s[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(s[`${o}`]=JSON.stringify(e[o]))}),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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Me();if(!e||!is.existsSync(e))return;let t=await Fe(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}},qe=new ye});import os from"fs-extra";var ve,Xe,Qe=f(()=>{"use strict";a();ve=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 os.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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups={coreJs:{test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}}),this.store.chain.merge({optimization:e})}},Xe=new ve});var be,Ke,Ye=f(()=>{"use strict";a();be=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:o}=this.store.empConfig.css||{sass:{}};o.mode==="modern"&&(s.implementation=o.implementation?o.implementation:b.resolve("sass-embedded"),s.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(s.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(s.webpackImporter=o.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"}}}})}},Ke=new be});import C from"node:path";var we,Ze,et=f(()=>{"use strict";a();z();q();we=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),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectHeadTags(e.tags,"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{src:this.store.empConfig.build.polyfill.entryCdn,type:"js"}];this.store.injectHeadTags(e,"injectEMPPolyfill")}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 o=this.setChunk(e),n=[s];this.entriesConfig[o]={entry:{[o]:n},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=n}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(de,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),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=C.join(this.store.appSrc,e),s=C.join(t,"**","*.{ts,tsx,jsx,js}"),o=await R([s],{windowsPathsNoEscape:!0});o=o.map(n=>n.replace(`${t}${C.sep}`,"")),o.map(n=>{let m=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...m},C.join(t,n))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.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 R([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])}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)}},Ze=new we});import tt from"node:path";var Ce,st,it=f(()=>{"use strict";a();w();Ce=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.mode}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,polyfill:s}=this.store.empConfig.build,{externalHelpers:o}=s;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,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.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",tt.dirname(b.resolve("@swc/helpers/package.json"))),this.coreJs.path=b.resolve("core-js/package.json");let t=re(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=tt.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(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}}}}}})}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"}}}})}},st=new Ce});import ot from"fs";import I from"@rspack/core";var xe,rt,nt=f(()=>{"use strict";a();xe=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(I.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");ot.existsSync(e)&&ot.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(I.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(I.ProgressPlugin,[{prefix:"EMP"}])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(I.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(I.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])}},rt=new xe});var Se,at,pt=f(()=>{"use strict";a();Qe();Ye();et();it();nt();Se=class{store;async setup(e){this.store=e;let t=[Xe.setup(this.store),st.setup(this.store),rt.setup(this.store),Ze.setup(this.store),Ke.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 Se});var lt,ct=f(()=>{"use strict";a();lt={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"node:fs/promises";import x from"node:path";import ns from"node:util";import as from"webpack-chain";var Ee,r,v=f(()=>{"use strict";a();E();w();Ve();pt();ct();q();Ee=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=lt;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=ae;deepAssign=y;getLanIp=M;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=qe,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new as,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=b(this.empResolve("package.json")),o=b(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...o},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),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.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(p.link("[Compile Config]")),console.log(ns.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("-","_")}injectHeadTags(e=[],t="",s=""){this.chain.plugin(`${H}-${t}`).use(H,[e,t,s])}},r=new Ee});import ps from"node:fs";import k from"node:path";import{gzipSizeSync as ls}from"gzip-size";function ds(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((o,n,m)=>{let g=t[m],P=n;return g&&(P=n.length<g?n+" ".repeat(g-n.length):n),`${o+P} `}," ");console.log(j.bold(s))}async function mt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>hs(u.name)).map(gs);s.sort((u,A)=>u.size-A.size);let o=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+k.sep+u.name).length));ds(n,o);let m=0,g=0;s.forEach(u=>{let{sizeLabel:A}=u,{name:bt,folder:wt,gzipSizeLabel:Ct}=u,Te=(wt+k.sep+bt).length,Re=A.length;if(m+=u.size,g+=u.gzippedSize,Re<o){let ee=" ".repeat(o-Re);A+=ee}let Le=D(u.folder+k.sep)+ys(u.name);if(Te<n){let ee=" ".repeat(n-Te);Le+=ee}p.info(` ${Le} ${D(A)} ${Ct}`)});let P=`${j.bold("Total size:")} ${X(m)}`,N=`${j.bold("Gzipped size:")} ${X(g)}`;p.info(`
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
`),p.info(`${
|
|
16
|
-
`)}function Q(i=0){p.info(`${
|
|
10
|
+
`)}},p=new oe});var le={};F(le,{clearConsole:()=>ne,deepAssign:()=>y,ensureArray:()=>Mt,getLanIp:()=>M,getPkgVersion:()=>re,importJsVm:()=>pe,jsonFilter:()=>zt,timeFormat:()=>H,vCompare:()=>ae});import{ip as Lt}from"address";import At from"chalk";import{gateway4sync as Nt}from"default-gateway";import Ft from"fs-extra";function ne(){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 o=t[s],a=i[s];if(Object(o)==o&&Object(a)===a){i[s]=y(a,o);continue}i[s]=t[s]}return i}var M,re,Mt,zt,ae,H,pe,C=m(()=>{"use strict";n();M=()=>{let{int:i}=Nt();return Lt(i||"")||"127.0.0.1"},re=i=>{try{let{version:e}=Ft.readJSONSync(i);return e}catch{return}};Mt=i=>Array.isArray(i)?i:[i],zt=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),ae=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),o=Math.max(t.length,s.length),a=0;for(let f=0;f<o;f++){let u=t.length>f?t[f]:0,S=isNaN(Number(u))?u.charCodeAt():Number(u),A=s.length>f?s[f]:0,g=isNaN(Number(A))?A.charCodeAt():Number(A);if(S<g){a=-1;break}else if(S>g){a=1;break}}return a},H=i=>{i=i/1e3;let e=s=>At.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`},pe=i=>`data:text/javascript,${i}`});var Ne={};F(Ne,{chalk:()=>Gt,color:()=>h,glob:()=>R,logger:()=>p,utils:()=>le});import Gt from"chalk";import{glob as R}from"glob";var z=m(()=>{"use strict";n();T();C();O()});import It from"node:fs";import Bt from"path";import Ut from"jiti";var Ht,Fe,Me,Jt,ze=m(()=>{"use strict";n();v();O();Ht=["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"],Fe=Ut(l,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Me=async()=>Jt(),Jt=()=>{p.time("[store]GetEmpConfigPath");let i;for(let e of Ht){let t=Bt.resolve(r.root,e);if(It.existsSync(t)){i=t;break}}return p.timeEnd("[store]GetEmpConfigPath"),i}});import _t from"net";import Wt from"os";async function J(i,e="localhost"){if(i!==qt&&(i<Ge||i>ce))throw new Error(`Port number must lie between ${Ge} and ${ce}`);let t=i,s=Vt(),o;e&&!s.has(e)?o=new Set([e]):o=s;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=ce;)try{return await Qt(t,o)}catch(f){if(!a.has(f.code))throw f;t+=1}throw new Error("No available ports found")}var Ge,ce,qt,Vt,Xt,Qt,me=m(()=>{"use strict";n();Ge=1024,ce=65535,qt=443,Vt=()=>{let i=Wt.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},Xt=(i,e)=>new Promise((t,s)=>{let o=_t.createServer();o.unref(),o.on("error",s),o.listen(i,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),Qt=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Xt(i,s)}catch(o){if(!t.has(o.code))throw o}return i}});import Ie from"url";import Kt from"chalk";var fe,L,he=m(()=>{"use strict";n();T();C();fe=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:D("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:o}=this.imf;return Ie.format({protocol:t,hostname:e,port:s,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:o}=this.imf;return Ie.format({protocol:t,hostname:e,port:Kt.bold(s),pathname:o})}},L=new fe});import{exec as Yt}from"node:child_process";import{promisify as Zt}from"node:util";var Ue,Be,es,ts,He,Je=m(()=>{"use strict";n();v();O();Ue=Zt(Yt),Be=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],es=async()=>{let i=process.env.BROWSER;if(!i||!Be.includes(i)){let{stdout:e}=await Ue("ps cax");i=Be.find(t=>e.includes(t))}return i},ts=async i=>{if(process.platform==="darwin")try{let t=await es();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Ue(s,{cwd:r.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},He=ts});var ue,_,ge=m(()=>{"use strict";n();me();he();C();v();ue=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=r.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!r.empOptions.autoDevBase&&r.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=r.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=L.getLanIp(),o=this.isHttps?"https":"http",a=r.empOptions.server?.port||8e3;a=await J(a,s),r.empOptions.base=`${o}://${s}:${a}/`,r.empOptions.server=y({port:a,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${a}/ws`}},r.empOptions.server)}},_=new ue});import _e from"node:fs/promises";var P,G=m(()=>{"use strict";n();T();me();he();O();Je();C();v();ge();P=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=r.rsConfig.output?.publicPath==="auto"?"/":r.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!r.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=r.empConfig.server.host?r.empConfig.server.host:this.sf.host,this.sf.port=r.empConfig.server.port,await this.serverPort(),L.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=L.prettyPrintUrl("localhost")):(this.sf.urls=L.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(p.info(`${E("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${E("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${E("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${E("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
|
|
11
|
+
`)),this.sf.isOpenBrower&&He(this.sf.url)}async setup(e,t){p.time(`[${e}]Setup`),await r.setup(e,t),r.debug.clearLog&&ne(),p.title(`${e}`),await this.adaptServer(),p.time(`[${e}]Run`),await this.run(),p.timeEnd(`[${e}]Run`),this.afterRun(),p.timeEnd(`[${e}]Setup`)}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{server:e,https:t,http2:s}=r.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0||s===!0}getcert(){return Promise.all([_e.readFile(r.resource.key),_e.readFile(r.resource.cert)])}async serverPort(){if(_.isADB)return;let{port:e,host:t}=this.sf,s=await J(e,t);s!==e&&(this.sf.port=s,r.rsConfig.devServer?.port&&(r.rsConfig.devServer.port=s))}}});import de from"html-webpack-plugin";function ss(){let i=[`import 'core-js/${r.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
12
|
+
`);return pe(i)}var W,I,q=m(()=>{"use strict";n();C();v();W=class{constructor(){}apply(e){let{webpack:t}=e;r.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ss(),{name:void 0}).apply(e)}},I=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",s=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=s}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{de.getHooks(t).alterAssetTagGroups.tapAsync(this.PluginName,(s,o)=>{if(this.chunk&&!s.plugin.userOptions.chunks?.includes(this.chunk))return o(null,s);this.files.map(a=>{let{pos:f,...u}=a;(f==="body"?s.bodyTags:s.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o(null,s)})})}}});var V,We=m(()=>{"use strict";n();v();ge();q();V=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await _.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){r.empConfig.build.polyfill.mode==="entry"&&r.chain.plugin("empPolyfill").use(W),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 is from"node:fs";var ye,qe,Ve=m(()=>{"use strict";n();z();ze();C();G();We();ye=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 V(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:o}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),o&&(this.appEntry=o)}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:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"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,tags:[]},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 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:o}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(a,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(o=>{t==="all"?(s[`import.meta.env.${o}`]=JSON.stringify(e[o]),s[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?s[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?s[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(s[`${o}`]=JSON.stringify(e[o]))}),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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Me();if(!e||!is.existsSync(e))return;let t=await Fe(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}},qe=new ye});import os from"fs-extra";var ve,Xe,Qe=m(()=>{"use strict";n();ve=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 os.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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups={coreJs:{test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}}),this.store.chain.merge({optimization:e})}},Xe=new ve});var be,Ke,Ye=m(()=>{"use strict";n();be=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:o}=this.store.empConfig.css||{sass:{}};o.mode==="modern"&&(s.implementation=o.implementation?o.implementation:b.resolve("sass-embedded"),s.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(s.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(s.webpackImporter=o.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"}}}})}},Ke=new be});import w from"node:path";var Ce,Ze,et=m(()=>{"use strict";n();z();q();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),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(w.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(w.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),a=[s];this.entriesConfig[o]={entry:{[o]:a},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(de,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),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.join(this.store.appSrc,e),s=w.join(t,"**","*.{ts,tsx,jsx,js}"),o=await R([s],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${w.sep}`,"")),o.map(a=>{let f=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...f},w.join(t,a))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]SetDefaultEntry");let e=w.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await R([e],{windowsPathsNoEscape:!0});if(t[0]){let s=w.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)}},Ze=new Ce});import tt from"node:path";var we,st,it=m(()=>{"use strict";n();C();we=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.mode}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,polyfill:s}=this.store.empConfig.build,{externalHelpers:o}=s;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,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.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",tt.dirname(b.resolve("@swc/helpers/package.json"))),this.coreJs.path=b.resolve("core-js/package.json");let t=re(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=tt.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(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}}}}}})}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"}}}})}},st=new we});import ot from"fs";import B from"@rspack/core";var xe,rt,nt=m(()=>{"use strict";n();xe=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");ot.existsSync(e)&&ot.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.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])}},rt=new xe});var Se,at,pt=m(()=>{"use strict";n();Qe();Ye();et();it();nt();Se=class{store;async setup(e){this.store=e;let t=[Xe.setup(this.store),st.setup(this.store),rt.setup(this.store),Ze.setup(this.store),Ke.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 Se});var lt,ct=m(()=>{"use strict";n();lt={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"node:fs/promises";import x from"node:path";import ns from"node:util";import as from"webpack-chain";var Ee,r,v=m(()=>{"use strict";n();O();C();Ve();pt();ct();q();Ee=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=lt;cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=ae;deepAssign=y;getLanIp=M;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=qe,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new as,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=b(this.empResolve("package.json")),o=b(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...o},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),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.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(p.link("[Compile Config]")),console.log(ns.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("-","_")}injectTags(e=[],t="",s=""){this.chain.plugin(`${I}-${t}`).use(I,[e,t,s])}},r=new Ee});import ps from"node:fs";import k from"node:path";import{gzipSizeSync as ls}from"gzip-size";function ds(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((o,a,f)=>{let u=t[f],S=a;return u&&(S=a.length<u?a+" ".repeat(u-a.length):a),`${o+S} `}," ");console.log(j.bold(s))}async function mt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(g=>hs(g.name)).map(gs);s.sort((g,N)=>g.size-N.size);let o=Math.max(...s.map(g=>g.sizeLabel.length)),a=Math.max(...s.map(g=>(g.folder+k.sep+g.name).length));ds(a,o);let f=0,u=0;s.forEach(g=>{let{sizeLabel:N}=g,{name:bt,folder:Ct,gzipSizeLabel:wt}=g,Te=(Ct+k.sep+bt).length,Re=N.length;if(f+=g.size,u+=g.gzippedSize,Re<o){let ee=" ".repeat(o-Re);N+=ee}let Le=D(g.folder+k.sep)+ys(g.name);if(Te<a){let ee=" ".repeat(a-Te);Le+=ee}p.info(` ${Le} ${D(N)} ${wt}`)});let S=`${j.bold("Total size:")} ${X(f)}`,A=`${j.bold("Gzipped size:")} ${X(u)}`;p.info(`
|
|
13
|
+
${S}
|
|
14
|
+
${A}
|
|
15
|
+
`),p.info(`${E("\u2713")} Ready in ${H(Number(e.time))}
|
|
16
|
+
`)}function Q(i=0){p.info(`${E("\u2713")} Ready in ${H(Number(i))}`)}var cs,ms,fs,hs,us,gs,X,ys,K=m(()=>{"use strict";n();T();v();O();C();cs=/\.html$/,ms=/\.(?:js|mjs|cjs|jsx)$/,fs=/\.css$/,hs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),us=i=>i>300*1e3?te:i>100*1e3?U:se,gs=i=>{let e=i.name.split("?")[0],t=X(i.size),s=k.basename(e),o=k.join(k.basename(r.empConfig.build.outDir),k.dirname(e)),a=ps.readFileSync(k.join(r.empConfig.build.outDir,e)),f=a.length,u=ls(a),S=us(u)(X(u));return{size:f,folder:o,name:s,gzippedSize:u,sizeLabel:t,gzipSizeLabel:S}};X=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},ys=i=>ms.test(i)?U(i):fs.test(i)?E(i):cs.test(i)?j(i):ie(i)});var ft={};F(ft,{default:()=>Cs});import{rspack as vs}from"@rspack/core";import{RspackDevServer as bs}from"@rspack/dev-server";var Oe,Cs,ht=m(()=>{"use strict";n();K();O();C();G();v();Oe=class extends P{get rspackDevConfig(){return y(r.rsConfig,{stats:{all:r.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({},r.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=vs(this.rspackDevConfig);if(!r.rsConfig.devServer){p.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new bs(t,e);this.startOpen(),r.empConfig.lifeCycle.beforeDevServe&&await r.empConfig.lifeCycle.beforeDevServe(),await s.start();let o=a=>{let f=a?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Q(f.time)};r.debug.showPerformance&&e.hooks.afterDone.tap("done",o),s.middleware?.waitUntilValid(a=>{r.debug.showPerformance||o(a),r.empConfig.lifeCycle.afterDevServe&&r.empConfig.lifeCycle.afterDevServe()})}},Cs=new Oe});import ws from"https";import xs from"compression";import Ss from"cors";import Es from"express";var Y,ut=m(()=>{"use strict";n();G();Y=class extends P{app;async init(){let e=Es();e.use(xs()),e.use(Ss()),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 Pe={};F(Pe,{ServeScript:()=>Z,default:()=>js});import Os from"node:fs";import Ps from"node:fs/promises";import ks from"path";import $s from"express";var Z,js,ke=m(()=>{"use strict";n();K();O();v();ut();Z=class extends Y{timing=0;async run(){if(this.timing=Date.now(),!Os.existsSync(r.outDir))return p.sysError(`emp serve must be executed after emp build,${r.outDir} not exist!`);r.empConfig.lifeCycle.beforeServe&&await r.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=r.resolve(r.rsConfig.output?.path);this.app.use($s.static(e));let t=await Ps.readFile(ks.join(e,"index.html"),"utf8");this.app.get("*",(s,o)=>o.send(t))}async onReady(){Q(Date.now()-this.timing),r.empConfig.lifeCycle.afterServe&&await r.empConfig.lifeCycle.afterServe()}},js=new Z});var gt={};F(gt,{default:()=>Ts});import{rspack as Ds}from"@rspack/core";var $e,Ts,dt=m(()=>{"use strict";n();K();O();G();v();$e=class extends P{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(()=>(ke(),Pe));await e.setup("serve",r.cliOptions)}async run(){await r.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!r.cliOptions.watch,this.isuseServe=!!r.cliOptions.serve,this.rspackConfig=r.rsConfig,this.isWatchMode&&this.watchMode(),Ds(this.rspackConfig,async(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await mt(t),this.startServe(),await r.empConfig.lifeCycle.afterBulid()})}},Ts=new $e});n();import{rspack as qr}from"@rspack/core";n();v();import Rs from"node:process";import{program as $}from"commander";function yt(){$.version(r.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(()=>(ht(),ft));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(()=>(dt(),gt));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(()=>(ke(),Pe));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 vt from"node:fs/promises";import je from"node: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?['"](.+)['"]/,Ns=/import\(['"]([^;\n]+?)['"]\)/,De=class{list=[];outDir=r.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 R([`${r.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=r.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 vt.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Ls,o=>{let a=o.match(As);if(a||(a=o.match(Ns)),a&&a[1]){let f=a[1];if(!f.startsWith("."))return o;let u=je.resolve(je.dirname(e),f).replace(this.outDir,this.aliasName);return o.replace(a[1],u)}return o});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 vt.writeFile(je.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Fs=new De;v();z();function Kr(i){return i}export{Kr as defineConfig,Fs as dts,
|
|
18
|
+
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await vt.writeFile(je.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Fs=new De;v();z();function Kr(i){return i}export{Kr as defineConfig,Fs as dts,Ne as empHelper,qr as rspack,yt as runScript,r as store};
|