@empjs/cli 3.0.0-alpha.16 → 3.0.0-alpha.17
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,4 +1,4 @@
|
|
|
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} `)}
|
|
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"),"@":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} `)}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare class RuntimePlugins {
|
|
2
|
+
constructor();
|
|
3
|
+
beforeInit(): void;
|
|
4
|
+
beforeLoadingRemote(): void;
|
|
5
|
+
loadRemoteMatch(): void;
|
|
6
|
+
loadRemote(): void;
|
|
7
|
+
errorLoadRemote(): void;
|
|
8
|
+
beforeLoadShare(): void;
|
|
9
|
+
beforePreloadRemote(): void;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: RuntimePlugins;
|
|
12
|
+
export default _default;
|