@empjs/cli 3.10.0-beta.5 → 3.10.0
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 +2 -2
- package/dist/index.js +2 -2
- package/package.json +35 -7
- package/{emp-tsconfig.json → tsconfig/base.json} +1 -4
- package/tsconfig/react.json +7 -0
- package/tsconfig/vue.json +6 -0
- package/types/base/emp.d.ts +23 -0
- package/types/base/file.d.ts +42 -0
- package/types/base/index.d.ts +3 -0
- package/types/base/style.d.ts +24 -0
- package/types/react/index.d.ts +2 -0
- package/types/react/react.d.ts +6 -0
- package/types/vue/index.d.ts +2 -0
- package/types/vue/vue.d.ts +5 -0
- package/client.d.ts +0 -110
package/dist/index.cjs
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
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
|
-
`)}},n=new z});var ce,We,me,ks,qe,Xe,Ke,Qe,J=c(()=>{"use strict";o();ce=l(require("fs"),1),We=require("jiti"),me=l(require("path"),1);S();O();ks=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],qe=(0,We.createJiti)(__filename,{interopDefault:!0}),Xe=async()=>{n.time("[store]GetEmpConfigPath");let s=ks.map(i=>me.default.resolve(p.root,i)),e=await Promise.all(s.map(i=>ce.default.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,r)=>e[r]);return n.timeEnd("[store]GetEmpConfigPath"),t},Ke=async()=>{let s=me.default.join(p.root,"tsconfig.json");return await ce.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Qe=()=>{let s=[__filename];return p.rootPaths.pkg&&s.push(p.rootPaths.pkg),p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ge={};R(ge,{clearConsole:()=>he,deepAssign:()=>v,ensureArray:()=>Os,getLanIp:()=>D,getPkgVersion:()=>ue,importJsVm:()=>fe,jsonFilter:()=>Ps,timeFormat:()=>W,vCompare:()=>V});function he(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function v(s,...e){for(let t of e)for(let i in t){let r=t[i],a=s[i];if(Object(r)==r&&Object(a)===a){s[i]=v(a,r);continue}s[i]=t[i]}return s}var Ye,Ze,et,tt,D,ue,Os,Ps,V,W,fe,w=c(()=>{"use strict";o();Ye=require("address"),Ze=l(require("chalk"),1),et=require("default-gateway"),tt=l(require("fs-extra"),1),D=()=>{let s="127.0.0.1";try{let{int:e}=(0,et.gateway4sync)();return(0,Ye.ip)(e||"")||s}catch{return s}},ue=s=>{try{let{version:e}=tt.default.readJSONSync(s);return e}catch{return}};Os=s=>Array.isArray(s)?s:[s],Ps=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),V=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),a=0;for(let u=0;u<r;u++){let f=t.length>u?t[u]:0,y=isNaN(Number(f))?f.charCodeAt():Number(f),j=i.length>u?i[u]:0,g=isNaN(Number(j))?j.charCodeAt():Number(j);if(y<g){a=-1;break}else if(y>g){a=1;break}}return a},W=s=>{s=s/1e3;let e=i=>Ze.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},fe=s=>`data:text/javascript,${s}`});var de,st,ye=c(()=>{"use strict";o();de=l(require("@empjs/chain"),1),st={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var ve={};R(ve,{chalk:()=>it.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ge});var it,F,G=c(()=>{"use strict";o();it=l(require("chalk"),1),F=require("glob");A();O();w()});var q,rt=c(()=>{"use strict";o();q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){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 be,ot,nt=c(()=>{"use strict";o();G();J();w();rt();be=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},v(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new q(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}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={}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0,warnRuleAsWarning:!0},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,cache:this.cache!==!1,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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,a={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}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,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)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return v({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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await qe(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}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}},ot=new be});var pt,Ce,at,lt=c(()=>{"use strict";o();pt=l(require("fs-extra"),1);J();Ce=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Qe(),version:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,lazyBarrel:!0,inlineConst:!0,inlineEnum:!0,typeReexportsPresence:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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 pt.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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})}},at=new Ce});var we,ct,mt=c(()=>{"use strict";o();we=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},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"}}}})}},ct=new we});function Es(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
9
|
+
`)}},n=new z});var ce,We,me,ks,qe,Xe,Ke,Qe,J=c(()=>{"use strict";o();ce=l(require("fs"),1),We=require("jiti"),me=l(require("path"),1);S();O();ks=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],qe=(0,We.createJiti)(__filename,{interopDefault:!0}),Xe=async()=>{n.time("[store]GetEmpConfigPath");let s=ks.map(i=>me.default.resolve(p.root,i)),e=await Promise.all(s.map(i=>ce.default.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,r)=>e[r]);return n.timeEnd("[store]GetEmpConfigPath"),t},Ke=async()=>{let s=me.default.join(p.root,"tsconfig.json");return await ce.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Qe=()=>{let s=[__filename];return p.rootPaths.pkg&&s.push(p.rootPaths.pkg),p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ge={};R(ge,{clearConsole:()=>he,deepAssign:()=>v,ensureArray:()=>Os,getLanIp:()=>D,getPkgVersion:()=>ue,importJsVm:()=>fe,jsonFilter:()=>Ps,timeFormat:()=>W,vCompare:()=>V});function he(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function v(s,...e){for(let t of e)for(let i in t){let r=t[i],a=s[i];if(Object(r)==r&&Object(a)===a){s[i]=v(a,r);continue}s[i]=t[i]}return s}var Ye,Ze,et,tt,D,ue,Os,Ps,V,W,fe,w=c(()=>{"use strict";o();Ye=require("address"),Ze=l(require("chalk"),1),et=require("default-gateway"),tt=l(require("fs-extra"),1),D=()=>{let s="127.0.0.1";try{let{int:e}=(0,et.gateway4sync)();return(0,Ye.ip)(e||"")||s}catch{return s}},ue=s=>{try{let{version:e}=tt.default.readJSONSync(s);return e}catch{return}};Os=s=>Array.isArray(s)?s:[s],Ps=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),V=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),a=0;for(let u=0;u<r;u++){let f=t.length>u?t[u]:0,y=isNaN(Number(f))?f.charCodeAt():Number(f),j=i.length>u?i[u]:0,g=isNaN(Number(j))?j.charCodeAt():Number(j);if(y<g){a=-1;break}else if(y>g){a=1;break}}return a},W=s=>{s=s/1e3;let e=i=>Ze.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},fe=s=>`data:text/javascript,${s}`});var de,st,ye=c(()=>{"use strict";o();de=l(require("@empjs/chain"),1),st={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var ve={};R(ve,{chalk:()=>it.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ge});var it,F,G=c(()=>{"use strict";o();it=l(require("chalk"),1),F=require("glob");A();O();w()});var q,rt=c(()=>{"use strict";o();q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){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 be,ot,nt=c(()=>{"use strict";o();G();J();w();rt();be=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},v(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new q(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}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={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0,warnRuleAsWarning:!0},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,cache:this.cache!==!1,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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,a={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}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,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)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return v({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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await qe(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}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}},ot=new be});var pt,Ce,at,lt=c(()=>{"use strict";o();pt=l(require("fs-extra"),1);J();Ce=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Qe(),version:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,lazyBarrel:!0,inlineConst:!0,inlineEnum:!0,typeReexportsPresence:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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 pt.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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})}},at=new Ce});var we,ct,mt=c(()=>{"use strict";o();we=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},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"}}}})}},ct=new we});function Es(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
10
|
`);return fe(s)}var K,X,I,Q=c(()=>{"use strict";o();K=l(require("html-webpack-plugin"),1);w();S();X=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Es(),{name:void 0}).apply(e)}},I=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{K.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:a,...u}=r;(a==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});var b,xe,ut,ht=c(()=>{"use strict";o();b=l(require("path"),1);G();Q();xe=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,t?`injectTags-${t}`:"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){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(b.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),a=[i];this.entriesConfig[r]={entry:{[r]:a},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(K.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(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=b.default.join(this.store.appSrc,e),i=b.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,F.glob)([i],{windowsPathsNoEscape:!0});r=r.map(a=>a.replace(`${t}${b.default.sep}`,"")),r.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},b.default.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.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,F.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let i=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(i,this.store.empConfig.html,t[0])}n.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)}},ut=new xe});var Se,ke,ft,gt=c(()=>{"use strict";o();Se=l(require("path"),1);w();ke=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.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},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:i}=this.store.empConfig.build,{externalHelpers:r}=i;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:v(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",Se.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ue(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Se.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:i}=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:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.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.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),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"}}}})}},ft=new ke});var P,Oe,dt,Pe,yt,vt=c(()=>{"use strict";o();P=l(require("@rspack/core"),1),Oe=l(require("fs"),1),dt=require("ts-checker-rspack-plugin");Q();Pe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(X)}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"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(dt.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(P.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Oe.default.existsSync(e)&&Oe.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(P.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(P.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(P.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=P.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[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])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(P.default.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(P.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(P.default.experiments.CssChunkingPlugin,[{}])}},yt=new Pe});var Ee,bt,Ct=c(()=>{"use strict";o();lt();mt();ht();gt();vt();Ee=class{store;async setup(e){this.store=e;let t=[at.setup(this.store),ft.setup(this.store),yt.setup(this.store),ut.setup(this.store),ct.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()}},bt=new Ee});async function Y(s,e=void 0){if(s!==js&&(s<wt||s>je))throw new Error(`Port number must lie between ${wt} and ${je}`);let t=s,i=$s(),r;e&&!i.has(e)?r=new Set([e]):r=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=je;)try{return await Ds(t,r)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var xt,St,wt,je,js,$s,Ts,Ds,kt=c(()=>{"use strict";o();xt=l(require("net"),1),St=l(require("os"),1),wt=1024,je=65535,js=443,$s=()=>{let s=St.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Ts=(s,e)=>new Promise((t,i)=>{let r=xt.default.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:a}=r.address();r.close(()=>{t(a)})})}),Ds=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Ts(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});var Ot,$e,Te,Z,Pt=c(()=>{"use strict";o();Ot=l(require("chalk"),1);A();$e=l(require("url"),1);w();Te=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:L("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==="::",i;if(t){i="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 i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=D;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return $e.default.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return $e.default.format({protocol:t,hostname:e,port:Ot.default.bold(i),pathname:r})}},Z=new Te});var jt,$t,Tt,Et,Rs,Ns,Dt,Rt=c(()=>{"use strict";o();jt=require("child_process"),$t=require("util");S();O();Tt=(0,$t.promisify)(jt.exec),Et=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Rs=async()=>{let s=process.env.BROWSER;if(!s||!Et.includes(s)){let{stdout:e}=await Tt("ps cax");s=Et.find(t=>e.includes(t))}return s},Ns=async s=>{if(process.platform==="darwin")try{let t=await Rs();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Tt(i,{cwd:p.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},Dt=Ns});var De,ee,Nt=c(()=>{"use strict";o();De=l(require("fs/promises"),1);G();A();kt();Pt();Rt();w();ee=class{ip=D();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await Y(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await Y(e.empConfig.server.port)),Z.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Z.prettyPrintUrl("localhost")):(this.urls=Z.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${x("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${x("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${x("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${x("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
|
|
11
11
|
`)),this.isOpenBrower&&Dt(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([De.default.readFile(e.resource.key),De.default.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await Y(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Lt,C,At,Re,Ne,p,S=c(()=>{"use strict";o();Lt=l(require("fs/promises"),1),C=l(require("path"),1),At=l(require("util"),1),Re=require("@rspack/core");J();O();w();ye();nt();Ct();Nt();ye();Q();Ne=class{rspack=Re.rspack;rspackVersion=Re.rspack.rspackVersion;isOldRspack=V(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=C.default.resolve(__dirname,__filename).replace(`${C.default.sep}dist${C.default.sep}index.js`,"");empSource=C.default.resolve(this.empRoot,"dist");resolve=e=>C.default.isAbsolute(e)?e:C.default.resolve(this.root,e);empResolve=e=>C.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=st;server=new ee(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};async setup(e,t){n.time("[store]Setup");let[i,r]=await Promise.all([Xe(),Ke()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=r,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(e,t),this.empConfig=ot,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new de.default,await bt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,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 i=require(this.empResolve("package.json")),r=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=C.default.join(this.empRoot,"resource"),this.resource.cert=C.default.join(this.resource.dir,"emp.cert"),this.resource.key=C.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)}loggerExtensionName="";setLoggerExtensionName(e){this.loggerExtensionName=e}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}${this.loggerExtensionName?" "+this.loggerExtensionName:""}`,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=C.default.join(this.root,this.debug.showRsconfig);Lt.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"?v(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(At.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.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=V;deepAssign=v;getLanIp=D;injectTags(e=[],t="",i=""){this.chain.plugin(`${I}-${t}`).use(I,[e,t,i])}},p=new Ne});function Is(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,a,u)=>{let f=t[u],y=a;return f&&(y=a.length<f?a+" ".repeat(f-a.length):a),`${r+y} `}," ");console.log(N.bold(i))}async function Ft(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(g=>zs(g.name)).map(Gs);i.sort((g,k)=>g.size-k.size);let r=Math.max(...i.map(g=>g.sizeLabel.length)),a=Math.max(...i.map(g=>(g.folder+E.default.sep+g.name).length));Is(a,r);let u=0,f=0;i.forEach(g=>{let{sizeLabel:k}=g,{name:ps,folder:as,gzipSizeLabel:ls}=g,Be=(as+E.default.sep+ps).length,He=k.length;if(u+=g.size,f+=g.gzippedSize,He<r){let ne=" ".repeat(r-He);k+=ne}let _e=L(g.folder+E.default.sep)+Us(g.name);if(Be<a){let ne=" ".repeat(a-Be);_e+=ne}n.info(` ${_e} ${L(k)} ${ls}`)});let y=`${N.bold("Total size:")} ${te(u)}`,j=`${N.bold("Gzipped size:")} ${te(f)}`;n.info(`
|
|
12
12
|
${y}
|
|
13
13
|
${j}
|
|
14
14
|
`),n.info(`${x("\u2713")} Ready in ${W(Number(e.time))}
|
|
15
15
|
`)}function se(s=0){n.info(`${x("\u2713")} Ready in ${W(Number(s))}`)}var Mt,E,zt,Ls,As,Ms,zs,Fs,Gs,te,Us,ie=c(()=>{"use strict";o();Mt=l(require("fs"),1),E=l(require("path"),1),zt=require("gzip-size");A();S();O();w();Ls=/\.html$/,As=/\.(?:js|mjs|cjs|jsx)$/,Ms=/\.css$/,zs=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Fs=s=>s>300*1e3?pe:s>100*1e3?_:ae,Gs=s=>{let e=s.name.split("?")[0],t=te(s.size),i=E.default.basename(e),r=E.default.join(E.default.basename(p.empConfig.build.outDir),E.default.dirname(e)),a=Mt.default.readFileSync(E.default.join(p.empConfig.build.outDir,e)),u=a.length,f=(0,zt.gzipSizeSync)(a),y=Fs(f)(te(f));return{size:u,folder:r,name:i,gzippedSize:f,sizeLabel:t,gzipSizeLabel:y}};te=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Us=s=>As.test(s)?_(s):Ms.test(s)?x(s):Ls.test(s)?N(s):le(s)});var $,re=c(()=>{"use strict";o();O();w();S();$=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&he(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});var Gt,It,U,Ut=c(()=>{"use strict";o();Gt=require("@rspack/dev-server"),It=l(require("connect"),1),U=class{async setup(e,t,i,r=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let a=new Gt.RspackDevServer(t.devServer,e);return await a.start(),a.middleware?.waitUntilValid(r),a}async beforeCompiler(e){return e.devServer.app=()=>(0,It.default)(),e.devServer.server&&e.devServer.server.type==="https"&&(e.devServer.server.type="http2"),e}}});var Le,Bt,Ht,_t,Jt,Vt,Ae,Wt,qt,M,B,Xt=c(()=>{"use strict";o();Le=l(require("fs"),1),Bt=l(require("fs/promises"),1),Ht=l(require("compression"),1),_t=l(require("connect"),1),Jt=l(require("cors"),1),Vt=l(require("http2"),1),Ae=l(require("path"),1),Wt=l(require("serve-static"),1),qt=require("url"),M=(0,_t.default)();M.use((0,Ht.default)());M.use((0,Jt.default)());B=class{async setup(e,t=()=>{}){let i="index",r=Object.keys(e.rsConfig.entry);if(r.length===0)return e.logger.sysError("emp serve must include entry!");if(r.includes(i)||(i=r[0]),!Le.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let a=e.resolve(e.rsConfig.output?.path);M.use((0,Wt.default)(a));let u=await Bt.default.readFile(Ae.default.join(a,`${i}.html`),"utf8");if(M.use((f,y,j)=>{let k=(0,qt.parse)(f.url||"",!0).pathname;if(k&&k!=="/"&&Le.default.existsSync(Ae.default.join(a,k)))return j();y.setHeader("Content-Type","text/html"),y.end(u)}),e.server.isHttps){let{key:f,cert:y}=await e.server.getcert();Vt.default.createSecureServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:f,cert:y,allowHTTP1:!0},M).listen(e.server.port,t)}else require("http").createServer(M).listen(e.server.port,t)}}});var Me=c(()=>{"use strict";o();Ut();Xt()});var Yt={};R(Yt,{default:()=>Bs});var Qt,Kt,ze,Bs,Zt=c(()=>{"use strict";o();Qt=require("@rspack/core");ie();w();re();Me();S();Kt=new U,ze=class extends ${get stats(){return{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=v(p.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:p.server.port}}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:r}=await p.server.getcert();t.server={type:"https",options:{key:i,cert:r}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await Kt.beforeCompiler(t);let i=(0,Qt.rspack)(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Kt.setup(i,t,p,async r=>{this.showTimeDone(r),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});se(t.time)}},Bs=new ze});var Fe={};R(Fe,{ServeScript:()=>oe,default:()=>_s});var Hs,es,oe,_s,Ge=c(()=>{"use strict";o();ie();re();Me();S();Hs=new B,es=0,oe=class extends ${async run(){es=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Hs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),se(Date.now()-es),await p.empConfig.lifeCycle.afterServe()}},_s=new oe});var ss={};R(ss,{default:()=>Js});var ts,Ie,Js,is=c(()=>{"use strict";o();ts=require("@rspack/core");ie();O();re();S();Ie=class extends ${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(()=>(Ge(),Fe));await e.setup("serve",p.cliOptions)}async run(){await p.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!p.cliOptions.watch,this.isuseServe=!!p.cliOptions.serve,this.rspackConfig=p.rsConfig,this.isWatchMode&&this.watchMode(),(0,ts.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
|
|
16
|
-
`),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Ft(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Js=new Ie});var Ws={};R(Ws,{Logger:()=>z,color:()=>h,defineConfig:()=>Vs,empHelper:()=>ve,program:()=>ns.program,rspack:()=>os.rspack,runScript:()=>Ue,store:()=>p});module.exports=gs(Ws);o();var os=require("@rspack/core"),ns=require("commander");o();var rs=l(require("process"),1),T=require("commander");var Ve={name:"@empjs/cli",version:"3.10.0
|
|
16
|
+
`),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Ft(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Js=new Ie});var Ws={};R(Ws,{Logger:()=>z,color:()=>h,defineConfig:()=>Vs,empHelper:()=>ve,program:()=>ns.program,rspack:()=>os.rspack,runScript:()=>Ue,store:()=>p});module.exports=gs(Ws);o();var os=require("@rspack/core"),ns=require("commander");o();var rs=l(require("process"),1),T=require("commander");var Ve={name:"@empjs/cli",version:"3.10.0",description:"emp",license:"MIT",type:"module",files:["dist","bin","resource","template","types","tsconfig"],maintainers:["xuhongbin","ckken","doerme"],repository:{type:"git",url:"git+https://github.com/empjs/emp.git",directory:"packages/cli"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},keywords:["rspack","rust","typescript"],bin:{emp:"./bin/emp.js"},main:"dist/index.js",types:"dist/index.d.ts",exports:{".":{import:{types:"./dist/index.d.ts",default:"./dist/index.js"},require:{types:"./dist/index.d.cts",default:"./dist/index.cjs"}},"./emp-tsconfig.json":{default:"./tsconfig/react.json"},"./tsconfig/base":{default:"./tsconfig/base.json"},"./tsconfig/react":{default:"./tsconfig/react.json"},"./tsconfig/vue":{default:"./tsconfig/vue.json"},"./client":{types:"./types/react/index.d.ts",default:"./types/react/index.d.ts"},"./types/base":{types:"./types/base/index.d.ts",default:"./types/base/index.d.ts"},"./types/vue":{types:"./types/vue/index.d.ts",default:"./types/vue/index.d.ts"},"./types/react":{types:"./types/react/index.d.ts",default:"./types/react/index.d.ts"}},scripts:{dev:"tsup --watch --env.ENV dev",build:"tsup --env.ENV prod",ph:"pnpm publish --no-git-checks"},engines:{node:">=18.0.0"},author:"Ken",devDependencies:{"@types/compression":"^1.7.2","@types/connect":"^3.4.38","@types/cors":"^2.8.12","@types/default-gateway":"^7.2.1","@types/fs-extra":"^11.0.4","@types/node":"^20.8.7","@types/react":"^18.3.2","@types/serve-static":"^1.15.8","@types/watchpack":"^2.4.3","@types/webpack":"^5.28.4","@types/webpack-bundle-analyzer":"^4.6.2","@types/webpack-sources":"^3.2.2",vue:"^3.5.21"},dependencies:{"@empjs/chain":"workspace:*","@rsdoctor/rspack-plugin":"1.2.3","@rspack/core":"1.5.4","@rspack/dev-server":"1.1.4","@swc/helpers":"^0.5.17","@vue/tsconfig":"^0.8.1",address:"^2.0.2",chalk:"^5.3.0",commander:"11.1.0",compression:"1.8.1",connect:"3.7.0","core-js":"^3.41.0",cors:"2.8.5","default-gateway":"7.2.2","fs-extra":"11.3.1",glob:"11.0.3","gzip-size":"7.0.0","html-webpack-plugin":"5.6.4",jiti:"2.0.0","less-loader":"^12.2.0",open:"10.2.0","sass-embedded":"1.91.0","sass-loader":"16.0.5","serve-static":"2.2.0","ts-checker-rspack-plugin":"1.1.5","typescript-plugin-css-modules":"5.2.0","webpack-bundle-analyzer":"4.10.2"}};async function Ue(){T.program.version(Ve.version,"-v, --version").usage("<command> [options]"),T.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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Zt(),Yt));await e.setup("dev",s)}),T.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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(is(),ss));await e.setup("build",s)}),T.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Ge(),Fe));await e.setup("serve",s)}),T.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(s=>{}),T.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(s=>{}),T.program.parse(rs.default.argv)}S();O();G();function Vs(s){return s}0&&(module.exports={Logger,color,defineConfig,empHelper,program,rspack,runScript,store});
|
|
17
17
|
if (module.exports.default) module.exports = module.exports.default;
|
package/dist/index.js
CHANGED
|
@@ -7,11 +7,11 @@ var Nt=Object.defineProperty;var v=(s=>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
|
-
`)}},n=new H});import Ae from"fs";import{createJiti as _t}from"jiti";import Me from"path";var Vt,ze,Fe,Ge,Ie,J=m(()=>{"use strict";o();k();P();Vt=["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"],ze=_t(l,{interopDefault:!0}),Fe=async()=>{n.time("[store]GetEmpConfigPath");let s=Vt.map(i=>Me.resolve(a.root,i)),e=await Promise.all(s.map(i=>Ae.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,r)=>e[r]);return n.timeEnd("[store]GetEmpConfigPath"),t},Ge=async()=>{let s=Me.join(a.root,"tsconfig.json");return await Ae.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Ie=()=>{let s=[l];return a.rootPaths.pkg&&s.push(a.rootPaths.pkg),a.rootPaths.empConfig&&s.push(a.rootPaths.empConfig),a.rootPaths.tsConfig&&s.push(a.rootPaths.tsConfig),s}});var ue={};z(ue,{clearConsole:()=>ce,deepAssign:()=>b,ensureArray:()=>Qt,getLanIp:()=>D,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>Yt,timeFormat:()=>V,vCompare:()=>_});import{ip as Wt}from"address";import qt from"chalk";import{gateway4sync as Xt}from"default-gateway";import Kt from"fs-extra";function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function b(s,...e){for(let t of e)for(let i in t){let r=t[i],p=s[i];if(Object(r)==r&&Object(p)===p){s[i]=b(p,r);continue}s[i]=t[i]}return s}var D,le,Qt,Yt,_,V,me,C=m(()=>{"use strict";o();D=()=>{let s="127.0.0.1";try{let{int:e}=Xt();return Wt(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Kt.readJSONSync(s);return e}catch{return}};Qt=s=>Array.isArray(s)?s:[s],Yt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),_=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),p=0;for(let u=0;u<r;u++){let f=t.length>u?t[u]:0,d=isNaN(Number(f))?f.charCodeAt():Number(f),E=i.length>u?i[u]:0,g=isNaN(Number(E))?E.charCodeAt():Number(E);if(d<g){p=-1;break}else if(d>g){p=1;break}}return p},V=s=>{s=s/1e3;let e=i=>qt.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},me=s=>`data:text/javascript,${s}`});import Be from"@empjs/chain";var Ue,he=m(()=>{"use strict";o();Ue={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var He={};z(He,{chalk:()=>Zt,color:()=>h,glob:()=>W,logger:()=>n,utils:()=>ue});import Zt from"chalk";import{glob as W}from"glob";var F=m(()=>{"use strict";o();A();P();C()});var q,Je=m(()=>{"use strict";o();q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){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 fe,_e,Ve=m(()=>{"use strict";o();F();J();C();Je();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},b(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new q(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}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={}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0,warnRuleAsWarning:!0},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,cache:this.cache!==!1,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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return b({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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await ze(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},_e=new fe});import es from"fs-extra";var ge,We,qe=m(()=>{"use strict";o();J();ge=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Ie(),version:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,lazyBarrel:!0,inlineConst:!0,inlineEnum:!0,typeReexportsPresence:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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 es.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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})}},We=new ge});var de,Xe,Ke=m(()=>{"use strict";o();de=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:v.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:v.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Xe=new de});import ye from"html-webpack-plugin";function ts(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
|
+
`)}},n=new H});import Ae from"fs";import{createJiti as _t}from"jiti";import Me from"path";var Vt,ze,Fe,Ge,Ie,J=m(()=>{"use strict";o();k();P();Vt=["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"],ze=_t(l,{interopDefault:!0}),Fe=async()=>{n.time("[store]GetEmpConfigPath");let s=Vt.map(i=>Me.resolve(a.root,i)),e=await Promise.all(s.map(i=>Ae.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,r)=>e[r]);return n.timeEnd("[store]GetEmpConfigPath"),t},Ge=async()=>{let s=Me.join(a.root,"tsconfig.json");return await Ae.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Ie=()=>{let s=[l];return a.rootPaths.pkg&&s.push(a.rootPaths.pkg),a.rootPaths.empConfig&&s.push(a.rootPaths.empConfig),a.rootPaths.tsConfig&&s.push(a.rootPaths.tsConfig),s}});var ue={};z(ue,{clearConsole:()=>ce,deepAssign:()=>b,ensureArray:()=>Qt,getLanIp:()=>D,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>Yt,timeFormat:()=>V,vCompare:()=>_});import{ip as Wt}from"address";import qt from"chalk";import{gateway4sync as Xt}from"default-gateway";import Kt from"fs-extra";function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function b(s,...e){for(let t of e)for(let i in t){let r=t[i],p=s[i];if(Object(r)==r&&Object(p)===p){s[i]=b(p,r);continue}s[i]=t[i]}return s}var D,le,Qt,Yt,_,V,me,C=m(()=>{"use strict";o();D=()=>{let s="127.0.0.1";try{let{int:e}=Xt();return Wt(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Kt.readJSONSync(s);return e}catch{return}};Qt=s=>Array.isArray(s)?s:[s],Yt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),_=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),p=0;for(let u=0;u<r;u++){let f=t.length>u?t[u]:0,d=isNaN(Number(f))?f.charCodeAt():Number(f),E=i.length>u?i[u]:0,g=isNaN(Number(E))?E.charCodeAt():Number(E);if(d<g){p=-1;break}else if(d>g){p=1;break}}return p},V=s=>{s=s/1e3;let e=i=>qt.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},me=s=>`data:text/javascript,${s}`});import Be from"@empjs/chain";var Ue,he=m(()=>{"use strict";o();Ue={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var He={};z(He,{chalk:()=>Zt,color:()=>h,glob:()=>W,logger:()=>n,utils:()=>ue});import Zt from"chalk";import{glob as W}from"glob";var F=m(()=>{"use strict";o();A();P();C()});var q,Je=m(()=>{"use strict";o();q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){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 fe,_e,Ve=m(()=>{"use strict";o();F();J();C();Je();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},b(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new q(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}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={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0,warnRuleAsWarning:!0},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,cache:this.cache!==!1,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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return b({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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await ze(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},_e=new fe});import es from"fs-extra";var ge,We,qe=m(()=>{"use strict";o();J();ge=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Ie(),version:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,lazyBarrel:!0,inlineConst:!0,inlineEnum:!0,typeReexportsPresence:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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 es.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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})}},We=new ge});var de,Xe,Ke=m(()=>{"use strict";o();de=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:v.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:v.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Xe=new de});import ye from"html-webpack-plugin";function ts(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
11
11
|
`);return me(s)}var X,G,K=m(()=>{"use strict";o();C();k();X=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ts(),{name:void 0}).apply(e)}},G=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{ye.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:p,...u}=r;(p==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});import w from"path";var ve,Qe,Ye=m(()=>{"use strict";o();F();K();ve=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,t?`injectTags-${t}`:"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){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(w.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),p=[i];this.entriesConfig[r]={entry:{[r]:p},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(ye,[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(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=w.join(this.store.appSrc,e),i=w.join(t,"**","*.{ts,tsx,jsx,js}"),r=await W([i],{windowsPathsNoEscape:!0});r=r.map(p=>p.replace(`${t}${w.sep}`,"")),r.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},w.join(t,p))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.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 W([e],{windowsPathsNoEscape:!0});if(t[0]){let i=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(i,this.store.empConfig.html,t[0])}n.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)}},Qe=new ve});import Ze from"path";var be,et,tt=m(()=>{"use strict";o();C();be=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.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},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:i}=this.store.empConfig.build,{externalHelpers:r}=i;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:b(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",Ze.dirname(v.resolve("@swc/helpers/package.json"))),this.coreJs.path=v.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Ze.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:i}=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:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.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.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},et=new be});import j from"@rspack/core";import st from"fs";import{TsCheckerRspackPlugin as ss}from"ts-checker-rspack-plugin";var Ce,it,rt=m(()=>{"use strict";o();K();Ce=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(X)}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"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(ss,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(j.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");st.existsSync(e)&&st.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(j.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(j.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(j.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=j;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=v("@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])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(j.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(j.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(j.experiments.CssChunkingPlugin,[{}])}},it=new Ce});var we,ot,nt=m(()=>{"use strict";o();qe();Ke();Ye();tt();rt();we=class{store;async setup(e){this.store=e;let t=[We.setup(this.store),et.setup(this.store),it.setup(this.store),Qe.setup(this.store),Xe.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ot=new we});import is from"net";import rs from"os";async function Q(s,e=void 0){if(s!==os&&(s<pt||s>xe))throw new Error(`Port number must lie between ${pt} and ${xe}`);let t=s,i=ns(),r;e&&!i.has(e)?r=new Set([e]):r=i;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=xe;)try{return await as(t,r)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var pt,xe,os,ns,ps,as,at=m(()=>{"use strict";o();pt=1024,xe=65535,os=443,ns=()=>{let s=rs.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},ps=(s,e)=>new Promise((t,i)=>{let r=is.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:p}=r.address();r.close(()=>{t(p)})})}),as=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await ps(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});import ls from"chalk";import lt from"url";var Se,Y,ct=m(()=>{"use strict";o();A();C();Se=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:L("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==="::",i;if(t){i="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 i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=D;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return lt.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return lt.format({protocol:t,hostname:e,port:ls.bold(i),pathname:r})}},Y=new Se});import{exec as cs}from"child_process";import{promisify as ms}from"util";var ut,mt,us,hs,ht,ft=m(()=>{"use strict";o();k();P();ut=ms(cs),mt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],us=async()=>{let s=process.env.BROWSER;if(!s||!mt.includes(s)){let{stdout:e}=await ut("ps cax");s=mt.find(t=>e.includes(t))}return s},hs=async s=>{if(process.platform==="darwin")try{let t=await us();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await ut(i,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},ht=hs});import gt from"fs/promises";var Z,dt=m(()=>{"use strict";o();F();A();at();ct();ft();C();Z=class{ip=D();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await Q(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await Q(e.empConfig.server.port)),Y.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Y.prettyPrintUrl("localhost")):(this.urls=Y.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
|
|
12
12
|
`)),this.isOpenBrower&&ht(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([gt.readFile(e.resource.key),gt.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await Q(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});import fs from"fs/promises";import x from"path";import gs from"util";import{rspack as yt}from"@rspack/core";var ke,a,k=m(()=>{"use strict";o();J();P();C();he();Ve();nt();dt();he();K();ke=class{rspack=yt;rspackVersion=yt.rspackVersion;isOldRspack=_(this.rspackVersion,"1.0.0")===-1;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=Ue;server=new Z(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};async setup(e,t){n.time("[store]Setup");let[i,r]=await Promise.all([Fe(),Ge()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=r,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(e,t),this.empConfig=_e,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Be,await ot.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,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 i=v(this.empResolve("package.json")),r=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}loggerExtensionName="";setLoggerExtensionName(e){this.loggerExtensionName=e}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}${this.loggerExtensionName?" "+this.loggerExtensionName:""}`,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);fs.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"?b(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(gs.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=_;deepAssign=b;getLanIp=D;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},a=new ke});import ds from"fs";import $ from"path";import{gzipSizeSync as ys}from"gzip-size";function ks(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,p,u)=>{let f=t[u],d=p;return f&&(d=p.length<f?p+" ".repeat(f-p.length):p),`${r+d} `}," ");console.log(N.bold(i))}async function vt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(g=>ws(g.name)).map(Ss);i.sort((g,O)=>g.size-O.size);let r=Math.max(...i.map(g=>g.sizeLabel.length)),p=Math.max(...i.map(g=>(g.folder+$.sep+g.name).length));ks(p,r);let u=0,f=0;i.forEach(g=>{let{sizeLabel:O}=g,{name:Tt,folder:Dt,gzipSizeLabel:Rt}=g,Te=(Dt+$.sep+Tt).length,De=O.length;if(u+=g.size,f+=g.gzippedSize,De<r){let oe=" ".repeat(r-De);O+=oe}let Re=L(g.folder+$.sep)+Os(g.name);if(Te<p){let oe=" ".repeat(p-Te);Re+=oe}n.info(` ${Re} ${L(O)} ${Rt}`)});let d=`${N.bold("Total size:")} ${ee(u)}`,E=`${N.bold("Gzipped size:")} ${ee(f)}`;n.info(`
|
|
13
13
|
${d}
|
|
14
14
|
${E}
|
|
15
15
|
`),n.info(`${S("\u2713")} Ready in ${V(Number(e.time))}
|
|
16
16
|
`)}function te(s=0){n.info(`${S("\u2713")} Ready in ${V(Number(s))}`)}var vs,bs,Cs,ws,xs,Ss,ee,Os,se=m(()=>{"use strict";o();A();k();P();C();vs=/\.html$/,bs=/\.(?:js|mjs|cjs|jsx)$/,Cs=/\.css$/,ws=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),xs=s=>s>300*1e3?ne:s>100*1e3?U:pe,Ss=s=>{let e=s.name.split("?")[0],t=ee(s.size),i=$.basename(e),r=$.join($.basename(a.empConfig.build.outDir),$.dirname(e)),p=ds.readFileSync($.join(a.empConfig.build.outDir,e)),u=p.length,f=ys(p),d=xs(f)(ee(f));return{size:u,folder:r,name:i,gzippedSize:f,sizeLabel:t,gzipSizeLabel:d}};ee=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Os=s=>bs.test(s)?U(s):Cs.test(s)?S(s):vs.test(s)?N(s):ae(s)});var T,ie=m(()=>{"use strict";o();P();C();k();T=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&ce(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});import{RspackDevServer as Ps}from"@rspack/dev-server";import Es from"connect";var I,bt=m(()=>{"use strict";o();I=class{async setup(e,t,i,r=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new Ps(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(r),p}async beforeCompiler(e){return e.devServer.app=()=>Es(),e.devServer.server&&e.devServer.server.type==="https"&&(e.devServer.server.type="http2"),e}}});import Ct from"fs";import js from"fs/promises";import $s from"compression";import Ts from"connect";import Ds from"cors";import Rs from"http2";import wt from"path";import Ns from"serve-static";import{parse as Ls}from"url";var M,B,xt=m(()=>{"use strict";o();M=Ts();M.use($s());M.use(Ds());B=class{async setup(e,t=()=>{}){let i="index",r=Object.keys(e.rsConfig.entry);if(r.length===0)return e.logger.sysError("emp serve must include entry!");if(r.includes(i)||(i=r[0]),!Ct.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let p=e.resolve(e.rsConfig.output?.path);M.use(Ns(p));let u=await js.readFile(wt.join(p,`${i}.html`),"utf8");if(M.use((f,d,E)=>{let O=Ls(f.url||"",!0).pathname;if(O&&O!=="/"&&Ct.existsSync(wt.join(p,O)))return E();d.setHeader("Content-Type","text/html"),d.end(u)}),e.server.isHttps){let{key:f,cert:d}=await e.server.getcert();Rs.createSecureServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:f,cert:d,allowHTTP1:!0},M).listen(e.server.port,t)}else v("http").createServer(M).listen(e.server.port,t)}}});var Oe=m(()=>{"use strict";o();bt();xt()});var kt={};z(kt,{default:()=>Ms});import{rspack as As}from"@rspack/core";var St,Pe,Ms,Ot=m(()=>{"use strict";o();se();C();ie();Oe();k();St=new I,Pe=class extends T{get stats(){return{all:a.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=b(a.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:a.server.port}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:r}=await a.server.getcert();t.server={type:"https",options:{key:i,cert:r}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=a,t=await this.getRspackDevConfig();t=await St.beforeCompiler(t);let i=As(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await St.setup(i,t,a,async r=>{this.showTimeDone(r),await a.empConfig.lifeCycle.afterDevServe()}),a.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});te(t.time)}},Ms=new Pe});var Ee={};z(Ee,{ServeScript:()=>re,default:()=>Fs});var zs,Pt,re,Fs,je=m(()=>{"use strict";o();se();ie();Oe();k();zs=new B,Pt=0,re=class extends T{async run(){Pt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await zs.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),te(Date.now()-Pt),await a.empConfig.lifeCycle.afterServe()}},Fs=new re});var Et={};z(Et,{default:()=>Is});import{rspack as Gs}from"@rspack/core";var $e,Is,jt=m(()=>{"use strict";o();se();P();ie();k();$e=class extends T{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(je(),Ee));await e.setup("serve",a.cliOptions)}async run(){await a.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!a.cliOptions.watch,this.isuseServe=!!a.cliOptions.serve,this.rspackConfig=a.rsConfig,this.isWatchMode&&this.watchMode(),Gs(this.rspackConfig,async(e,t)=>{if(console.log(`
|
|
17
|
-
`),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await vt(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Is=new $e});o();import{rspack as Zo}from"@rspack/core";import{program as tn}from"commander";o();import Bs from"process";import{program as R}from"commander";var Le={name:"@empjs/cli",version:"3.10.0
|
|
17
|
+
`),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await vt(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Is=new $e});o();import{rspack as Zo}from"@rspack/core";import{program as tn}from"commander";o();import Bs from"process";import{program as R}from"commander";var Le={name:"@empjs/cli",version:"3.10.0",description:"emp",license:"MIT",type:"module",files:["dist","bin","resource","template","types","tsconfig"],maintainers:["xuhongbin","ckken","doerme"],repository:{type:"git",url:"git+https://github.com/empjs/emp.git",directory:"packages/cli"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},keywords:["rspack","rust","typescript"],bin:{emp:"./bin/emp.js"},main:"dist/index.js",types:"dist/index.d.ts",exports:{".":{import:{types:"./dist/index.d.ts",default:"./dist/index.js"},require:{types:"./dist/index.d.cts",default:"./dist/index.cjs"}},"./emp-tsconfig.json":{default:"./tsconfig/react.json"},"./tsconfig/base":{default:"./tsconfig/base.json"},"./tsconfig/react":{default:"./tsconfig/react.json"},"./tsconfig/vue":{default:"./tsconfig/vue.json"},"./client":{types:"./types/react/index.d.ts",default:"./types/react/index.d.ts"},"./types/base":{types:"./types/base/index.d.ts",default:"./types/base/index.d.ts"},"./types/vue":{types:"./types/vue/index.d.ts",default:"./types/vue/index.d.ts"},"./types/react":{types:"./types/react/index.d.ts",default:"./types/react/index.d.ts"}},scripts:{dev:"tsup --watch --env.ENV dev",build:"tsup --env.ENV prod",ph:"pnpm publish --no-git-checks"},engines:{node:">=18.0.0"},author:"Ken",devDependencies:{"@types/compression":"^1.7.2","@types/connect":"^3.4.38","@types/cors":"^2.8.12","@types/default-gateway":"^7.2.1","@types/fs-extra":"^11.0.4","@types/node":"^20.8.7","@types/react":"^18.3.2","@types/serve-static":"^1.15.8","@types/watchpack":"^2.4.3","@types/webpack":"^5.28.4","@types/webpack-bundle-analyzer":"^4.6.2","@types/webpack-sources":"^3.2.2",vue:"^3.5.21"},dependencies:{"@empjs/chain":"workspace:*","@rsdoctor/rspack-plugin":"1.2.3","@rspack/core":"1.5.4","@rspack/dev-server":"1.1.4","@swc/helpers":"^0.5.17","@vue/tsconfig":"^0.8.1",address:"^2.0.2",chalk:"^5.3.0",commander:"11.1.0",compression:"1.8.1",connect:"3.7.0","core-js":"^3.41.0",cors:"2.8.5","default-gateway":"7.2.2","fs-extra":"11.3.1",glob:"11.0.3","gzip-size":"7.0.0","html-webpack-plugin":"5.6.4",jiti:"2.0.0","less-loader":"^12.2.0",open:"10.2.0","sass-embedded":"1.91.0","sass-loader":"16.0.5","serve-static":"2.2.0","ts-checker-rspack-plugin":"1.1.5","typescript-plugin-css-modules":"5.2.0","webpack-bundle-analyzer":"4.10.2"}};async function $t(){R.version(Le.version,"-v, --version").usage("<command> [options]"),R.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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Ot(),kt));await e.setup("dev",s)}),R.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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(jt(),Et));await e.setup("build",s)}),R.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(je(),Ee));await e.setup("serve",s)}),R.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(s=>{}),R.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(s=>{}),R.parse(Bs.argv)}k();P();F();function on(s){return s}export{H as Logger,h as color,on as defineConfig,He as empHelper,tn as program,Zo as rspack,$t as runScript,a as store};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/cli",
|
|
3
|
-
"version": "3.10.0
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "emp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"bin",
|
|
10
10
|
"resource",
|
|
11
11
|
"template",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"types",
|
|
13
|
+
"tsconfig"
|
|
14
14
|
],
|
|
15
15
|
"maintainers": [
|
|
16
16
|
"xuhongbin",
|
|
@@ -47,7 +47,34 @@
|
|
|
47
47
|
"default": "./dist/index.cjs"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
"./emp-tsconfig.json":
|
|
50
|
+
"./emp-tsconfig.json": {
|
|
51
|
+
"default": "./tsconfig/react.json"
|
|
52
|
+
},
|
|
53
|
+
"./tsconfig/base": {
|
|
54
|
+
"default": "./tsconfig/base.json"
|
|
55
|
+
},
|
|
56
|
+
"./tsconfig/react": {
|
|
57
|
+
"default": "./tsconfig/react.json"
|
|
58
|
+
},
|
|
59
|
+
"./tsconfig/vue": {
|
|
60
|
+
"default": "./tsconfig/vue.json"
|
|
61
|
+
},
|
|
62
|
+
"./client": {
|
|
63
|
+
"types": "./types/react/index.d.ts",
|
|
64
|
+
"default": "./types/react/index.d.ts"
|
|
65
|
+
},
|
|
66
|
+
"./types/base": {
|
|
67
|
+
"types": "./types/base/index.d.ts",
|
|
68
|
+
"default": "./types/base/index.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./types/vue": {
|
|
71
|
+
"types": "./types/vue/index.d.ts",
|
|
72
|
+
"default": "./types/vue/index.d.ts"
|
|
73
|
+
},
|
|
74
|
+
"./types/react": {
|
|
75
|
+
"types": "./types/react/index.d.ts",
|
|
76
|
+
"default": "./types/react/index.d.ts"
|
|
77
|
+
}
|
|
51
78
|
},
|
|
52
79
|
"engines": {
|
|
53
80
|
"node": ">=18.0.0"
|
|
@@ -66,14 +93,14 @@
|
|
|
66
93
|
"@types/webpack": "^5.28.4",
|
|
67
94
|
"@types/webpack-bundle-analyzer": "^4.6.2",
|
|
68
95
|
"@types/webpack-sources": "^3.2.2",
|
|
69
|
-
"
|
|
96
|
+
"vue": "^3.5.21"
|
|
70
97
|
},
|
|
71
98
|
"dependencies": {
|
|
72
|
-
"typescript-plugin-css-modules": "5.2.0",
|
|
73
99
|
"@rsdoctor/rspack-plugin": "1.2.3",
|
|
74
|
-
"@rspack/core": "1.5.
|
|
100
|
+
"@rspack/core": "1.5.4",
|
|
75
101
|
"@rspack/dev-server": "1.1.4",
|
|
76
102
|
"@swc/helpers": "^0.5.17",
|
|
103
|
+
"@vue/tsconfig": "^0.8.1",
|
|
77
104
|
"address": "^2.0.2",
|
|
78
105
|
"chalk": "^5.3.0",
|
|
79
106
|
"commander": "11.1.0",
|
|
@@ -93,6 +120,7 @@
|
|
|
93
120
|
"sass-loader": "16.0.5",
|
|
94
121
|
"serve-static": "2.2.0",
|
|
95
122
|
"ts-checker-rspack-plugin": "1.1.5",
|
|
123
|
+
"typescript-plugin-css-modules": "5.2.0",
|
|
96
124
|
"webpack-bundle-analyzer": "4.10.2",
|
|
97
125
|
"@empjs/chain": "1.0.0"
|
|
98
126
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"types": ["@empjs/cli/client"],
|
|
4
3
|
"plugins": [
|
|
5
4
|
{
|
|
6
5
|
"name": "typescript-plugin-css-modules",
|
|
@@ -32,7 +31,5 @@
|
|
|
32
31
|
"sourceMap": true,
|
|
33
32
|
"jsx": "preserve",
|
|
34
33
|
"verbatimModuleSyntax": true
|
|
35
|
-
}
|
|
36
|
-
"include": ["src"],
|
|
37
|
-
"exclude": ["dist", "nodule_modules"]
|
|
34
|
+
}
|
|
38
35
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
// web worker
|
|
3
|
+
declare module '*?worker' {
|
|
4
|
+
const workerConstructor: {
|
|
5
|
+
new (): Worker
|
|
6
|
+
}
|
|
7
|
+
export default workerConstructor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '*?inline' {
|
|
11
|
+
const inlineStr: string
|
|
12
|
+
export default inlineStr
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// import.meta
|
|
16
|
+
|
|
17
|
+
interface ImportMetaEnv {
|
|
18
|
+
[key: string]: string | boolean | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ImportMeta {
|
|
22
|
+
readonly env: ImportMetaEnv
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.svga' {
|
|
2
|
+
const src: string
|
|
3
|
+
export default src
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.avif' {
|
|
7
|
+
const src: string
|
|
8
|
+
export default src
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module '*.bmp' {
|
|
12
|
+
const src: string
|
|
13
|
+
export default src
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module '*.gif' {
|
|
17
|
+
const src: string
|
|
18
|
+
export default src
|
|
19
|
+
}
|
|
20
|
+
declare module '*.jpg' {
|
|
21
|
+
const src: string
|
|
22
|
+
export default src
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module '*.jpeg' {
|
|
26
|
+
const src: string
|
|
27
|
+
export default src
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare module '*.png' {
|
|
31
|
+
const src: string
|
|
32
|
+
export default src
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module '*.webp' {
|
|
36
|
+
const src: string
|
|
37
|
+
export default src
|
|
38
|
+
}
|
|
39
|
+
declare module '*.svg' {
|
|
40
|
+
const src: string
|
|
41
|
+
export default src
|
|
42
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: {[key: string]: string}
|
|
3
|
+
export default classes
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.module.scss' {
|
|
7
|
+
const classes: {[key: string]: string}
|
|
8
|
+
export default classes
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module '*.module.sass' {
|
|
12
|
+
const classes: {[key: string]: string}
|
|
13
|
+
export default classes
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module '*.module.less' {
|
|
17
|
+
const classes: {[key: string]: string}
|
|
18
|
+
export default classes
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module '*.module.styl' {
|
|
22
|
+
const classes: {[key: string]: string}
|
|
23
|
+
export default classes
|
|
24
|
+
}
|
package/client.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
|
-
declare module '*.svga' {
|
|
4
|
-
const src: string
|
|
5
|
-
export default src
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
declare module '*.avif' {
|
|
9
|
-
const src: string
|
|
10
|
-
export default src
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare module '*.bmp' {
|
|
14
|
-
const src: string
|
|
15
|
-
export default src
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare module '*.gif' {
|
|
19
|
-
const src: string
|
|
20
|
-
export default src
|
|
21
|
-
}
|
|
22
|
-
declare module '*.jpg' {
|
|
23
|
-
const src: string
|
|
24
|
-
export default src
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module '*.jpeg' {
|
|
28
|
-
const src: string
|
|
29
|
-
export default src
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare module '*.png' {
|
|
33
|
-
const src: string
|
|
34
|
-
export default src
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
declare module '*.webp' {
|
|
38
|
-
const src: string
|
|
39
|
-
export default src
|
|
40
|
-
}
|
|
41
|
-
declare module '*.svg' {
|
|
42
|
-
const src: string
|
|
43
|
-
export default src
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* declare module '*.svg' {
|
|
47
|
-
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
|
|
48
|
-
const content: string
|
|
49
|
-
export {ReactComponent}
|
|
50
|
-
export default content
|
|
51
|
-
} */
|
|
52
|
-
// declare module '*.svg?react' {
|
|
53
|
-
// const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
|
|
54
|
-
// const content: string
|
|
55
|
-
// export {ReactComponent}
|
|
56
|
-
// export default content
|
|
57
|
-
// }
|
|
58
|
-
declare module '*.svg?react' {
|
|
59
|
-
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
|
|
60
|
-
export default ReactComponent
|
|
61
|
-
}
|
|
62
|
-
// styles
|
|
63
|
-
|
|
64
|
-
declare module '*.module.css' {
|
|
65
|
-
const classes: {[key: string]: string}
|
|
66
|
-
export default classes
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
declare module '*.module.scss' {
|
|
70
|
-
const classes: {[key: string]: string}
|
|
71
|
-
export default classes
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
declare module '*.module.sass' {
|
|
75
|
-
const classes: {[key: string]: string}
|
|
76
|
-
export default classes
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
declare module '*.module.less' {
|
|
80
|
-
const classes: {[key: string]: string}
|
|
81
|
-
export default classes
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
declare module '*.module.styl' {
|
|
85
|
-
const classes: {[key: string]: string}
|
|
86
|
-
export default classes
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// web worker
|
|
90
|
-
declare module '*?worker' {
|
|
91
|
-
const workerConstructor: {
|
|
92
|
-
new (): Worker
|
|
93
|
-
}
|
|
94
|
-
export default workerConstructor
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
declare module '*?inline' {
|
|
98
|
-
const inlineStr: string
|
|
99
|
-
export default inlineStr
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// import.meta
|
|
103
|
-
|
|
104
|
-
interface ImportMetaEnv {
|
|
105
|
-
[key: string]: string | boolean | undefined
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
interface ImportMeta {
|
|
109
|
-
readonly env: ImportMetaEnv
|
|
110
|
-
}
|