@empjs/cli 3.7.0-beta.3 → 3.7.1
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
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 ae});var ue={};j(ue,{clearConsole:()=>ce,deepAssign:()=>y,ensureArray:()=>ys,getLanIp:()=>T,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>vs,timeFormat:()=>_,vCompare:()=>J});function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=y(p,o);continue}s[i]=t[i]}return s}var ze,Ie,Ue,Be,T,le,ys,vs,J,_,me,C=c(()=>{"use strict";r();ze=require("address"),Ie=l(require("chalk"),1),Ue=require("default-gateway"),Be=l(require("fs-extra"),1),T=()=>{let s="127.0.0.1";try{let{int:e}=(0,Ue.gateway4sync)();return(0,ze.ip)(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Be.default.readJSONSync(s);return e}catch{return}};ys=s=>Array.isArray(s)?s:[s],vs=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),J=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,x=isNaN(Number(g))?g.charCodeAt():Number(g),N=i.length>u?i[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(x<f){p=-1;break}else if(x>f){p=1;break}}return p},_=s=>{s=s/1e3;let e=i=>Ie.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`},me=s=>`data:text/javascript,${s}`});var he={};j(he,{chalk:()=>He.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ue});var He,F,G=c(()=>{"use strict";r();He=l(require("chalk"),1),F=require("glob");L();C();k()});var Je,_e,Ve,bs,We,qe,Cs,Xe=c(()=>{"use strict";r();Je=l(require("fs"),1),_e=l(require("path"),1),Ve=require("jiti");w();k();bs=["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"],We=(0,Ve.createJiti)(__filename,{interopDefault:!0}),qe=async()=>Cs(),Cs=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of bs){let t=_e.default.resolve(a.root,e);if(Je.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var V,Qe=c(()=>{"use strict";r();V=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 Ke,fe,Ye,Ze=c(()=>{"use strict";r();Ke=l(require("fs"),1);G();Xe();C();Qe();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}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={supports:{generateTileGraph:!0}}),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},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:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){n.time("[store][empConfig]SyncEmpOptions");let e=await qe();if(!e||!Ke.default.existsSync(e))return;let t=await We(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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}},Ye=new fe});var et,ge,tt,st=c(()=>{"use strict";r();et=l(require("fs-extra"),1),ge=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory"},parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting},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 et.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})}},tt=new ge});var de,it,ot=c(()=>{"use strict";r();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:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.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"}}}})}},it=new de});function ws(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
9
|
+
`)}},n=new ae});var ue={};j(ue,{clearConsole:()=>ce,deepAssign:()=>y,ensureArray:()=>ys,getLanIp:()=>T,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>vs,timeFormat:()=>_,vCompare:()=>J});function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=y(p,o);continue}s[i]=t[i]}return s}var ze,Ie,Ue,Be,T,le,ys,vs,J,_,me,C=c(()=>{"use strict";r();ze=require("address"),Ie=l(require("chalk"),1),Ue=require("default-gateway"),Be=l(require("fs-extra"),1),T=()=>{let s="127.0.0.1";try{let{int:e}=(0,Ue.gateway4sync)();return(0,ze.ip)(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Be.default.readJSONSync(s);return e}catch{return}};ys=s=>Array.isArray(s)?s:[s],vs=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),J=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,x=isNaN(Number(g))?g.charCodeAt():Number(g),N=i.length>u?i[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(x<f){p=-1;break}else if(x>f){p=1;break}}return p},_=s=>{s=s/1e3;let e=i=>Ie.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`},me=s=>`data:text/javascript,${s}`});var he={};j(he,{chalk:()=>He.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ue});var He,F,G=c(()=>{"use strict";r();He=l(require("chalk"),1),F=require("glob");L();C();k()});var Je,_e,Ve,bs,We,qe,Cs,Xe=c(()=>{"use strict";r();Je=l(require("fs"),1),_e=l(require("path"),1),Ve=require("jiti");w();k();bs=["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"],We=(0,Ve.createJiti)(__filename,{interopDefault:!0}),qe=async()=>Cs(),Cs=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of bs){let t=_e.default.resolve(a.root,e);if(Je.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var V,Qe=c(()=>{"use strict";r();V=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 Ke,fe,Ye,Ze=c(()=>{"use strict";r();Ke=l(require("fs"),1);G();Xe();C();Qe();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}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={supports:{generateTileGraph:!0}}),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},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:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${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(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){n.time("[store][empConfig]SyncEmpOptions");let e=await qe();if(!e||!Ke.default.existsSync(e))return;let t=await We(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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}},Ye=new fe});var et,ge,tt,st=c(()=>{"use strict";r();et=l(require("fs-extra"),1),ge=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory"},parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting},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 et.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})}},tt=new ge});var de,it,ot=c(()=>{"use strict";r();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:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.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"}}}})}},it=new de});function ws(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
10
|
`);return me(s)}var q,W,z,X=c(()=>{"use strict";r();q=l(require("html-webpack-plugin"),1);C();w();W=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ws(),{name:void 0}).apply(e)}},z=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=>{q.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:p,...u}=o;(p==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});var v,ye,rt,nt=c(()=>{"use strict";r();v=l(require("path"),1);G();X();ye=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),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(v.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${v.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(v.default.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),p=[i];this.entriesConfig[o]={entry:{[o]:p},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(q.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=v.default.join(this.store.appSrc,e),i=v.default.join(t,"**","*.{ts,tsx,jsx,js}"),o=await(0,F.glob)([i],{windowsPathsNoEscape:!0});o=o.map(p=>p.replace(`${t}${v.default.sep}`,"")),o.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},v.default.join(t,p))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=v.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=v.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)}},rt=new ye});var ve,be,pt,at=c(()=>{"use strict";r();ve=l(require("path"),1);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}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{css:{localIdentName:t},"css/auto":{localIdentName:t},"css/module":{localIdentName:t}}}})}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:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:y(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",ve.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ve.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"}}}})}},pt=new be});var Ce,E,lt,we,ct,mt=c(()=>{"use strict";r();Ce=l(require("fs"),1),E=l(require("@rspack/core"),1),lt=require("ts-checker-rspack-plugin");X();we=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.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(W)}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(lt.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(E.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Ce.default.existsSync(e)&&Ce.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(E.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(E.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(E.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=E.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(E.default.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(E.default.CircularDependencyRspackPlugin,[{}])}},ct=new we});var Se,ut,ht=c(()=>{"use strict";r();st();ot();nt();at();mt();Se=class{store;async setup(e){this.store=e;let t=[tt.setup(this.store),pt.setup(this.store),ct.setup(this.store),rt.setup(this.store),it.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()}},ut=new Se});async function Q(s,e=void 0){if(s!==Ss&&(s<ft||s>xe))throw new Error(`Port number must lie between ${ft} and ${xe}`);let t=s,i=xs(),o;e&&!i.has(e)?o=new Set([e]):o=i;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=xe;)try{return await ks(t,o)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var gt,dt,ft,xe,Ss,xs,Os,ks,yt=c(()=>{"use strict";r();gt=l(require("net"),1),dt=l(require("os"),1),ft=1024,xe=65535,Ss=443,xs=()=>{let s=dt.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},Os=(s,e)=>new Promise((t,i)=>{let o=gt.default.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:p}=o.address();o.close(()=>{t(p)})})}),ks=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Os(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});var Oe,vt,ke,K,bt=c(()=>{"use strict";r();Oe=l(require("url"),1),vt=l(require("chalk"),1);L();C();ke=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:R("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",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=T;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Oe.default.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Oe.default.format({protocol:t,hostname:e,port:vt.default.bold(i),pathname:o})}},K=new ke});var wt,St,xt,Ct,Es,Ps,Ot,kt=c(()=>{"use strict";r();wt=require("child_process"),St=require("util");w();k();xt=(0,St.promisify)(wt.exec),Ct=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Es=async()=>{let s=process.env.BROWSER;if(!s||!Ct.includes(s)){let{stdout:e}=await xt("ps cax");s=Ct.find(t=>e.includes(t))}return s},Ps=async s=>{if(process.platform==="darwin")try{let t=await Es();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await xt(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}},Ot=Ps});var Ee,Y,Et=c(()=>{"use strict";r();Ee=l(require("fs/promises"),1);G();L();yt();bt();kt();C();Y=class{ip=T();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)),K.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=K.prettyPrintUrl("localhost")):(this.urls=K.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)}
|
|
11
11
|
`)),this.isOpenBrower&&Ot(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,o]=await Promise.all([Ee.default.readFile(e.resource.key),Ee.default.readFile(e.resource.cert)]);return{key:i,cert:o}}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}}});var Pt,$t=c(()=>{"use strict";r();Pt={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 Tt,b,jt,Dt,Rt,Pe,a,w=c(()=>{"use strict";r();Tt=l(require("fs/promises"),1),b=l(require("path"),1),jt=l(require("util"),1),Dt=require("@rspack/core");k();C();Ze();ht();Et();Rt=l(require("webpack-chain"),1);$t();X();Pe=class{rspackVersion=Dt.rspack.rspackVersion;isOldRspack=J(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=b.default.resolve(__dirname,__filename).replace(`${b.default.sep}dist${b.default.sep}index.js`,"");empSource=b.default.resolve(this.empRoot,"dist");resolve=e=>b.default.isAbsolute(e)?e:b.default.resolve(this.root,e);empResolve=e=>b.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Pt;server=new Y(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;async setup(e,t){n.time("[store]Setup"),await this.initVars(e,t),this.empConfig=Ye,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Rt.default,await ut.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")),o=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=b.default.join(this.empRoot,"resource"),this.resource.cert=b.default.join(this.resource.dir,"emp.cert"),this.resource.key=b.default.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=b.default.join(this.root,this.debug.showRsconfig);Tt.default.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(jt.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=J;deepAssign=y;getLanIp=T;injectTags(e=[],t="",i=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,i])}},a=new Pe});var Lt,At,Nt,Mt,Ft,Gt,$e,A,I,zt=c(()=>{"use strict";r();Lt=l(require("https"),1),At=l(require("fs"),1),Nt=l(require("fs/promises"),1),Mt=l(require("path"),1),Ft=l(require("compression"),1),Gt=l(require("cors"),1),$e=l(require("express"),1),A=(0,$e.default)();A.use((0,Ft.default)());A.use((0,Gt.default)());I=class{async setup(e,t=()=>{}){if(!At.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let i=e.resolve(e.rsConfig.output?.path);A.use($e.default.static(i));let o=await Nt.default.readFile(Mt.default.join(i,"index.html"),"utf8");if(A.get("*",(p,u)=>u.send(o)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();Lt.default.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});var It,U,Ut=c(()=>{"use strict";r();It=require("@rspack/dev-server"),U=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new It.RspackDevServer(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(o),p}async beforeCompiler(e){return e}}});var Te=c(()=>{"use strict";r();zt();Ut()});function As(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,p,u)=>{let g=t[u],x=p;return g&&(x=p.length<g?p+" ".repeat(g-p.length):p),`${o+x} `}," ");console.log(D.bold(i))}async function Jt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>Ds(f.name)).map(Ls);i.sort((f,M)=>f.size-M.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),p=Math.max(...i.map(f=>(f.folder+O.default.sep+f.name).length));As(p,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:M}=f,{name:ts,folder:ss,gzipSizeLabel:is}=f,Ne=(ss+O.default.sep+ts).length,Me=M.length;if(u+=f.size,g+=f.gzippedSize,Me<o){let oe=" ".repeat(o-Me);M+=oe}let Fe=R(f.folder+O.default.sep)+Ns(f.name);if(Ne<p){let oe=" ".repeat(p-Ne);Fe+=oe}n.info(` ${Fe} ${R(M)} ${is}`)});let x=`${D.bold("Total size:")} ${Z(u)}`,N=`${D.bold("Gzipped size:")} ${Z(g)}`;n.info(`
|
|
12
12
|
${x}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var kt=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 pe});var me={};F(me,{clearConsole:()=>le,deepAssign:()=>y,ensureArray:()=>It,getLanIp:()=>$,getPkgVersion:()=>ae,importJsVm:()=>ce,jsonFilter:()=>Bt,timeFormat:()=>J,vCompare:()=>H});import{ip as Mt}from"address";import Ft from"chalk";import{gateway4sync as Gt}from"default-gateway";import zt from"fs-extra";function le(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=y(p,o);continue}s[i]=t[i]}return s}var $,ae,It,Bt,H,J,ce,b=m(()=>{"use strict";r();$=()=>{let s="127.0.0.1";try{let{int:e}=Gt();return Mt(e||"")||s}catch{return s}},ae=s=>{try{let{version:e}=zt.readJSONSync(s);return e}catch{return}};It=s=>Array.isArray(s)?s:[s],Bt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),H=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),N=i.length>u?i[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(O<f){p=-1;break}else if(O>f){p=1;break}}return p},J=s=>{s=s/1e3;let e=i=>Ft.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`},ce=s=>`data:text/javascript,${s}`});var Re={};F(Re,{chalk:()=>Ut,color:()=>h,glob:()=>_,logger:()=>n,utils:()=>me});import Ut from"chalk";import{glob as _}from"glob";var G=m(()=>{"use strict";r();A();b();k()});import Ht from"node:fs";import Jt from"path";import{createJiti as _t}from"jiti";var Vt,Ae,Le,Wt,Ne=m(()=>{"use strict";r();C();k();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"],Ae=_t(l,{interopDefault:!0}),Le=async()=>Wt(),Wt=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of Vt){let t=Jt.resolve(a.root,e);if(Ht.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var V,Me=m(()=>{"use strict";r();V=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()}}});import qt from"node:fs";var ue,Fe,Ge=m(()=>{"use strict";r();G();Ne();b();Me();ue=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}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={supports:{generateTileGraph:!0}}),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},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:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){n.time("[store][empConfig]SyncEmpOptions");let e=await Le();if(!e||!qt.existsSync(e))return;let t=await Ae(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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}},Fe=new ue});import Xt from"fs-extra";var he,ze,Ie=m(()=>{"use strict";r();he=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory"},parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting},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 Xt.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})}},ze=new he});var fe,Be,Ue=m(()=>{"use strict";r();fe=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:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.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"}}}})}},Be=new fe});import ge from"html-webpack-plugin";function Qt(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
|
+
`)}},n=new pe});var me={};F(me,{clearConsole:()=>le,deepAssign:()=>y,ensureArray:()=>It,getLanIp:()=>$,getPkgVersion:()=>ae,importJsVm:()=>ce,jsonFilter:()=>Bt,timeFormat:()=>J,vCompare:()=>H});import{ip as Mt}from"address";import Ft from"chalk";import{gateway4sync as Gt}from"default-gateway";import zt from"fs-extra";function le(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=y(p,o);continue}s[i]=t[i]}return s}var $,ae,It,Bt,H,J,ce,b=m(()=>{"use strict";r();$=()=>{let s="127.0.0.1";try{let{int:e}=Gt();return Mt(e||"")||s}catch{return s}},ae=s=>{try{let{version:e}=zt.readJSONSync(s);return e}catch{return}};It=s=>Array.isArray(s)?s:[s],Bt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),H=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),N=i.length>u?i[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(O<f){p=-1;break}else if(O>f){p=1;break}}return p},J=s=>{s=s/1e3;let e=i=>Ft.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`},ce=s=>`data:text/javascript,${s}`});var Re={};F(Re,{chalk:()=>Ut,color:()=>h,glob:()=>_,logger:()=>n,utils:()=>me});import Ut from"chalk";import{glob as _}from"glob";var G=m(()=>{"use strict";r();A();b();k()});import Ht from"node:fs";import Jt from"path";import{createJiti as _t}from"jiti";var Vt,Ae,Le,Wt,Ne=m(()=>{"use strict";r();C();k();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"],Ae=_t(l,{interopDefault:!0}),Le=async()=>Wt(),Wt=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of Vt){let t=Jt.resolve(a.root,e);if(Ht.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var V,Me=m(()=>{"use strict";r();V=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()}}});import qt from"node:fs";var ue,Fe,Ge=m(()=>{"use strict";r();G();Ne();b();Me();ue=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}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={supports:{generateTileGraph:!0}}),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},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:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${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(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){n.time("[store][empConfig]SyncEmpOptions");let e=await Le();if(!e||!qt.existsSync(e))return;let t=await Ae(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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}},Fe=new ue});import Xt from"fs-extra";var he,ze,Ie=m(()=>{"use strict";r();he=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory"},parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting},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 Xt.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})}},ze=new he});var fe,Be,Ue=m(()=>{"use strict";r();fe=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:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.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"}}}})}},Be=new fe});import ge from"html-webpack-plugin";function Qt(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
11
11
|
`);return ce(s)}var W,z,q=m(()=>{"use strict";r();b();C();W=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Qt(),{name:void 0}).apply(e)}},z=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=>{ge.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:p,...u}=o;(p==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});import w from"node:path";var de,He,Je=m(()=>{"use strict";r();G();q();de=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 o=this.setChunk(e),p=[i];this.entriesConfig[o]={entry:{[o]:p},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(ge,[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}"),o=await _([i],{windowsPathsNoEscape:!0});o=o.map(p=>p.replace(`${t}${w.sep}`,"")),o.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 _([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)}},He=new de});import _e from"node:path";var ye,Ve,We=m(()=>{"use strict";r();b();ye=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}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{css:{localIdentName:t},"css/auto":{localIdentName:t},"css/module":{localIdentName:t}}}})}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:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:y(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",_e.dirname(v.resolve("@swc/helpers/package.json"))),this.coreJs.path=v.resolve("core-js/package.json");let t=ae(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=_e.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"}}}})}},Ve=new ye});import qe from"fs";import T from"@rspack/core";import{TsCheckerRspackPlugin as Kt}from"ts-checker-rspack-plugin";var ve,Xe,Qe=m(()=>{"use strict";r();q();ve=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.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(W)}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(Kt,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(T.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");qe.existsSync(e)&&qe.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(T.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(T.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(T.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=T;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(T.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(T.CircularDependencyRspackPlugin,[{}])}},Xe=new ve});var be,Ke,Ye=m(()=>{"use strict";r();Ie();Ue();Je();We();Qe();be=class{store;async setup(e){this.store=e;let t=[ze.setup(this.store),Ve.setup(this.store),Xe.setup(this.store),He.setup(this.store),Be.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()}},Ke=new be});import Yt from"net";import Zt from"os";async function X(s,e=void 0){if(s!==es&&(s<Ze||s>Ce))throw new Error(`Port number must lie between ${Ze} and ${Ce}`);let t=s,i=ts(),o;e&&!i.has(e)?o=new Set([e]):o=i;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=Ce;)try{return await is(t,o)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ze,Ce,es,ts,ss,is,et=m(()=>{"use strict";r();Ze=1024,Ce=65535,es=443,ts=()=>{let s=Zt.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},ss=(s,e)=>new Promise((t,i)=>{let o=Yt.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:p}=o.address();o.close(()=>{t(p)})})}),is=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await ss(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});import tt from"url";import os from"chalk";var we,Q,st=m(()=>{"use strict";r();A();b();we=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:R("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",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=$;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return tt.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return tt.format({protocol:t,hostname:e,port:os.bold(i),pathname:o})}},Q=new we});import{exec as rs}from"node:child_process";import{promisify as ns}from"node:util";var ot,it,ps,as,rt,nt=m(()=>{"use strict";r();C();k();ot=ns(rs),it=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ps=async()=>{let s=process.env.BROWSER;if(!s||!it.includes(s)){let{stdout:e}=await ot("ps cax");s=it.find(t=>e.includes(t))}return s},as=async s=>{if(process.platform==="darwin")try{let t=await ps();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await ot(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}},rt=as});import pt from"node:fs/promises";var K,at=m(()=>{"use strict";r();G();A();et();st();nt();b();K=class{ip=$();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 X(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 X(e.empConfig.server.port)),Q.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Q.prettyPrintUrl("localhost")):(this.urls=Q.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)}
|
|
12
12
|
`)),this.isOpenBrower&&rt(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,o]=await Promise.all([pt.readFile(e.resource.key),pt.readFile(e.resource.cert)]);return{key:i,cert:o}}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 X(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,ct=m(()=>{"use strict";r();lt={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"}}});import ls from"node:fs/promises";import S from"node:path";import cs from"node:util";import{rspack as ms}from"@rspack/core";import us from"webpack-chain";var Se,a,C=m(()=>{"use strict";r();k();b();Ge();Ye();at();ct();q();Se=class{rspackVersion=ms.rspackVersion;isOldRspack=H(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=S.resolve(c,l).replace(`${S.sep}dist${S.sep}index.js`,"");empSource=S.resolve(this.empRoot,"dist");resolve=e=>S.isAbsolute(e)?e:S.resolve(this.root,e);empResolve=e=>S.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=lt;server=new K(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;async setup(e,t){n.time("[store]Setup"),await this.initVars(e,t),this.empConfig=Fe,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new us,await Ke.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")),o=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=S.join(this.empRoot,"resource"),this.resource.cert=S.join(this.resource.dir,"emp.cert"),this.resource.key=S.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=S.join(this.root,this.debug.showRsconfig);ls.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(cs.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=H;deepAssign=y;getLanIp=$;injectTags(e=[],t="",i=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,i])}},a=new Se});import hs from"https";import fs from"node:fs";import gs from"node:fs/promises";import ds from"path";import ys from"compression";import vs from"cors";import mt from"express";var L,I,ut=m(()=>{"use strict";r();L=mt();L.use(ys());L.use(vs());I=class{async setup(e,t=()=>{}){if(!fs.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let i=e.resolve(e.rsConfig.output?.path);L.use(mt.static(i));let o=await gs.readFile(ds.join(i,"index.html"),"utf8");if(L.get("*",(p,u)=>u.send(o)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();hs.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},L).listen(e.server.port,t)}else L.listen(e.server.port,t)}}});import{RspackDevServer as bs}from"@rspack/dev-server";var B,ht=m(()=>{"use strict";r();B=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new bs(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(o),p}async beforeCompiler(e){return e}}});var xe=m(()=>{"use strict";r();ut();ht()});import Cs from"node:fs";import E from"node:path";import{gzipSizeSync as ws}from"gzip-size";function $s(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,p,u)=>{let g=t[u],O=p;return g&&(O=p.length<g?p+" ".repeat(g-p.length):p),`${o+O} `}," ");console.log(D.bold(i))}async function ft(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>ks(f.name)).map(Ps);i.sort((f,M)=>f.size-M.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),p=Math.max(...i.map(f=>(f.folder+E.sep+f.name).length));$s(p,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:M}=f,{name:St,folder:xt,gzipSizeLabel:Ot}=f,$e=(xt+E.sep+St).length,Te=M.length;if(u+=f.size,g+=f.gzippedSize,Te<o){let ie=" ".repeat(o-Te);M+=ie}let je=R(f.folder+E.sep)+Ts(f.name);if($e<p){let ie=" ".repeat(p-$e);je+=ie}n.info(` ${je} ${R(M)} ${Ot}`)});let O=`${D.bold("Total size:")} ${Y(u)}`,N=`${D.bold("Gzipped size:")} ${Y(g)}`;n.info(`
|
|
13
13
|
${O}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/cli",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"description": "emp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"directory": "packages/cli"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
26
|
+
"access": "public",
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
28
|
},
|
|
28
29
|
"keywords": [
|
|
29
30
|
"rspack",
|
|
@@ -67,10 +68,10 @@
|
|
|
67
68
|
"tsup": "^8.4.0"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"@rsdoctor/rspack-plugin": "1.0.
|
|
71
|
-
"@rspack/core": "1.3.
|
|
71
|
+
"@rsdoctor/rspack-plugin": "1.0.2",
|
|
72
|
+
"@rspack/core": "1.3.7",
|
|
72
73
|
"@rspack/dev-server": "1.1.1",
|
|
73
|
-
"@swc/helpers": "^0.5.
|
|
74
|
+
"@swc/helpers": "^0.5.17",
|
|
74
75
|
"address": "^2.0.2",
|
|
75
76
|
"chalk": "^5.3.0",
|
|
76
77
|
"commander": "^11.1.0",
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
"jiti": "2.0.0",
|
|
87
88
|
"less-loader": "^12.2.0",
|
|
88
89
|
"open": "^10.1.0",
|
|
89
|
-
"sass-embedded": "1.
|
|
90
|
+
"sass-embedded": "1.87.0",
|
|
90
91
|
"sass-loader": "^16.0.5",
|
|
91
92
|
"ts-checker-rspack-plugin": "^1.1.1",
|
|
92
93
|
"typescript-plugin-css-modules": "^5.1.0",
|