@empjs/cli 3.0.0-alpha.14 → 3.0.0-alpha.16

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.js CHANGED
@@ -1,9 +1,9 @@
1
- var Oe=Object.defineProperty;var p=(o,e)=>()=>(o&&(e=o(o=0)),e);var E=(o,e)=>{for(var t in e)Oe(o,t,{get:e[t],enumerable:!0})};import{fileURLToPath as $e}from"node:url";import{dirname as je}from"node:path";import{readFile as Re}from"node:fs/promises";var De,ct,P,W=p(()=>{"use strict";De=$e(import.meta.url),ct=je(De),P=async o=>{try{let e=await Re(o);return JSON.parse(e)}catch(e){console.error(e)}}});import w from"@rspack/core";import Te from"fs";var k,V,_=p(()=>{"use strict";k=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare()];await Promise.all(t)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin("bundleAnalyzerPlugin").use(e,[{}])}async define(){this.store.chain.plugin("definePlugin").use(w.DefinePlugin,[{"process.env.NODE_ENV":`'${this.store.mode}'`}])}async copy(){let e=this.store.resolve("public");Te.existsSync(e)&&this.store.chain.plugin("copyRspackPlugin").use(w.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve("dist")}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin("progressPlugin").use(w.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){if(!this.store.empConfig.empShare.name)return;let{ModuleFederationPlugin:e}=w.container;this.store.chain.plugin("empShare").use(e,[this.store.empConfig.empShare])}},V=new k});var O,q,Q=p(()=>{"use strict";O=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.react(),this.files()];await Promise.all(t)}async react(){if(this.store.reactVersion&&(this.store.empConfig.react.svgr&&this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,issuer:/\.[jt]sx?$/,resourceQuery:/svgr/,use:[{loader:this.store.importResolve("@svgr/webpack"),options:{}}]}}}}),this.store.isDev&&this.store.empConfig.react.hmr)){let{default:e}=await import("@rspack/plugin-react-refresh"),t={};this.store.empConfig.empShare.name&&(t.library=this.store.empConfig.empShare.name),this.store.chain.plugin("plugin-react-refresh").use(e,[t])}}async sass(){this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:[{loader:this.store.importResolve("sass-loader"),options:{}}],type:"css/auto"}}}})}async less(){this.store.chain.merge({module:{rule:{less:{test:/\.less$/,use:[{loader:this.store.importResolve("less-loader"),options:{}}],type:"css/auto"}}}})}async files(){(!this.store.reactVersion||!this.store.empConfig.react.svgr)&&this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{inline:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{image:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset"},fonts:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},svga:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},q=new O});var $,X,Y=p(()=>{"use strict";$=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.assets(),this.optimization()];await Promise.all(t)}async common(){let e=this.store.isDev?"":".[contenthash:8]";this.store.merge({experiments:{rspackFuture:{}},mode:this.store.mode,cache:!0,devtool:this.store.empConfig.build.sourcemap?"source-map":!1,builtins:{css:{modules:{localIdentName:this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]"}}},output:{publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`js/[name]${e}.js`,cssFilename:`css/[name]${e}.css`,cssChunkFilename:`css/[name]${e}.css`,assetModuleFilename:`assets/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0},resolve:{alias:{src:this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]}})}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!0,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async assets(){this.store.chain.merge({module:{rule:{assets:{test:/\.(png|jpe?g|gif|webp|ico|otf|ttf|eot|woff|woff2|svga)$/i,type:"asset/resource"}}}})}async optimization(){this.store.chain.merge({optimization:{chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify}})}},X=new $});import Fe from"@rspack/plugin-html";import Le from"fast-glob";import v from"node:path";var j,K,Z=p(()=>{"use strict";j=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e}setChunk(e){return e.replace(v.extname(e),"").replace(`${this.store.empConfig.appSrc}/`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(v.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(v.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(v.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e);this.entriesConfig[r]={entry:{[r]:s},html:this.setHtmlConfig(t,[r])}}setRspackHtmlPlugin(e,t){let s=Fe;this.store.chain.plugin(`html-plugin-${t}`).use(s.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){let e=await Le([`${this.store.appSrc}/${this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"}`]);if(e[0]){let t=v.join(this.store.empConfig.appSrc,this.store.empConfig.appEntry||"index");this.setEntryItem(t,this.store.empConfig.html,e[0])}if(Object.keys(this.store.empConfig.entries).length>0)for(let[t,s]of Object.entries(this.store.empConfig.entries))this.setEntryItem(t,s)}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},K=new j});var R,ee,te=p(()=>{"use strict";_();Q();Y();Z();R=class{store;async setup(e){this.store=e;let t=[X.setup(this.store),q.setup(this.store),V.setup(this.store),K.setup(this.store)];await Promise.all(t),await this.store.empConfig.plugins(),await this.store.empConfig.chain()}},ee=new R});import c from"chalk";import{table as Ae}from"table";var D,i,b=p(()=>{"use strict";D=class{pname="";logLevel="debug";setup({pname:e,logLevel:t}){this.pname=e,t&&(this.logLevel=t)}debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${c.white.bgBlue(this.pname)}${c.blue.bgWhite(` ${e} `)}
1
+ var je=Object.defineProperty;var p=(o,e)=>()=>(o&&(e=o(o=0)),e);var P=(o,e)=>{for(var t in e)je(o,t,{get:e[t],enumerable:!0})};import{fileURLToPath as De}from"node:url";import{dirname as Te}from"node:path";import{readFile as Fe}from"node:fs/promises";var Le,ht,O,q=p(()=>{"use strict";Le=De(import.meta.url),ht=Te(Le),O=async o=>{try{let e=await Fe(o);return JSON.parse(e)}catch(e){console.error(e)}}});import w from"@rspack/core";import Ae from"fs";var k,Q,X=p(()=>{"use strict";k=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare()];await Promise.all(t)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin("bundleAnalyzerPlugin").use(e,[{}])}async define(){this.store.chain.plugin("definePlugin").use(w.DefinePlugin,[{"process.env.NODE_ENV":`'${this.store.mode}'`}])}async copy(){let e=this.store.resolve("public");Ae.existsSync(e)&&this.store.chain.plugin("copyRspackPlugin").use(w.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve("dist")}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin("progressPlugin").use(w.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){if(!this.store.empConfig.empShare.name)return;let{ModuleFederationPlugin:e}=w.container;this.store.chain.plugin("empShare").use(e,[this.store.empConfig.empShare])}},Q=new k});var $,Y,K=p(()=>{"use strict";$=class{store;async setup(e){this.store=e;let t=[this.react(),this.files()];await Promise.all(t)}async react(){if(this.store.reactVersion&&(this.store.empConfig.react.svgr&&this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,issuer:/\.[jt]sx?$/,resourceQuery:/svgr/,use:[{loader:this.store.importResolve("@svgr/webpack"),options:{}}]}}}}),this.store.isDev&&this.store.empConfig.react.hmr)){let{default:e}=await import("@rspack/plugin-react-refresh"),t={};this.store.empConfig.empShare.name&&(t.library=this.store.empConfig.empShare.name),this.store.chain.plugin("plugin-react-refresh").use(e,[t])}}async files(){(!this.store.reactVersion||!this.store.empConfig.react.svgr)&&this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{inline:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{image:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset"},fonts:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},svga:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Y=new $});var R,Z,ee=p(()=>{"use strict";R=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.assets(),this.optimization()];await Promise.all(t)}async common(){let e=this.store.isDev?"":".[contenthash:8]";this.store.merge({experiments:{rspackFuture:{}},mode:this.store.mode,cache:!0,devtool:this.store.empConfig.build.sourcemap?"source-map":!1,builtins:{css:{modules:{localIdentName:this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]"}}},output:{publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`js/[name]${e}.js`,cssFilename:`css/[name]${e}.css`,cssChunkFilename:`css/[name]${e}.css`,assetModuleFilename:`assets/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0},resolve:{alias:{src:this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]}})}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 assets(){this.store.chain.merge({module:{rule:{assets:{test:/\.(png|jpe?g|gif|webp|ico|otf|ttf|eot|woff|woff2|svga)$/i,type:"asset/resource"}}}})}async optimization(){this.store.chain.merge({optimization:{chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify}})}},Z=new R});import Ge from"@rspack/plugin-html";import Me from"fast-glob";import v from"node:path";var j,te,se=p(()=>{"use strict";j=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e}setChunk(e){return e.replace(v.extname(e),"").replace(`${this.store.empConfig.appSrc}/`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(v.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(v.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(v.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e);this.entriesConfig[r]={entry:{[r]:s},html:this.setHtmlConfig(t,[r])}}setRspackHtmlPlugin(e,t){let s=Ge;this.store.chain.plugin(`html-plugin-${t}`).use(s.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){let e=await Me([`${this.store.appSrc}/${this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"}`]);if(e[0]){let t=v.join(this.store.empConfig.appSrc,this.store.empConfig.appEntry||"index");this.setEntryItem(t,this.store.empConfig.html,e[0])}if(Object.keys(this.store.empConfig.entries).length>0)for(let[t,s]of Object.entries(this.store.empConfig.entries))this.setEntryItem(t,s)}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},te=new j});var D,oe,re=p(()=>{"use strict";D=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let e={loader:this.store.importResolve("sass-loader"),options:{}};this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:[this.postcss,e],type:"css/auto"}}}})}async less(){let e={loader:this.store.importResolve("less-loader"),options:{}};this.store.chain.merge({module:{rule:{less:{test:/\.less$/,use:[this.postcss,e],type:"css/auto"}}}})}async css(){this.store.chain.merge({module:{rule:{css:{test:/\.css$/,use:[this.postcss],type:"css/auto"}}}})}get postcss(){return{loader:this.store.importResolve("postcss-loader"),options:{postcssOptions:{plugins:this.store.empConfig.css.postcss}}}}},oe=new D});var T,ie,ne=p(()=>{"use strict";X();K();ee();se();re();T=class{store;async setup(e){this.store=e;let t=[Z.setup(this.store),Y.setup(this.store),Q.setup(this.store),te.setup(this.store),oe.setup(this.store)];await Promise.all(t),await this.store.empConfig.plugins(),await this.store.empConfig.chain()}},ie=new T});import c from"chalk";import{table as Ne}from"table";var F,n,b=p(()=>{"use strict";F=class{pname="";logLevel="debug";setup({pname:e,logLevel:t}){this.pname=e,t&&(this.logLevel=t)}debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${c.white.bgBlue(this.pname)}${c.blue.bgWhite(` ${e} `)}
2
2
  `)};cyan=e=>{console.log(`${c.white.bgCyan(this.pname)}${c.cyan.bgWhite(` ${e} `)}
3
3
  `)};magenta=e=>{console.log(`${c.white.bgMagenta(this.pname)}${c.magenta.bgWhite(` ${e} `)}
4
4
  `)};green=e=>{console.log(`${c.white.bgGreen(this.pname)}${c.green.bgWhite(` ${e} `)}
5
5
  `)};yellow=e=>{console.log(`${c.white.bgYellow(this.pname)}${c.yellow.bgWhite(` ${e} `)}
6
6
  `)};red=e=>{console.log(`${c.white.bgRed(this.pname)}${c.red.bgWhite(` ${e} `)}
7
- `)};link=e=>c.hex("#3498db")(e);tableData=[];tableConfig={border:{topBody:"\u2500",topJoin:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottomBody:"\u2500",bottomJoin:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",bodyLeft:"\u2502",bodyRight:"\u2502",bodyJoin:"\u2502",joinBody:"\u2500",joinLeft:"\u251C",joinRight:"\u2524",joinJoin:"\u253C"}};tableInput(e){this.tableData.push(e)}tableOutput(){console.log(Ae(this.tableData,this.tableConfig))}},i=new D});import Me from"node:fs";var T,se,oe=p(()=>{"use strict";T=class{store;appSrc="src";appEntry="";base="";assign(e,t){return t=t||{},{...e,...t}}async setup(e){this.store=e,await this.syncEmpOptions();let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&await Promise.all(this.store.empOptions.plugins)}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!1,showRsconfig:!1},this.store.empOptions.debug)}get build(){return this.assign({outDir:"dist",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev},this.store.empOptions.build)}get html(){return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,meta:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"}}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get react(){return this.assign({hmr:!0,svgr:!1},this.store.empOptions.react)}get server(){return this.assign({host:"0.0.0.0",port:8e3,open:!1,hot:!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"}},this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js"},this.store.empOptions.empShare)}async syncEmpOptions(){let e=this.store.resolve("emp-config.js");if(!Me.existsSync(e))return;let{default:t}=await import(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{}}},se=new T});var F,re,ie=p(()=>{"use strict";F=class{js(e){let{isDev:t}=e,s={test:/\.(jsx?|tsx?)$/,use:[{loader:"builtin:swc-loader",options:{sourceMap:!0,jsc:{parser:{syntax:"typescript",tsx:!0},transform:{react:{runtime:"automatic",development:t,refresh:t}}}}}]};e.rsConfig.module?.rules?.push(s)}},re=new F});var L,ne,ae=p(()=>{"use strict";ie();L=class{async afterChain(e){re.js(e)}},ne=new L});import C from"node:path";import Ge from"webpack-chain";var A,n,u=p(()=>{"use strict";W();te();b();oe();ae();A=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=import.meta.resolve("@empjs/cli").replace("/dist/index.js","").replace("file://","");empSource=C.resolve(this.empRoot,"dist");resolve=e=>C.isAbsolute(e)?e:C.resolve(this.root,e);empResolve=e=>C.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";cacheDir="";mode="development";cliMode="dev";isDev=!0;reactVersion=void 0;cliOptions;chain;rsConfig;empOptions={};empConfig;async setup(e,t){await this.initVars(e,t),this.empConfig=se,await this.empConfig.setup(this),this.initPaths(),this.chain=new Ge,await ee.setup(this),this.setLogger(),this.toConfig(),this.logConfig()}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development";let s=await P(this.empResolve("package.json")),r=await P(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.reactVersion=this.pkg.dependencies.react||this.pkg.devDependencies.react}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.empConfig.debug.loggerLevel&&(e=this.empConfig.debug.loggerLevel),i.setup({pname:` EMP v${this.empPkg.version} ${this.cliMode==="dev"?"DEV ":""}`,logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e){return import.meta.resolve(e).replace("file://","")}toConfig(){this.rsConfig=this.chain.toConfig(),ne.afterChain(this)}logConfig(){this.empConfig.debug.showRsconfig&&console.log("[ChainConfig]",JSON.stringify(this.rsConfig,null,2))}},n=new A});function pe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}var le=p(()=>{"use strict"});var f,x=p(()=>{"use strict";b();u();le();f=class{async setup(e,t){await n.setup(e,t),n.empConfig.debug.clearLog&&pe(),i.blue(`${e} Running`),await this.run()}async run(){}}});var ce={};E(ce,{default:()=>Ue});import{rspack as Ne}from"@rspack/core";import{RspackDevServer as Ie}from"@rspack/dev-server";var M,Ue,me=p(()=>{"use strict";u();x();b();M=class extends f{async run(){let e=Ne(n.rsConfig);if(!n.rsConfig.devServer){i.error("devServer is not defined in config");return}new Ie(n.rsConfig.devServer,e).start()}},Ue=new M});var he={};E(he,{default:()=>Be});import{rspack as He}from"@rspack/core";var G,Be,ue=p(()=>{"use strict";b();u();x();G=class extends f{async run(){He(n.rsConfig,(e,t)=>{if(e!==null){i.error(e.stack||e),e.message&&i.error(e.message);return}if(!t){i.red("Stats is Undefined.");return}let s=t.toString({all:!1,colors:!0,assets:!0,chunks:!1,entrypoints:!0,timings:!0,version:!0});t.hasErrors()&&(i.error(s),i.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(i.yellow("Compiled with warnings."),i.warn(s)),i.info(s),i.green("Compiled successfully.")})}},Be=new G});import ze from"net";import Je from"os";async function ge(o,e){if(o!==We&&(o<fe||o>N))throw new Error(`Port number must lie between ${fe} and ${N}`);let t=o,s=Ve(),r;e&&!s.has(e)?r=new Set([e]):r=s;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=N;)try{return await qe(t,r)}catch(m){if(!a.has(m.code))throw m;t+=1}throw new Error("No available ports found")}var fe,N,We,Ve,_e,qe,de=p(()=>{"use strict";fe=1024,N=65535,We=443,Ve=()=>{let o=Je.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(o))if(t)for(let s of t)e.add(s.address);return e},_e=(o,e)=>new Promise((t,s)=>{let r=ze.createServer();r.unref(),r.on("error",s),r.listen(o,e,()=>{let{port:a}=r.address();r.close(()=>{t(a)})})}),qe=async(o,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await _e(o,s)}catch(r){if(!t.has(r.code))throw r}return o}});import ye from"url";import be from"chalk";import{ip as Qe}from"address";import{gateway4sync as Xe}from"default-gateway";function ve(o,e,t,s="/"){let r=y=>ye.format({protocol:o,hostname:y,port:t,pathname:s}),a=y=>ye.format({protocol:o,hostname:y,port:be.bold(t),pathname:s}),m=e==="0.0.0.0"||e==="::",l,h,g=be.gray("unavailable");if(m){l="localhost";try{let{int:y}=Xe();h=Qe(y||""),h&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(h)?g=a(h):h=void 0)}catch{}}else l=e,h=e,g=a(h);let J=a(l),ke=r(l);return{lanUrlForConfig:h,lanUrlForTerminal:g,localUrlForTerminal:J,localUrlForBrowser:ke}}var we=p(()=>{"use strict"});var xe={};E(xe,{default:()=>et});import Ce from"express";import Ye from"cors";import Ke from"compression";import Ze from"https";import S from"path";import I from"node:fs/promises";var U,et,H,Se=p(()=>{"use strict";de();we();u();b();x();U=class extends f{async run(){await new H().setup()}},et=new U,H=class{app;resourcePath="";constructor(){let e=Ce();e.use(Ke()),e.use(Ye()),this.app=e,this.resourcePath=S.join(n.empRoot,"resource")}startLogger({httpsOptions:e,host:t,port:s,publicPath:r}){if(r&&(r.indexOf("http://")>-1||r.indexOf("https://")>-1))i.info(`- Network: ${i.link(r)}`);else{let l=ve(e?"https":"http",t||"0.0.0.0",s,r);i.info(`- Local: ${i.link(l.localUrlForTerminal)}`),i.info(`- Network: ${i.link(l.lanUrlForTerminal)}`)}}async setup(){let e=n.resolve(n.rsConfig.output?.path);this.app.use(Ce.static(e));let t=await I.readFile(S.join(e,"index.html"),"utf8");this.app.get("*",(h,g)=>g.send(t));let{host:s,port:r}=n.rsConfig.devServer,a=n.rsConfig.devServer?.https,m=n.rsConfig.output?.publicPath==="auto"?"/":n.rsConfig.output?.publicPath,l=await ge(r,s);if(a){let h=await I.readFile(S.join(this.resourcePath,"emp.key")),g=await I.readFile(S.join(this.resourcePath,"emp.cert"));Ze.createServer(typeof a!="boolean"?a:{key:h,cert:g},this.app).listen(l,()=>{this.startLogger({httpsOptions:a,host:s,port:l,publicPath:m})})}else this.app.listen(l,()=>{this.startLogger({httpsOptions:a,host:s,port:l,publicPath:m})})}}});u();u();import{program as d}from"commander";function Ee(){d.version(n.empPkg.version,"-v, --version").usage("<command> [options]"),d.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async o=>{let{default:e}=await Promise.resolve().then(()=>(me(),ce));await e.setup("dev",o)}),d.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async o=>{let{default:e}=await Promise.resolve().then(()=>(ue(),he));await e.setup("build",o)}),d.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async o=>{let{default:e}=await Promise.resolve().then(()=>(Se(),xe));await e.setup("serve",o)}),d.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(o=>{}),d.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(o=>{}),d.parse(process.argv)}u();import tt from"fast-glob";import Pe from"node:fs/promises";import B from"node:path";var st=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,ot=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,rt=/import\(['"]([^;\n]+?)['"]\)/,z=class{list=[];outDir=n.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await tt(["dist/**/*.d.ts"]);let e=[];this.list.map(s=>{s=n.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await Pe.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(st,r=>{let a=r.match(ot);if(a||(a=r.match(rt)),a&&a[1]){let m=a[1];if(!m.startsWith("."))return r;let l=B.resolve(B.dirname(e),m).replace(this.outDir,this.aliasName);return r.replace(a[1],l)}return r});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
7
+ `)};link=e=>c.hex("#3498db")(e);tableData=[];tableConfig={border:{topBody:"\u2500",topJoin:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottomBody:"\u2500",bottomJoin:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",bodyLeft:"\u2502",bodyRight:"\u2502",bodyJoin:"\u2502",joinBody:"\u2500",joinLeft:"\u251C",joinRight:"\u2524",joinJoin:"\u253C"}};tableInput(e){this.tableData.push(e)}tableOutput(){console.log(Ne(this.tableData,this.tableConfig))}},n=new F});import Ie from"node:fs";var L,ae,pe=p(()=>{"use strict";L=class{store;appSrc="src";appEntry="";base="";assign(e,t){return t=t||{},{...e,...t}}async setup(e){this.store=e,await this.syncEmpOptions();let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&await Promise.all(this.store.empOptions.plugins)}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!1,showRsconfig:!1},this.store.empOptions.debug)}get build(){return this.assign({outDir:"dist",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev},this.store.empOptions.build)}get html(){return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,meta:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"}}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get react(){return this.assign({hmr:!0,svgr:!1},this.store.empOptions.react)}get server(){return this.assign({host:"0.0.0.0",port:8e3,open:!1,hot:!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"}},this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js"},this.store.empOptions.empShare)}get css(){return this.assign({postcss:[]},this.store.empOptions.css)}async syncEmpOptions(){let e=this.store.resolve("emp-config.js");if(!Ie.existsSync(e))return;let{default:t}=await import(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{}}get moduleTransformRule(){let e={and:[/(node_modules|bower_components)/]},{moduleTransform:t}=this.store.empOptions;return t?.exclude&&(e.and=t.exclude),t?.include&&(e.not=t.include),e}},ae=new L});var A,le,ce=p(()=>{"use strict";A=class{js(e){let{isDev:t}=e,s={test:/\.(jsx?|tsx?)$/,use:[{loader:"builtin:swc-loader",options:{sourceMap:!0,jsc:{parser:{syntax:"typescript",tsx:!0},transform:{react:{runtime:"automatic",development:t,refresh:t}}}}}]};e.rsConfig.module?.rules?.push(s)}},le=new A});var G,me,ue=p(()=>{"use strict";ce();G=class{async afterChain(e){le.js(e)}},me=new G});import C from"node:path";import Ue from"webpack-chain";var M,i,h=p(()=>{"use strict";q();ne();b();pe();ue();M=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=import.meta.resolve("@empjs/cli").replace("/dist/index.js","").replace("file://","");empSource=C.resolve(this.empRoot,"dist");resolve=e=>C.isAbsolute(e)?e:C.resolve(this.root,e);empResolve=e=>C.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";cacheDir="";mode="development";cliMode="dev";isDev=!0;reactVersion=void 0;cliOptions;chain;rsConfig;empOptions={};empConfig;async setup(e,t){await this.initVars(e,t),this.empConfig=ae,await this.empConfig.setup(this),this.initPaths(),this.chain=new Ue,await ie.setup(this),this.setLogger(),this.toConfig(),this.logConfig()}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development";let s=await O(this.empResolve("package.json")),r=await O(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.reactVersion=this.pkg.dependencies.react||this.pkg.devDependencies.react}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.empConfig.debug.loggerLevel&&(e=this.empConfig.debug.loggerLevel),n.setup({pname:` EMP v${this.empPkg.version} ${this.cliMode==="dev"?"DEV ":""}`,logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e){return import.meta.resolve(e).replace("file://","")}toConfig(){this.rsConfig=this.chain.toConfig(),me.afterChain(this)}logConfig(){this.empConfig.debug.showRsconfig&&console.log("[ChainConfig]",JSON.stringify(this.rsConfig,null,2))}},i=new M});function he(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}var fe=p(()=>{"use strict"});var f,x=p(()=>{"use strict";b();h();fe();f=class{async setup(e,t){await i.setup(e,t),i.empConfig.debug.clearLog&&he(),n.blue(`${e} Running`),await this.run()}async run(){}}});import He from"net";import Be from"os";async function S(o,e){if(o!==ze&&(o<ge||o>N))throw new Error(`Port number must lie between ${ge} and ${N}`);let t=o,s=Je(),r;e&&!s.has(e)?r=new Set([e]):r=s;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=N;)try{return await _e(t,r)}catch(m){if(!a.has(m.code))throw m;t+=1}throw new Error("No available ports found")}var ge,N,ze,Je,We,_e,I=p(()=>{"use strict";ge=1024,N=65535,ze=443,Je=()=>{let o=Be.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(o))if(t)for(let s of t)e.add(s.address);return e},We=(o,e)=>new Promise((t,s)=>{let r=He.createServer();r.unref(),r.on("error",s),r.listen(o,e,()=>{let{port:a}=r.address();r.close(()=>{t(a)})})}),_e=async(o,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await We(o,s)}catch(r){if(!t.has(r.code))throw r}return o}});var de={};P(de,{default:()=>Qe});import{rspack as Ve}from"@rspack/core";import{RspackDevServer as qe}from"@rspack/dev-server";var U,Qe,ye=p(()=>{"use strict";h();x();b();I();U=class extends f{async run(){let e=Ve(i.rsConfig);if(!i.rsConfig.devServer){n.error("devServer is not defined in config");return}let{host:t,port:s}=i.rsConfig.devServer,r=await S(s,t);r!==s&&(i.rsConfig.devServer.port=r),new qe(i.rsConfig.devServer,e).start()}},Qe=new U});var be={};P(be,{default:()=>Ye});import{rspack as Xe}from"@rspack/core";var H,Ye,ve=p(()=>{"use strict";b();h();x();H=class extends f{async run(){Xe(i.rsConfig,(e,t)=>{if(e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}let s=t.toString({all:!1,colors:!0,assets:!0,chunks:!1,entrypoints:!0,timings:!0,version:!0});t.hasErrors()&&(n.error(s),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(s)),n.info(s),n.green("Compiled successfully.")})}},Ye=new H});import we from"url";import Ce from"chalk";import{ip as Ke}from"address";import{gateway4sync as Ze}from"default-gateway";function xe(o,e,t,s="/"){let r=y=>we.format({protocol:o,hostname:y,port:t,pathname:s}),a=y=>we.format({protocol:o,hostname:y,port:Ce.bold(t),pathname:s}),m=e==="0.0.0.0"||e==="::",l,u,g=Ce.gray("unavailable");if(m){l="localhost";try{let{int:y}=Ze();u=Ke(y||""),u&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(u)?g=a(u):u=void 0)}catch{}}else l=e,u=e,g=a(u);let V=a(l),Re=r(l);return{lanUrlForConfig:u,lanUrlForTerminal:g,localUrlForTerminal:V,localUrlForBrowser:Re}}var Se=p(()=>{"use strict"});var Pe={};P(Pe,{default:()=>ot});import Ee from"express";import et from"cors";import tt from"compression";import st from"https";import E from"path";import B from"node:fs/promises";var z,ot,J,Oe=p(()=>{"use strict";I();Se();h();b();x();z=class extends f{async run(){await new J().setup()}},ot=new z,J=class{app;resourcePath="";constructor(){let e=Ee();e.use(tt()),e.use(et()),this.app=e,this.resourcePath=E.join(i.empRoot,"resource")}startLogger({httpsOptions:e,host:t,port:s,publicPath:r}){if(r&&(r.indexOf("http://")>-1||r.indexOf("https://")>-1))n.info(`- Network: ${n.link(r)}`);else{let l=xe(e?"https":"http",t||"0.0.0.0",s,r);n.info(`- Local: ${n.link(l.localUrlForTerminal)}`),n.info(`- Network: ${n.link(l.lanUrlForTerminal)}`)}}async setup(){let e=i.resolve(i.rsConfig.output?.path);this.app.use(Ee.static(e));let t=await B.readFile(E.join(e,"index.html"),"utf8");this.app.get("*",(u,g)=>g.send(t));let{host:s,port:r}=i.rsConfig.devServer,a=i.rsConfig.devServer?.https,m=i.rsConfig.output?.publicPath==="auto"?"/":i.rsConfig.output?.publicPath,l=await S(r,s);if(a){let u=await B.readFile(E.join(this.resourcePath,"emp.key")),g=await B.readFile(E.join(this.resourcePath,"emp.cert"));st.createServer(typeof a!="boolean"?a:{key:u,cert:g},this.app).listen(l,()=>{this.startLogger({httpsOptions:a,host:s,port:l,publicPath:m})})}else this.app.listen(l,()=>{this.startLogger({httpsOptions:a,host:s,port:l,publicPath:m})})}}});h();h();import{program as d}from"commander";function ke(){d.version(i.empPkg.version,"-v, --version").usage("<command> [options]"),d.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async o=>{let{default:e}=await Promise.resolve().then(()=>(ye(),de));await e.setup("dev",o)}),d.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async o=>{let{default:e}=await Promise.resolve().then(()=>(ve(),be));await e.setup("build",o)}),d.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async o=>{let{default:e}=await Promise.resolve().then(()=>(Oe(),Pe));await e.setup("serve",o)}),d.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(o=>{}),d.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(o=>{}),d.parse(process.argv)}h();import rt from"fast-glob";import $e from"node:fs/promises";import W from"node:path";var it=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,nt=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,at=/import\(['"]([^;\n]+?)['"]\)/,_=class{list=[];outDir=i.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await rt(["dist/**/*.d.ts"]);let e=[];this.list.map(s=>{s=i.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await $e.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(it,r=>{let a=r.match(nt);if(a||(a=r.match(at)),a&&a[1]){let m=a[1];if(!m.startsWith("."))return r;let l=W.resolve(W.dirname(e),m).replace(this.outDir,this.aliasName);return r.replace(a[1],l)}return r});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
8
8
  ${t}}\r
9
- `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await Pe.writeFile(B.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},it=new z;function As(o){return o}export{As as defineConfig,it as dts,Ee as runScript,n as store};
9
+ `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await $e.writeFile(W.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},pt=new _;function Hs(o){return o}export{Hs as defineConfig,pt as dts,ke as runScript,i as store};
@@ -44,7 +44,11 @@ export declare class EmpConfig {
44
44
  name: string;
45
45
  filename: string;
46
46
  };
47
+ get css(): {
48
+ postcss: never[];
49
+ };
47
50
  syncEmpOptions(): Promise<void>;
51
+ get moduleTransformRule(): any;
48
52
  }
49
53
  declare const _default: EmpConfig;
50
54
  export default _default;
@@ -0,0 +1,18 @@
1
+ import type { GlobalStore } from '../../store';
2
+ declare class RspackCss {
3
+ store: GlobalStore;
4
+ setup(store: GlobalStore): Promise<void>;
5
+ sass(): Promise<void>;
6
+ less(): Promise<void>;
7
+ css(): Promise<void>;
8
+ get postcss(): {
9
+ loader: string;
10
+ options: {
11
+ postcssOptions: {
12
+ plugins: never[];
13
+ };
14
+ };
15
+ };
16
+ }
17
+ declare const _default: RspackCss;
18
+ export default _default;
@@ -3,8 +3,6 @@ declare class RspackModule {
3
3
  store: GlobalStore;
4
4
  setup(store: GlobalStore): Promise<void>;
5
5
  react(): Promise<void>;
6
- sass(): Promise<void>;
7
- less(): Promise<void>;
8
6
  files(): Promise<void>;
9
7
  }
10
8
  declare const _default: RspackModule;
@@ -1,6 +1,6 @@
1
1
  import { GlobalStore } from '../../store';
2
- declare class TransformScript {
2
+ declare class Script {
3
3
  js(store: GlobalStore): void;
4
4
  }
5
- declare const _default: TransformScript;
5
+ declare const _default: Script;
6
6
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import { Configuration as devServerConfig } from '@rspack/dev-server';
2
2
  import Chain from 'webpack-chain';
3
- import { HtmlRspackPluginOptions, ModuleFederationPluginOptions } from '@rspack/core';
3
+ import { HtmlRspackPluginOptions, ModuleFederationPluginOptions, RuleSetRule } from '@rspack/core';
4
4
  export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
5
5
  export type DebugType = {
6
6
  loggerLevel: LoggerType;
@@ -87,6 +87,13 @@ export type ReactType = {
87
87
  */
88
88
  svgr: boolean;
89
89
  };
90
+ export type CSSOptions = {
91
+ postcss?: [string, any][];
92
+ };
93
+ export interface ModuleTransform {
94
+ exclude?: RuleSetRule['exclude'][];
95
+ include?: RuleSetRule['include'][];
96
+ }
90
97
  export type EmpOptions = {
91
98
  /**
92
99
  * publicPath 根路径 可参考webpack,业务模式默认为 auto
@@ -115,5 +122,7 @@ export type EmpOptions = {
115
122
  chain?: (chain: Chain) => void;
116
123
  react?: ReactType;
117
124
  empShare?: ModuleFederationPluginOptions;
125
+ css?: CSSOptions;
126
+ moduleTransform?: ModuleTransform;
118
127
  };
119
128
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.0.0-alpha.14",
3
+ "version": "3.0.0-alpha.16",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -75,10 +75,10 @@
75
75
  "tsc-alias": "^1.8.8"
76
76
  },
77
77
  "dependencies": {
78
- "@rspack/core": "^0.5.0",
79
- "@rspack/dev-server": "^0.5.0",
80
- "@rspack/plugin-html": "^0.5.0",
81
- "@rspack/plugin-react-refresh": "^0.5.0",
78
+ "@rspack/core": "^0.5.1",
79
+ "@rspack/dev-server": "^0.5.1",
80
+ "@rspack/plugin-html": "^0.5.1",
81
+ "@rspack/plugin-react-refresh": "^0.5.1",
82
82
  "@svgr/webpack": "^8.1.0",
83
83
  "@types/node": "^20.8.7",
84
84
  "@types/react": "^18.2.30",
@@ -91,6 +91,8 @@
91
91
  "express": "^4.18.2",
92
92
  "fast-glob": "^3.3.1",
93
93
  "less-loader": "^11.1.3",
94
+ "postcss": "^8.4.33",
95
+ "postcss-loader": "^7.3.4",
94
96
  "sass-loader": "^13.3.2",
95
97
  "table": "^6.8.1",
96
98
  "typescript-plugin-css-modules": "^5.0.2",
@@ -98,7 +100,7 @@
98
100
  "webpack-chain": "^6.5.1"
99
101
  },
100
102
  "peerDependencies": {
101
- "react-refresh": "^0.14.0",
102
- "@swc/helpers": "^0.5.3"
103
+ "@swc/helpers": "^0.5.3",
104
+ "react-refresh": "^0.14.0"
103
105
  }
104
106
  }